예제 #1
0
        private static void Main(string[] args)
        {
            var oCSharpDeveloper = new PersonController(new ProgrammingLanguageCSharp());
            Console.WriteLine(oCSharpDeveloper.GetCode());

            var oVisualBasicDeveloper = new PersonController(new ProgrammingLanguageVB());
            Console.WriteLine(oVisualBasicDeveloper.GetCode());
        }
        public void TestPersonController_ValidateCSharpCode_ReturnOK_NoMoq()
        {
            //Arrange
            var oPersonaController = new PersonController(new ProgrammingLanguageCSharp());

            //Act
            var sentence = oPersonaController.GetCode();

            //Assert

            Assert.AreEqual("var cSharp = new CSharp();", sentence);
        }
        public void TestPersonController_ValidateCSharpCode_ReturnOK_MoqClass()
        {
            //Arrange
            var mockProgrammingLanguage = new Mock<ProgrammingLanguageCSharp>();
            mockProgrammingLanguage.CallBase = true;

            var oPersonaController = new PersonController(mockProgrammingLanguage.Object);

            //Act
            var sentence = oPersonaController.GetCode();

            //Assert

            Assert.AreEqual("var cSharp = new CSharp();", sentence);
        }
        public void TestPersonController_ValidateCSharpCode_ReturnOK_Moq()
        {
            //Arrange
            var mockProgrammingLanguage = new Mock<IProgrammingLanguage>();

            mockProgrammingLanguage.Setup(m => m.WriteCodeDeclareVariable()).Returns("var cSharp = new CSharp();").Verifiable();
            var oPersonaController = new PersonController(mockProgrammingLanguage.Object);

            //Act
            var sentence = oPersonaController.GetCode();

            //Assert

            Assert.AreEqual("var cSharp = new CSharp();", sentence);
            mockProgrammingLanguage.Verify();
        }