async Task HasRights() { var repo = mockup.Get <IRightRepository>(); await repo.AddRange(new RightInput[] { RightTests.CreateInput(), RightTests.CreateInput(), RightTests.CreateInput() }); Assert.True(await repo.HasRights()); }
async Task Add() { var repo = mockup.Get <IRightRepository>(); var result = await repo.Add(RightTests.CreateInput()); Assert.NotNull(result); }
async Task Add() { var controller = mockup.Get <RightsController>(); var result = await controller.Add(RightTests.CreateInput()); Assert.NotNull(result); }
void EntityToView() { var mapper = mockup.Get <AppMapper>(); var entity = RightTests.CreateEntity(); var view = mapper.MapRight(entity, new Right()); Assert.Equal(entity.RightId, view.RightId); AssertEqual(entity, view); }
void InputToEntity() { var mapper = mockup.Get <AppMapper>(); var input = RightTests.CreateInput(); var entity = mapper.MapRight(input, new RightEntity()); //Make sure the id does not copy over Assert.Equal(default(Guid), entity.RightId); AssertEqual(input, entity); }
async Task Update() { var repo = mockup.Get <IRightRepository>(); var result = await repo.Add(RightTests.CreateInput()); Assert.NotNull(result); var updateResult = await repo.Update(result.RightId, RightTests.CreateInput()); Assert.NotNull(updateResult); }
async Task Update() { var controller = mockup.Get <RightsController>(); var result = await controller.Add(RightTests.CreateInput()); Assert.NotNull(result); var updateResult = await controller.Update(result.RightId, RightTests.CreateInput()); Assert.NotNull(updateResult); }
async Task Get() { var dbContext = mockup.Get <AppDbContext>(); var repo = mockup.Get <IRightRepository>(); await repo.AddRange(new RightInput[] { RightTests.CreateInput(), RightTests.CreateInput(), RightTests.CreateInput() }); var result = await repo.Add(RightTests.CreateInput()); Assert.Equal <int>(4, dbContext.Rights.Count()); var getResult = await repo.Get(result.RightId); Assert.NotNull(getResult); }
async Task List() { //This could be more complete var repo = mockup.Get <IRightRepository>(); await repo.AddRange(new RightInput[] { RightTests.CreateInput(), RightTests.CreateInput(), RightTests.CreateInput() }); var query = new RightQuery(); 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 <RightsController>(); var result = await controller.Add(RightTests.CreateInput()); Assert.NotNull(result); var listResult = await controller.List(new RightQuery()); Assert.Equal(1, listResult.Total); await controller.Delete(result.RightId); listResult = await controller.List(new RightQuery()); Assert.Equal(0, listResult.Total); }
async Task Get() { var totalItems = 3; var controller = mockup.Get <RightsController>(); for (var i = 0; i < totalItems; ++i) { Assert.NotNull(await controller.Add(RightTests.CreateInput())); } //Manually add the item we will look back up var lookup = await controller.Add(RightTests.CreateInput()); var result = await controller.Get(lookup.RightId); Assert.NotNull(result); }
async Task List() { var totalItems = 3; var controller = mockup.Get <RightsController>(); for (var i = 0; i < totalItems; ++i) { Assert.NotNull(await controller.Add(RightTests.CreateInput())); } var query = new RightQuery(); 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 <IRightRepository>(); await repo.AddRange(new RightInput[] { RightTests.CreateInput(), RightTests.CreateInput(), RightTests.CreateInput() }); }