public async void TestForCreateLeague() { var options = new DbContextOptionsBuilder <LeagueContext>() .UseInMemoryDatabase(databaseName: "p3LeagueControllerCreateLeague") .Options; using (var context = new LeagueContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repo r = new Repo(context, new NullLogger <Repo>()); Logic logic = new Logic(r, new NullLogger <Repo>()); LeagueController leagueController = new LeagueController(logic); var sport = new Sport { SportID = 35, SportName = "basketball" }; r.Sports.Add(sport); await r.CommitSave(); var leagueDto = new CreateLeagueDto { LeagueName = "sports", SportName = sport.SportName }; var createLeague = await leagueController.CreateLeague(leagueDto); Assert.IsAssignableFrom <League>((createLeague as OkObjectResult).Value); var createLeague2 = await leagueController.CreateLeague(leagueDto); Assert.IsAssignableFrom <string>((createLeague2 as ConflictObjectResult).Value); } }