public async void DeleteResultDeletesOnlyThatResult() { //Create the options to feed into the context for dependency injection... DbContextOptions <API_DanceFellowsDbContext> options = new DbContextOptionsBuilder <API_DanceFellowsDbContext>().UseInMemoryDatabase("DeletingADoesNotDeleteB").Options; using (API_DanceFellowsDbContext context = new API_DanceFellowsDbContext(options)) { //arrange Result result = new Result(); result.EventCompetitionID = 1; result.CompetitorID = 1; result.Placement = Placement.Finalled; Result resultTwo = new Result(); resultTwo.EventCompetitionID = 1; resultTwo.CompetitorID = 2; resultTwo.Placement = Placement.Position3; //act ResultManagementService resultServ = new ResultManagementService(context); await resultServ.CreateResult(result); await resultServ.CreateResult(resultTwo); await resultServ.DeleteResult(result.EventCompetitionID, result.CompetitorID); Result queryResult = await resultServ.GetResult(1, 2); //assert Assert.Equal(resultTwo, queryResult); } }
public async void DeleteDeletesARecordFromTheDatabase() { //Create the options to feed into the context for dependency injection... DbContextOptions <API_DanceFellowsDbContext> options = new DbContextOptionsBuilder <API_DanceFellowsDbContext>().UseInMemoryDatabase("DeleteDeletes").Options; using (API_DanceFellowsDbContext context = new API_DanceFellowsDbContext(options)) { //arrange Result result = new Result(); result.EventCompetitionID = 1; result.CompetitorID = 1; result.Placement = Placement.Finalled; //act ResultManagementService resultServ = new ResultManagementService(context); await resultServ.CreateResult(result); await resultServ.DeleteResult(result.EventCompetitionID, result.CompetitorID); Result queryResult = await resultServ.GetResult(1, 1); //assert Assert.Null(queryResult); } }