コード例 #1
0
        public void TestInitialize()
        {
            ICDbContext context = new ICDbContext(connectionString);

            context.Set <User>().AddOrUpdate(testUsers.ToArray());
            context.SaveChanges();
            userRepo = new UserRepository(context);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: Repository.cs プロジェクト: kvpz/Ideally-Connected
 /*
  *  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();
 }