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); }
public Repository(ICDbContext context) { this.dbContext = context; DbSet = dbContext.Set <T>(); }
public Repository() { this.dbContext = new ICDbContext(); DbSet = dbContext.Set <T>(); }