Exemplo n.º 1
0
        public void ContextBuildsAViewModelWithAllCategories()
        {
            var category = new Category {
                Description = "Category 1"
            };
            var categoryViewModel = new CategoryViewModel {
                Description = "Category 1"
            };
            var categories = new List <Category> {
                category
            };
            var mockCategoryRepository = new MockCategoryRepository().StubGetAllToReturn(categories);
            var mockCategoryMapper     = new MockCategoryMapper().StubMapToReturn(categoryViewModel);
            var categoriesContext      = new CategoriesContext(mockCategoryRepository, mockCategoryMapper);

            var viewModel = categoriesContext.BuildViewModel();

            Assert.NotNull(viewModel);
            Assert.IsType <CategoriesViewModel>(viewModel);
            Assert.Equal(categories.Count, viewModel.Categories.Count());

            var categoryViewModels = viewModel.Categories.ToList();

            Assert.Equal(category.Id, categoryViewModels.First()
                         .Id);
            Assert.Equal(category.Description, categoryViewModels.First()
                         .Description);

            mockCategoryRepository.VerifyGetAllCalled();
            mockCategoryMapper.VerifyMapCalledWith(category);
        }
Exemplo n.º 2
0
        public void ContextBuildsAViewModel()
        {
            var mockCategoryRepository = new MockCategoryRepository();
            var mockCategoryMapper     = new MockCategoryMapper();
            var categoriesContext      = new CategoriesContext(mockCategoryRepository, mockCategoryMapper);

            var viewModel = categoriesContext.BuildViewModel();

            Assert.NotNull(viewModel);
            Assert.IsType <CategoriesViewModel>(viewModel);
        }