parent nodes: WikiOtros

TDD

Test Driven Development

Author: César TM
Date: 26/10/2017
Source:
http://www.c-sharpcorner.com/UploadFile/dommym/a-test-driven-development-tutorial-in-C-Sharp-4-0/
No: https://msdn.microsoft.com/es-es/communitydocs/alm/sobre-tdd-con-visual-studio


Para C#

Ejemplo de uno de los ficheros generados:
#include "StdAfx.h"
using namespace System::Collections::Generic;
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
using namespace GestionTrabajoDiario;
namespace GestionTrabajoDiarioTest 
{
    using namespace System;
    ref class CGlobalTest;
    
    
    /// <summary>
///This is a test class for CGlobalTest and is intended
///to contain all CGlobalTest Unit Tests
///</summary>
	[TestClass]
	public ref class CGlobalTest
	{

	private: Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^  testContextInstance;
			 /// <summary>
			 ///Gets or sets the test context which provides
			 ///information about and functionality for the current test run.
			 ///</summary>
	public: property Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^  TestContext
			{
				Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^  get()
				{
					return testContextInstance;
				}
				System::Void set(Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^  value)
				{
					testContextInstance = value;
				}
			}

#pragma region Additional test attributes
			// 
			//You can use the following additional attributes as you write your tests:
			//
			//Use ClassInitialize to run code before running the first test in the class
			//public: [ClassInitialize]
			//static System::Void MyClassInitialize(TestContext^  testContext)
			//{
			//}
			//
			//Use ClassCleanup to run code after all tests in a class have run
			//public: [ClassCleanup]
			//static System::Void MyClassCleanup()
			//{
			//}
			//
			//Use TestInitialize to run code before running each test
			//public: [TestInitialize]
			//System::Void MyTestInitialize()
			//{
			//}
			//
			//Use TestCleanup to run code after each test has run
			//public: [TestCleanup]
			//System::Void MyTestCleanup()
			//{
			//}
			//
#pragma endregion
			/// <summary>
			///A test for getCurrentUser
			///</summary>
	public: [TestMethod]
			void getCurrentUserTest()
			{
				String^  expected = "CT";
				String^  actual;
				actual = CGlobal::getCurrentUser();
				Assert::AreEqual(expected, actual);
				//Assert::Inconclusive(L"Verify the correctness of this test method.");
			}
			/// <summary>
			///A test for getItemFromList
			///</summary>
	public: [TestMethod]
			void getItemFromListTest()
			{
				String^  theStatus = "HECH";
				String^  theTicketNumber = "1706221615279";
				bool deleteItem = false; 
				String^  expected = "HECH  1706221615279-VAL-Apostilla_y_legalizacion_por_titulo_y_certificación	:CLIE:Solicitud:#D:MN:";
				String^  actual;
				actual = CGlobal::getItemFromList(theStatus, theTicketNumber, deleteItem);
				Assert::AreEqual(expected, actual);
				Assert::Inconclusive(L"Verify the correctness of this test method.");
			}
			/// <summary>
			///A test for getMasterList
			///</summary>
	public: [TestMethod]
			void getMasterListTest()
			{
				String^  estado = "HECH"; 
				List<String^ >^  expected = CGlobal::hechos;  
				List<String^ >^  actual;
				actual = CGlobal::getMasterList(estado);
				Assert::AreEqual(expected, actual);
				Assert::Inconclusive(L"Verify the correctness of this test method.");
			}
			/// <summary>
			///A test for replaceMetaCharsWithChar
			///</summary>
	public: [TestMethod]
			void replaceMetaCharsWithCharTest()
			{
				String^  theString = "MÚRCÍÉLÁGÓ_múrcíélágó:ñ:Ñ:Çç[]hòlà";
				wchar_t theChar = '_'; 
				String^  expected = "MURCIELAGO_murcielago_n_N_Cc__hola";
				String^  actual;
				actual = CGlobal::replaceMetaCharsWithChar(theString, theChar);
				Assert::AreEqual(expected, actual);
				//Assert::Inconclusive(L"Verify the correctness of this test method.");
			}
			/// <summary>
			///A test for setItemInList
			///</summary>
	/*public: [TestMethod]
			void setItemInListTest()
			{
				String^  theStatus = "HECH";
				String^  theFullItemString = "";
				CGlobal::setItemInList(theStatus, theFullItemString);
				Assert::Inconclusive(L"A method that does not return a value cannot be verified.");
			}*/
	};
}
namespace GestionTrabajoDiarioTest {
    
}









_________________________________________________________________________________________________________
WikiOtros [camelCaseWordsEnabled: false]