public void People_Pets_Return_Correct_View()
        {
            // Arrange
            var peoplePetsTestController = new PeoplePetsController();

            //Action
            var result = peoplePetsTestController.PeoplePets() as ViewResult;

            // Assert
            Assert.AreEqual("PeoplePets", result.ViewName);
        }
        public void People_Pets_Controller_Model_Test()
        {
            // Arrange
            var peoplePetsTestController = new PeoplePetsController(_Service.Object);

            //Action
            var result = peoplePetsTestController.PeoplePets() as ViewResult;

            // Assert
            Assert.IsInstanceOfType(result.ViewData.Model, typeof(PetsViewModel));
        }
Пример #3
0
        public void FemaleCatsTest()
        {
            //Arrange
            var testPeoplePetsController = new PeoplePetsController(_Service);

            //Action
            var result = testPeoplePetsController.PeoplePets() as ViewResult;

            //Assert
            var testPeoplePetsViewModel = (PetsViewModel)result.ViewData.Model;

            foreach (var femaleCats in testPeoplePetsViewModel.FemaleCats)
            {
                Assert.AreEqual("Cat", femaleCats.Type);
            }
        }
Пример #4
0
        public void SortedPetsTest()
        {
            //Arrange
            Mock <IProcessJsonDataService> _processMoqJsonDataService = new Mock <IProcessJsonDataService>();

            _processMoqJsonDataService.Setup(service => service.GetPeoplePetsData())
            .Returns(GetMocPetsViewModelData());

            var testPeoplePetsController = new PeoplePetsController(_processMoqJsonDataService.Object);
            var moqResult = testPeoplePetsController.PeoplePets() as ViewResult;

            PetsViewModel moqPeoplePets = (PetsViewModel)moqResult.ViewData.Model;

            PetsViewModel peoplePets = _Service.GetPeoplePetsData();

            //Action
            var serializer     = new System.Web.Script.Serialization.JavaScriptSerializer();
            var expectedResult = serializer.Serialize(moqPeoplePets);
            var actualResult   = serializer.Serialize(peoplePets);

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }