public void AllHomeMatchesByTeamIdShouldReturnNone() { var options = new DbContextOptionsBuilder <FooteoDbContext>() .UseInMemoryDatabase(databaseName: "AllHomeMatchesNone_Teams_DB") .Options; var dbContext = new FooteoDbContext(options); var townsService = new TownsService(dbContext); var leaguesService = new LeaguesService(dbContext, townsService); var mockUserStore = new Mock <IUserStore <FooteoUser> >(); var userManager = new Mock <UserManager <FooteoUser> >(mockUserStore.Object, null, null, null, null, null, null, null, null); var town = townsService.CreateTown("Ruse"); var user = new FooteoUser { Age = new Random().Next(20, 30), Email = $"*****@*****.**", FirstName = "Footeo", LastName = "Player", UserName = $"footeoPlayer", Town = town, PasswordHash = "123123", Player = new Player { FullName = "Footeo Player" } }; dbContext.Users.Add(user); dbContext.SaveChanges(); userManager.Setup(u => u.RemoveFromRoleAsync(user, "Player")).Returns(Task.FromResult(IdentityResult.Success)); userManager.Setup(u => u.AddToRoleAsync(user, "PlayerInTeam")).Returns(Task.FromResult(IdentityResult.Success)); userManager.Setup(u => u.AddToRoleAsync(user, "Captain")).Returns(Task.FromResult(IdentityResult.Success)); var teamsService = new TeamsService(dbContext, townsService, leaguesService, userManager.Object, null); teamsService.CreateTeam("Team4", "TTT", user.UserName); var team = dbContext.Teams.FirstOrDefault(n => n.Name == "Team4"); var allHomeMatches = teamsService.AllHomeMatchesByTeamId(team.Id).ToList(); var allHomeMatchesCount = allHomeMatches.Count; var expectedHomeMatchesCount = 0; Assert.AreEqual(expectedHomeMatchesCount, allHomeMatchesCount); }