public void ContextSavesANewCategory() { var category = new Category { Id = 4, Description = "This is new category" }; var categoryViewModel = new CategoryViewModel { Id = 4, Description = "This is a new category" }; var mockCategoryRepository = new MockCategoryRepository(); var mockCategoryMapper = new MockCategoryMapper().StubMapToReturn(category); var categoryContext = new CategoryContext(mockCategoryRepository, mockCategoryMapper); categoryContext.Save(categoryViewModel); mockCategoryRepository.VerifyGetByCalledWith(categoryViewModel.Id); mockCategoryRepository.VerifyAddCalledWith(category); mockCategoryMapper.VerifyMapCalledWith(categoryViewModel); }
public void ContextSavesAnUpdatedCategory() { var category = new Category { Id = 2, Description = "This is category 2" }; var categoryViewModel = new CategoryViewModel { Id = 2, Description = "This is an updated category" }; var mockCategoryRepository = new MockCategoryRepository().StubGetByIdToReturn(category); var mockCategoryMapper = new MockCategoryMapper(); var categoryContext = new CategoryContext(mockCategoryRepository, mockCategoryMapper); categoryContext.Save(categoryViewModel); mockCategoryRepository.VerifyGetByCalledWith(categoryViewModel.Id); mockCategoryRepository.VerifyUpdateCalledWith(category); }