public void UserAdded_AppearsInContext() { SourceUser newUser; var srcUser = new SourceUser { EmailAddress = "*****@*****.**", UserName = "******" }; using (var efContext = new SourceDbContext(_srcConnection)) { efContext.Users.Add(srcUser); efContext.SaveChanges(); } using (var source = new EfDataContext <SourceDbContext>(new SourceDbContext(_srcConnection)) as IDataSource) { newUser = source.Entities <SourceUser>().Single(x => x.EmailAddress == srcUser.EmailAddress); } Assert.Multiple(() => { Assert.That(newUser.Id, Is.EqualTo(srcUser.Id)); Assert.That(newUser.EmailAddress, Is.EqualTo(srcUser.EmailAddress)); }); }
public void UserNotInDb_ReturnsEmpty() { bool exists; using (var source = new EfDataContext <SourceDbContext>(new SourceDbContext(_srcConnection)) as IDataSource) { exists = source.Entities <SourceUser>().Any(x => x.EmailAddress == "*****@*****.**"); } Assert.That(exists, Is.False); }