Esempio n. 1
0
        public void ContextBuildsAViewModelWithNewCategory()
        {
            var mockCategoryRepository = new MockCategoryRepository();
            var mockCategoryMapper     = new MockCategoryMapper();
            var categoryContext        = new CategoryContext(mockCategoryRepository, mockCategoryMapper);

            var viewModel = categoryContext.BuildViewModel();

            Assert.NotNull(viewModel);
        }
Esempio n. 2
0
        public void ContextBuildsAViewModelWithEditedCategory()
        {
            var category = new Category {
                Id = 2, Description = "This is category 2"
            };
            var categoryViewModel = new CategoryViewModel {
                Id = 2, Description = "This is category 2"
            };
            var mockCategoryRepository = new MockCategoryRepository().StubGetByIdToReturn(category);
            var mockCategoryMapper     = new MockCategoryMapper().StubMapToReturn(categoryViewModel);
            var categoryContext        = new CategoryContext(mockCategoryRepository, mockCategoryMapper);

            var viewModel = categoryContext.BuildViewModel(category.Id);

            Assert.NotNull(viewModel);
            mockCategoryRepository.VerifyGetByCalledWith(category.Id);
            mockCategoryMapper.VerifyMapCalledWith(category);
        }