예제 #1
0
        public void HomePageViewModelManager_can_receive_list_of_PictureViewModels()
        {
            //Arrange
            var homePageVMM = new HomePageViewModelManager(_picServiceMock.Object
                , _dessertServiceMock.Object);

            //Action
            var viewModel = homePageVMM.Get();
            var derivedPic =
                viewModel.TopSlidePictures.Select(
                    t =>
                    new Picture { Alt = t.Alt, OrdinalIndex = t.OrdinalIndex, ImageType = t.ImageType }).
                    ToList()[0];

            //Assertions
            _picServiceMock.Verify(psm => psm.GetFirstPictures(HomePageViewModel.TOP_SLIDE_PIC_COUNT), Times.Once());
            Assert.That(viewModel.TopSlidePictures.Count == 1);
            Assert.AreEqual(derivedPic.Alt, _testPic.Alt);
            Assert.AreEqual(derivedPic.OrdinalIndex, _testPic.OrdinalIndex);
            Assert.AreEqual(derivedPic.ImageType, _testPic.ImageType);
            Assert.AreEqual(string.Format("{0}{1}.{2}", ConfigurationManager.AppSettings["PhotoDirectory"], _testPic.ID, _testPic.ImageType)
                            , viewModel.TopSlidePictures.First().Url);
        }
예제 #2
0
        public void The_HomePageViewModelManager_can_receive_list_of_DessertViewModels()
        {
            //Arrange
            IHomePageViewModelManager homePageVMM = new HomePageViewModelManager(_picServiceMock.Object
                , _dessertServiceMock.Object);

            //Action
            HomePageViewModel viewModel = homePageVMM.Get();
            Dessert derivedDessert =
                viewModel.Desserts.Select(
                    t =>
                    new Dessert { ID = t.ID, Name = t.Name, Description = t.Description, Likes = t.Likes, Dislikes = t.Dislikes, Picture = _testPic2}).
                    ToList()[0];

            //Assertions
            Assert.That(viewModel.Desserts.Count == 2);
            Assert.AreEqual(derivedDessert.Name, _testDessert2.Name);
            Assert.AreEqual(derivedDessert.Description, _testDessert2.Description);
            Assert.AreEqual(derivedDessert.Likes, _testDessert2.Likes);
            Assert.AreEqual(derivedDessert.Dislikes, _testDessert2.Dislikes);
            Assert.AreEqual(derivedDessert.Picture, _testDessert2.Picture);
        }