public void CountForUser_ReturnsCorrectUserReservations() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using (var dbContext = new ApplicationDbContext(options)) { var user = new ApplicationUser { UserName = "******", Email = "*****@*****.**" }; Reservation reservation = new Reservation() { VehicleMake = "BMW", VehicleModel = "M5", LicenseNumber = "СА 1234 КР", PhoneNumber = "0897482124", ReservationDateTime = new DateTime(2020, 3, 21, 10, 30, 10), User = user, }; var reservationsService = new ReservationsService(dbContext); dbContext.Reservations.Add(reservation); dbContext.SaveChanges(); var result = reservationsService.CountForUser(user.UserName); Assert.Equal(1, result); } }