예제 #1
0
            async Task HasItems()
            {
                var repo = mockup.Get <IItemRepository>();
                await repo.AddRange(new ItemInput[] { ItemTests.CreateInput(), ItemTests.CreateInput(), ItemTests.CreateInput() });

                Assert.True(await repo.HasItems());
            }
예제 #2
0
            async Task Add()
            {
                var repo   = mockup.Get <IItemRepository>();
                var result = await repo.Add(ItemTests.CreateInput());

                Assert.NotNull(result);
            }
예제 #3
0
            async Task Add()
            {
                var controller = mockup.Get <ItemsController>();

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

                Assert.NotNull(result);
            }
예제 #4
0
            void EntityToView()
            {
                var mapper = mockup.Get <AppMapper>();
                var entity = ItemTests.CreateEntity();
                var view   = mapper.MapItem(entity, new Item());

                Assert.Equal(entity.ItemId, view.ItemId);
                AssertEqual(entity, view);
            }
예제 #5
0
            async Task Update()
            {
                var repo   = mockup.Get <IItemRepository>();
                var result = await repo.Add(ItemTests.CreateInput());

                Assert.NotNull(result);
                var updateResult = await repo.Update(result.ItemId, ItemTests.CreateInput());

                Assert.NotNull(updateResult);
            }
예제 #6
0
            void InputToEntity()
            {
                var mapper = mockup.Get <AppMapper>();
                var input  = ItemTests.CreateInput();
                var entity = mapper.MapItem(input, new ItemEntity());

                //Make sure the id does not copy over
                Assert.Equal(default(Guid), entity.ItemId);
                AssertEqual(input, entity);
            }
예제 #7
0
            async Task Update()
            {
                var controller = mockup.Get <ItemsController>();

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

                Assert.NotNull(result);

                var updateResult = await controller.Update(result.ItemId, ItemTests.CreateInput());

                Assert.NotNull(updateResult);
            }
예제 #8
0
            async Task Get()
            {
                var dbContext = mockup.Get <AppDbContext>();
                var repo      = mockup.Get <IItemRepository>();
                await repo.AddRange(new ItemInput[] { ItemTests.CreateInput(), ItemTests.CreateInput(), ItemTests.CreateInput() });

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

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

                Assert.NotNull(getResult);
            }
예제 #9
0
            async Task List()
            {
                //This could be more complete
                var repo = mockup.Get <IItemRepository>();
                await repo.AddRange(new ItemInput[] { ItemTests.CreateInput(), ItemTests.CreateInput(), ItemTests.CreateInput() });

                var query  = new ItemQuery();
                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);
            }
예제 #10
0
            async Task Delete()
            {
                var controller = mockup.Get <ItemsController>();

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

                Assert.NotNull(result);

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

                Assert.Equal(1, listResult.Total);

                await controller.Delete(result.ItemId);

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

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

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

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

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

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

                Assert.NotNull(result);
            }
예제 #12
0
            async Task List()
            {
                var totalItems = 3;

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

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

                var query  = new ItemQuery();
                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 <IItemRepository>();
     await repo.AddRange(new ItemInput[] { ItemTests.CreateInput(), ItemTests.CreateInput(), ItemTests.CreateInput() });
 }