async Task HasItems() { var repo = mockup.Get <IItemRepository>(); await repo.AddRange(new ItemInput[] { ItemTests.CreateInput(), ItemTests.CreateInput(), ItemTests.CreateInput() }); Assert.True(await repo.HasItems()); }
async Task Add() { var repo = mockup.Get <IItemRepository>(); var result = await repo.Add(ItemTests.CreateInput()); Assert.NotNull(result); }
async Task Add() { var controller = mockup.Get <ItemsController>(); var result = await controller.Add(ItemTests.CreateInput()); Assert.NotNull(result); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
async Task AddRange() { var repo = mockup.Get <IItemRepository>(); await repo.AddRange(new ItemInput[] { ItemTests.CreateInput(), ItemTests.CreateInput(), ItemTests.CreateInput() }); }