public void The_dessert_view_model_manager_can_call_the_service_to_save_the_dessert() { //Arrange HomePageModelMapper.Init(); var viewModelManager = new DessertViewModelManager(_httpHelperMock.Object, _pictureServiceMock.Object, _dessertServiceMock.Object); //Action var dessert = AutoMapper.Mapper.Map<DessertBoxViewModel, Dessert>(_testDessertViewModel); viewModelManager.Add(_testDessertViewModel); //Assertions _dessertServiceMock.Verify(service => service.Save(It.IsAny<Dessert>())); HyperAssert.ThatPropertiesAreEqual(_testDessert, dessert); }
public void The_DessertViewModelManager_can_save_the_picture_to_the_Temp_folder_and_add_it_to_session() { //Arrange var dessertVMM = new DessertViewModelManager( _httpHelperMock.Object, _pictureServiceMock.Object, _dessertServiceMock.Object); //Actions var tempPicViewModel = dessertVMM.UploadTempPicture(_postedfileMock.Object); //Assertions _httpHelperMock.Verify(hpr => hpr.ExistsInSession(TEMP_PIC_SESSION_KEY)); _postedfileMock.VerifyGet(file => file.FileName, Times.Once()); _postedfileMock.Verify(file => file.SaveAs(TEMP_PIC_FILE_PATH), Times.Once()); _httpHelperMock.Verify(hpr => hpr.AddToAppSession(TEMP_PIC_SESSION_KEY, It.IsAny<TempPictureViewModel>()), Times.Once()); Assert.AreEqual(tempPicViewModel.Name, TEMP_PIC_FILE_NAME); Assert.AreEqual(tempPicViewModel.SavedFIlePath, TEMP_PIC_FILE_PATH); Assert.AreEqual(tempPicViewModel.Uri, _tempPictureUrl); Assert.AreEqual(tempPicViewModel.ImageType, "jpg"); }
public void The_DessertViewModelManager_can_call_the_DessertService_to_like_the_dessert() { //Arrange var _viewModelManager = new DessertViewModelManager(_httpHelperMock.Object, _pictureServiceMock.Object, _dessertServiceMock.Object); //Actions _viewModelManager.Like(_dessertGuid); //Assertions _dessertServiceMock.Verify(svc => svc.LikeDessert(_dessertGuid)); }