Ejemplo n.º 1
0
        public void TestSummary()
        {
            //Arrange
            var mockRepository = new Mock <ICityRepository>();

            mockRepository.SetupGet(m => m.Cities).Returns(new List <City>
            {
                new City {
                    Population = 100
                },
                new City {
                    Population = 20000
                },
                new City {
                    Population = 1000000
                },
                new City {
                    Population = 500000
                }
            });
            var viewComponent = new CitySummary(mockRepository.Object);

            //Act
            ViewViewComponentResult result = viewComponent.Invoke(false) as ViewViewComponentResult;

            //Assert
            Assert.IsType <CityViewModel>(result.ViewData.Model);
            Assert.Equal(4, ((CityViewModel)result.ViewData.Model).Cities);
            Assert.Equal(1520100, ((CityViewModel)result.ViewData.Model).Population);
        }
Ejemplo n.º 2
0
        public void TestSummary()
        {
            //Arrange
            var mock = new Mock <ICity>();

            mock.SetupGet(m => m.Cities).Returns(new List <City>
            {
                new City {
                    Population = 100
                },
                new City {
                    Population = 200
                }
            });

            var view = new CitySummary(mock.Object);


            //Act

            ViewViewComponentResult result = view.Invoke(false) as ViewViewComponentResult;


            //Assert
            Assert.IsType(typeof(ViewCityModel), result.ViewData.Model);
            Assert.Equal(2, ((ViewCityModel)result.ViewData.Model).Cities);
            Assert.Equal(300, ((ViewCityModel)result.ViewData.Model).Population);
        }