public void Exists_ReturnsFalse() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using (var dbContext = new ApplicationDbContext(options)) { var phonesService = new PhonesService(dbContext); var result = phonesService.Exists(1); Assert.False(result); } }
public void Exists_ReturnsTrue() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using (var dbContext = new ApplicationDbContext(options)) { Phone phone = new Phone() { PhoneNumber = "0897248721" }; dbContext.Phones.Add(phone); dbContext.SaveChanges(); var phonesService = new PhonesService(dbContext); var result = phonesService.Exists(1); Assert.True(result); } }