public void TestInitialize() { ICDbContext context = new ICDbContext(connectionString); context.Set <User>().AddOrUpdate(testUsers.ToArray()); context.SaveChanges(); userRepo = new UserRepository(context); }
public static void TestInitialize(TestContext testContext) { ICDbContext context = new ICDbContext(connectionString); context.Set <User>().AddOrUpdate(t => new { t.UserName }, testUsers.ToArray()); context.SaveChanges(); repo = new Repository <User>(context); }
public void Should_Return_Users_When_Searching_By_First_And_Last_Name(string firstName, string lastName) { ICDbContext context = new ICDbContext(connectionString); context.Set <User>().AddOrUpdate(testUsers.ToArray()); context.SaveChanges(); userRepo = new UserRepository(context); List <User> result = userRepo.GetByFirstAndLastName(firstName, lastName).ToList(); foreach (User user in result) { Xunit.Assert.True(user.FirstName == firstName && user.LastName == lastName, "Did not find the correct users by first and last name."); } userRepo.Dispose(); Database.Delete(connectionString); }
/* * Exceptions: * - DbUpdateConcurrencyException is thrown when an optimistic concurrency is detected while attempting to * save an entity that uses foreign key associations. */ public void SaveChanges() { dbContext.SaveChanges(); }