async Task HasEntries() { var repo = mockup.Get <IEntryRepository>(); await repo.AddRange(new EntryInput[] { EntryTests.CreateInput(), EntryTests.CreateInput(), EntryTests.CreateInput() }); Assert.True(await repo.HasEntries()); }
async Task Add() { var repo = mockup.Get <IEntryRepository>(); var result = await repo.Add(EntryTests.CreateInput()); Assert.NotNull(result); }
async Task Add() { var controller = mockup.Get <EntriesController>(); var result = await controller.Add(EntryTests.CreateInput()); Assert.NotNull(result); }
async Task Update() { var repo = mockup.Get <IEntryRepository>(); var result = await repo.Add(EntryTests.CreateInput()); Assert.NotNull(result); var updateResult = await repo.Update(result.EntryId, EntryTests.CreateInput()); Assert.NotNull(updateResult); }
void InputToEntity() { var mapper = mockup.Get <AppMapper>(); var input = EntryTests.CreateInput(); var entity = mapper.MapEntry(input, new EntryEntity()); //Make sure the id does not copy over Assert.Equal(default(Guid), entity.EntryId); AssertEqual(input, entity); }
async Task Update() { var controller = mockup.Get <EntriesController>(); var result = await controller.Add(EntryTests.CreateInput()); Assert.NotNull(result); var updateResult = await controller.Update(result.EntryId, EntryTests.CreateInput()); Assert.NotNull(updateResult); }
async Task Get() { var dbContext = mockup.Get <AppDbContext>(); var repo = mockup.Get <IEntryRepository>(); await repo.AddRange(new EntryInput[] { EntryTests.CreateInput(), EntryTests.CreateInput(), EntryTests.CreateInput() }); var result = await repo.Add(EntryTests.CreateInput()); Assert.Equal <int>(4, dbContext.Entries.Count()); var getResult = await repo.Get(result.EntryId); Assert.NotNull(getResult); }
async Task List() { //This could be more complete var repo = mockup.Get <IEntryRepository>(); await repo.AddRange(new EntryInput[] { EntryTests.CreateInput(), EntryTests.CreateInput(), EntryTests.CreateInput() }); var query = new EntryQuery(); 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 <EntriesController>(); var result = await controller.Add(EntryTests.CreateInput()); Assert.NotNull(result); var listResult = await controller.List(new EntryQuery()); Assert.Equal(1, listResult.Total); await controller.Delete(result.EntryId); listResult = await controller.List(new EntryQuery()); Assert.Equal(0, listResult.Total); }
async Task Get() { var totalItems = 3; var controller = mockup.Get <EntriesController>(); for (var i = 0; i < totalItems; ++i) { Assert.NotNull(await controller.Add(EntryTests.CreateInput())); } //Manually add the item we will look back up var lookup = await controller.Add(EntryTests.CreateInput()); var result = await controller.Get(lookup.EntryId); Assert.NotNull(result); }
async Task List() { var totalItems = 3; var controller = mockup.Get <EntriesController>(); for (var i = 0; i < totalItems; ++i) { Assert.NotNull(await controller.Add(EntryTests.CreateInput())); } var query = new EntryQuery(); 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 <IEntryRepository>(); await repo.AddRange(new EntryInput[] { EntryTests.CreateInput(), EntryTests.CreateInput(), EntryTests.CreateInput() }); }