public void Exist_ReturnsTrue() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using (var dbContext = new ApplicationDbContext(options)) { Reservation reservation = new Reservation() { VehicleMake = "BMW", VehicleModel = "M5", LicenseNumber = "СА 1234 КР", PhoneNumber = "0897482124", ReservationDateTime = new DateTime(2020, 3, 21, 10, 30, 10), }; dbContext.Reservations.Add(reservation); dbContext.SaveChanges(); var reservationsService = new ReservationsService(dbContext); var result = reservationsService.Exists(reservation.Id); Assert.True(result); } }
public void Exist_ReturnsFalse() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using (var dbContext = new ApplicationDbContext(options)) { var reservationsService = new ReservationsService(dbContext); var result = reservationsService.Exists("fsfsfsf"); Assert.False(result); } }