Пример #1
0
            async Task Add()
            {
                var repo   = mockup.Get <ICategoryRepository>();
                var result = await repo.Add(CategoryTests.CreateInput());

                Assert.NotNull(result);
            }
Пример #2
0
            async Task HasCategories()
            {
                var repo = mockup.Get <ICategoryRepository>();
                await repo.AddRange(new CategoryInput[] { CategoryTests.CreateInput(), CategoryTests.CreateInput(), CategoryTests.CreateInput() });

                Assert.True(await repo.HasCategories());
            }
            async Task Add()
            {
                var controller = mockup.Get <CategoriesController>();

                var result = await controller.Add(CategoryTests.CreateInput());

                Assert.NotNull(result);
            }
Пример #4
0
            void EntityToView()
            {
                var mapper = mockup.Get <AppMapper>();
                var entity = CategoryTests.CreateEntity();
                var view   = mapper.MapCategory(entity, new Category());

                Assert.Equal(entity.CategoryId, view.CategoryId);
                AssertEqual(entity, view);
            }
Пример #5
0
            async Task Update()
            {
                var repo   = mockup.Get <ICategoryRepository>();
                var result = await repo.Add(CategoryTests.CreateInput());

                Assert.NotNull(result);
                var updateResult = await repo.Update(result.CategoryId, CategoryTests.CreateInput());

                Assert.NotNull(updateResult);
            }
Пример #6
0
            void InputToEntity()
            {
                var mapper = mockup.Get <AppMapper>();
                var input  = CategoryTests.CreateInput();
                var entity = mapper.MapCategory(input, new CategoryEntity());

                //Make sure the id does not copy over
                Assert.Equal(default(Guid), entity.CategoryId);
                AssertEqual(input, entity);
            }
            async Task Update()
            {
                var controller = mockup.Get <CategoriesController>();

                var result = await controller.Add(CategoryTests.CreateInput());

                Assert.NotNull(result);

                var updateResult = await controller.Update(result.CategoryId, CategoryTests.CreateInput());

                Assert.NotNull(updateResult);
            }
Пример #8
0
            async Task Get()
            {
                var dbContext = mockup.Get <AppDbContext>();
                var repo      = mockup.Get <ICategoryRepository>();
                await repo.AddRange(new CategoryInput[] { CategoryTests.CreateInput(), CategoryTests.CreateInput(), CategoryTests.CreateInput() });

                var result = await repo.Add(CategoryTests.CreateInput());

                Assert.Equal <int>(4, dbContext.Categories.Count());
                var getResult = await repo.Get(result.CategoryId);

                Assert.NotNull(getResult);
            }
Пример #9
0
            async Task List()
            {
                //This could be more complete
                var repo = mockup.Get <ICategoryRepository>();
                await repo.AddRange(new CategoryInput[] { CategoryTests.CreateInput(), CategoryTests.CreateInput(), CategoryTests.CreateInput() });

                var query  = new CategoryQuery();
                var result = await repo.List(query);

                Assert.Equal(query.Limit, result.Limit);
                Assert.Equal(query.Offset, result.Offset);
                Assert.Equal(3, result.Total);
                Assert.NotEmpty(result.Items);
            }
            async Task Delete()
            {
                var controller = mockup.Get <CategoriesController>();

                var result = await controller.Add(CategoryTests.CreateInput());

                Assert.NotNull(result);

                var listResult = await controller.List(new CategoryQuery());

                Assert.Equal(1, listResult.Total);

                await controller.Delete(result.CategoryId);

                listResult = await controller.List(new CategoryQuery());

                Assert.Equal(0, listResult.Total);
            }
            async Task Get()
            {
                var totalItems = 3;

                var controller = mockup.Get <CategoriesController>();

                for (var i = 0; i < totalItems; ++i)
                {
                    Assert.NotNull(await controller.Add(CategoryTests.CreateInput()));
                }

                //Manually add the item we will look back up
                var lookup = await controller.Add(CategoryTests.CreateInput());

                var result = await controller.Get(lookup.CategoryId);

                Assert.NotNull(result);
            }
            async Task List()
            {
                var totalItems = 3;

                var controller = mockup.Get <CategoriesController>();

                for (var i = 0; i < totalItems; ++i)
                {
                    Assert.NotNull(await controller.Add(CategoryTests.CreateInput()));
                }

                var query  = new CategoryQuery();
                var result = await controller.List(query);

                Assert.Equal(query.Limit, result.Limit);
                Assert.Equal(query.Offset, result.Offset);
                Assert.Equal(3, result.Total);
                Assert.NotEmpty(result.Items);
            }
Пример #13
0
 async Task AddRange()
 {
     var repo = mockup.Get <ICategoryRepository>();
     await repo.AddRange(new CategoryInput[] { CategoryTests.CreateInput(), CategoryTests.CreateInput(), CategoryTests.CreateInput() });
 }