Ejemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
        public void CRUD_Test()
        {
            var repositoryContext = new RepositoryContext();

            Account testAccount = TestEntities.GetTestAccount(
                1,
                Guid.Parse("F341B4FB-4CC3-4FDB-B7CF-8DCD45365341"),
                "AccAddr");

            try
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                // create account
                repositoryContext.AccountRepository.Upsert(testAccount);

                // create
                AccountAddress expectedAccountAddress = TestEntities.GetTestAccountAddress(1, testAccount.AccountId);
                repositoryContext.AccountAddressRepository.Upsert(expectedAccountAddress);

                // read
                AccountAddress actualAccountAddress =
                    repositoryContext.AccountAddressRepository.Get(expectedAccountAddress.AccountId);
                Assert.NotNull(actualAccountAddress);
                Assert.True(EntityComparer.AreAccountAddressEqual(expectedAccountAddress, actualAccountAddress));

                // update
                AccountAddress expectedAccountAddressNew = TestEntities.GetTestAccountAddress(
                    2,
                    expectedAccountAddress.AccountId);

                repositoryContext.AccountAddressRepository.Upsert(expectedAccountAddressNew);
                Assert.AreEqual(expectedAccountAddress.AccountId, expectedAccountAddressNew.AccountId);

                AccountAddress actualAccountAddressNew =
                    repositoryContext.AccountAddressRepository.Get(expectedAccountAddressNew.AccountId);
                Assert.NotNull(actualAccountAddressNew);
                Assert.True(
                    EntityComparer.AreAccountAddressEqual(expectedAccountAddressNew, actualAccountAddressNew));

                // delete
                repositoryContext.AccountRepository.Delete(expectedAccountAddress.AccountId);

                // read by id
                actualAccountAddress =
                    repositoryContext.AccountAddressRepository.Get(expectedAccountAddress.AccountId);
                Assert.Null(actualAccountAddress);
            }
            finally
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                repositoryContext.Dispose();
            }
        }
Ejemplo n.º 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
 }
Ejemplo n.º 4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             context.Dispose();
         }
     }
     disposed = true;
 }
Ejemplo n.º 5
0
 public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             _db.Dispose();
         }
     }
     this.disposed = true;
 }
Ejemplo n.º 6
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (Context != null)
         {
             Context.Dispose();
             Context = null;
         }
     }
 }
Ejemplo n.º 7
0
            public void Dispose()
            {
                if (_userRepoContext != null)
                {
                    _userRepoContext.Dispose();
                }

                if (_orgRepoContext != null)
                {
                    _orgRepoContext.Dispose();
                }
            }
Ejemplo n.º 8
0
 public void Dispose()
 {
     RepositoryContext.Dispose();
 }
Ejemplo n.º 9
0
        public void CRUD_Test()
        {
            var repositoryContext = new RepositoryContext();

            Account expectedAccount = TestEntities.GetTestAccount(
                1,
                Guid.Parse("B2A4DF0B-B0B4-46E6-A308-6DFB79909CD3"),
                "AccOld");

            try
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, expectedAccount.AccountId);

                // create
                repositoryContext.AccountRepository.Upsert(expectedAccount);

                // read by id
                Account actualAccount = repositoryContext.AccountRepository.Get(expectedAccount.AccountId);
                Assert.IsNotNull(actualAccount);
                Assert.IsTrue(EntityComparer.AreAccountEqual(expectedAccount, actualAccount));

                if (expectedAccount.AccountGuid.HasValue)
                {
                    // read by guid
                    actualAccount = repositoryContext.AccountRepository.Get(expectedAccount.AccountGuid.Value);
                    Assert.IsNotNull(actualAccount);
                    Assert.IsTrue(EntityComparer.AreAccountEqual(expectedAccount, actualAccount));
                }

                int?actualAccountId;

                if (expectedAccount.AccountGuid.HasValue)
                {
                    // read id by guid
                    actualAccountId = repositoryContext.AccountRepository.GetId(expectedAccount.AccountGuid.Value);
                    Assert.AreEqual(expectedAccount.AccountId, actualAccountId);
                }

                // read id by account number
                actualAccountId = repositoryContext.AccountRepository.GetId(expectedAccount.AccountNumber);
                Assert.AreEqual(expectedAccount.AccountId, actualAccountId);

                // update
                Account expectedAccountNew =
                    TestEntities.GetTestAccount(2, expectedAccount.AccountGuid.Value, "AccNew");
                repositoryContext.AccountRepository.Upsert(expectedAccountNew);
                Assert.AreEqual(expectedAccount.AccountId, expectedAccountNew.AccountId);

                Account actualAccountNew = repositoryContext.AccountRepository.Get(expectedAccountNew.AccountId);
                Assert.IsNotNull(actualAccountNew);
                Assert.IsTrue(EntityComparer.AreAccountEqual(expectedAccountNew, actualAccountNew));

                // delete
                repositoryContext.AccountRepository.Delete(expectedAccount.AccountId);

                // read by id
                actualAccount = repositoryContext.AccountRepository.Get(expectedAccount.AccountId);
                Assert.IsNull(actualAccount);

                if (expectedAccount.AccountGuid.HasValue)
                {
                    // read by guid
                    actualAccount = repositoryContext.AccountRepository.Get(expectedAccount.AccountGuid.Value);
                    Assert.IsNull(actualAccount);

                    // read id by guid
                    actualAccountId = repositoryContext.AccountRepository.GetId(expectedAccount.AccountGuid.Value);
                    Assert.IsNull(actualAccountId);
                }

                // read id by account number
                actualAccountId = repositoryContext.AccountRepository.GetId(expectedAccount.AccountNumber);
                Assert.IsNull(actualAccountId);
            }
            finally
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, expectedAccount.AccountId);

                repositoryContext.Dispose();
            }
        }
Ejemplo n.º 10
0
        public void CRUD_Test()
        {
            var repositoryContext = new RepositoryContext();

            Account testAccount = TestEntities.GetTestAccount(
                1,
                Guid.Parse("579526DD-D75C-46E2-8A30-A1D3828F92A5"),
                "UserOld");

            try
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                // create account
                repositoryContext.AccountRepository.Upsert(testAccount);

                // create
                User expectedUser = TestEntities.GetTestUser(
                    1,
                    Guid.Parse("86641E45-CB9C-4CC3-93EB-E6D26FDC91BE"),
                    "User",
                    testAccount.AccountId);

                repositoryContext.UserRepository.Upsert(expectedUser);

                // read by id
                User actualUser = repositoryContext.UserRepository.Get(expectedUser.UserId);
                Assert.NotNull(actualUser);
                Assert.True(EntityComparer.AreUserEqual(expectedUser, actualUser));

                // read by guid
                if (expectedUser.UserGuid.HasValue)
                {
                    actualUser = repositoryContext.UserRepository.Get(expectedUser.UserGuid.Value);
                    Assert.NotNull(actualUser);
                    Assert.True(EntityComparer.AreUserEqual(expectedUser, actualUser));
                }

                // read by logon name
                actualUser = repositoryContext.UserRepository.Get(expectedUser.LogonName);
                Assert.NotNull(actualUser);
                Assert.True(EntityComparer.AreUserEqual(expectedUser, actualUser));

                int?actualUserId;

                // read id by guid
                if (expectedUser.UserGuid.HasValue)
                {
                    actualUserId = repositoryContext.UserRepository.GetId(expectedUser.UserGuid.Value);
                    Assert.Equal(expectedUser.UserId, actualUserId);
                }

                // read id by logon name
                actualUserId = repositoryContext.UserRepository.GetId(expectedUser.LogonName);
                Assert.Equal(expectedUser.UserId, actualUserId);

                // update
                User expectedUserNew = TestEntities.GetTestUser(
                    2,
                    expectedUser?.UserGuid.Value ?? null,
                    "UserNew",
                    expectedUser.AccountId);

                repositoryContext.UserRepository.Upsert(expectedUserNew);
                Assert.Equal(expectedUser.UserId, expectedUserNew.UserId);

                User actualUserNew = repositoryContext.UserRepository.Get(expectedUserNew.UserId);
                Assert.NotNull(actualUserNew);
                Assert.True(EntityComparer.AreUserEqual(expectedUserNew, actualUserNew));

                // delete
                repositoryContext.UserRepository.Delete(expectedUserNew.UserId);

                // read by id
                actualUser = repositoryContext.UserRepository.Get(expectedUserNew.UserId);
                Assert.Null(actualUser);

                if (expectedUserNew.UserGuid.HasValue)
                {
                    // read by guid
                    actualUser = repositoryContext.UserRepository.Get(expectedUserNew.UserGuid.Value);
                    Assert.Null(actualUser);
                }

                // read by logon name
                actualUser = repositoryContext.UserRepository.Get(expectedUser.LogonName);
                Assert.Null(actualUser);

                if (expectedUserNew.UserGuid.HasValue)
                {
                    // read id by guid
                    actualUserId = repositoryContext.UserRepository.GetId(expectedUserNew.UserGuid.Value);
                    Assert.Null(actualUserId);
                }

                // read id by logon name
                actualUserId = repositoryContext.UserRepository.GetId(expectedUserNew.LogonName);
                Assert.Null(actualUserId);

                // test by account

                // create users
                var expectedUsers = new List <User>
                {
                    TestEntities.GetTestUser(
                        1,
                        Guid.Parse("5B446BFB-7BCF-4A49-84EA-EB8D738F11DF"),
                        "User1",
                        testAccount.AccountId),

                    TestEntities.GetTestUser(
                        2,
                        Guid.Parse("EC15A8F5-941B-4C46-8EDA-83CD5B42E482"),
                        "User2",
                        testAccount.AccountId)
                };

                foreach (User user in expectedUsers)
                {
                    repositoryContext.UserRepository.Upsert(user);
                }

                // read by account
                List <User> actualUsers = repositoryContext.UserRepository.GetByAccount(testAccount.AccountId);
                Assert.Equal(expectedUsers.Count, actualUsers.Count);

                foreach (User user in expectedUsers)
                {
                    actualUser = actualUsers.Single(ar => ar.UserGuid == user.UserGuid);
                    Assert.True(EntityComparer.AreUserEqual(user, actualUser));
                }

                // delete by account
                repositoryContext.UserRepository.DeleteByAccount(testAccount.AccountId);

                // read by account
                actualUsers = repositoryContext.UserRepository.GetByAccount(testAccount.AccountId);
                Assert.Empty(actualUsers);
            }
            finally
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                repositoryContext.Dispose();
            }
        }
Ejemplo n.º 11
0
 public void Cleanup()
 {
     context.Dispose();
     context        = null;
     userRepository = null;
 }
Ejemplo n.º 12
0
        public void CRUD_Test()
        {
            var repositoryContext = new RepositoryContext();

            Account testAccount = TestEntities.GetTestAccount(
                1,
                Guid.Parse("DA8306F8-B255-4737-925C-AACCA7EB2B87"),
                "UserRole");

            try
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                // create account
                repositoryContext.AccountRepository.Upsert(testAccount);

                // create account roles
                AccountRole testAccountRole1 = TestEntities.GetTestAccountRole(
                    1,
                    Guid.Parse("FFDEA1D7-78BA-414C-8A7B-A3B09A50DDF2"),
                    testAccount.AccountId,
                    "UserRole1");

                repositoryContext.AccountRoleRepository.Upsert(testAccountRole1);

                AccountRole testAccountRole2 = TestEntities.GetTestAccountRole(
                    2,
                    Guid.Parse("B0775CA4-7339-4127-BDF3-440B85F71AC5"),
                    testAccount.AccountId,
                    "UserRole2");
                repositoryContext.AccountRoleRepository.Upsert(testAccountRole2);

                // create user
                User testUser = TestEntities.GetTestUser(
                    1,
                    Guid.Parse("EE837AA8-D3B8-47D4-B5DF-23E389BCFBA4"),
                    "UserRole",
                    testAccount.AccountId);
                repositoryContext.UserRepository.Upsert(testUser);

                // create
                UserRole expectedUserRole = TestEntities.GetTestUserRole(
                    testUser.UserId,
                    testAccountRole1.AccountRoleId);
                repositoryContext.UserRoleRepository.Add(expectedUserRole);

                // read
                UserRole actualUserRole = repositoryContext.UserRoleRepository.Get(
                    expectedUserRole.UserId,
                    expectedUserRole.AccountRoleId);
                Assert.NotNull(actualUserRole);
                Assert.True(EntityComparer.AreUserRoleEqual(expectedUserRole, actualUserRole));

                // delete
                repositoryContext.UserRoleRepository.Delete(expectedUserRole.UserId, expectedUserRole.AccountRoleId);

                // read
                actualUserRole = repositoryContext.UserRoleRepository.Get(
                    expectedUserRole.UserId,
                    expectedUserRole.AccountRoleId);
                Assert.Null(actualUserRole);

                // test by user

                // create user roles
                var expectedUserRoles = new List <UserRole>
                {
                    TestEntities.GetTestUserRole(testUser.UserId, testAccountRole1.AccountRoleId),
                    TestEntities.GetTestUserRole(testUser.UserId, testAccountRole2.AccountRoleId)
                };

                foreach (UserRole userRole in expectedUserRoles)
                {
                    repositoryContext.UserRoleRepository.Add(userRole);
                }

                // read by user
                List <UserRole> actualUserRoles = repositoryContext.UserRoleRepository.Get(testUser.UserId);
                Assert.AreEqual(expectedUserRoles.Count, actualUserRoles.Count);

                foreach (UserRole userRole in expectedUserRoles)
                {
                    actualUserRole =
                        actualUserRoles.Single(
                            ur => ur.UserId == userRole.UserId && ur.AccountRoleId == userRole.AccountRoleId);
                    Assert.True(EntityComparer.AreUserRoleEqual(userRole, actualUserRole));
                }

                // delete by user
                repositoryContext.UserRoleRepository.Delete(testUser.UserId);

                // read by user
                actualUserRoles = repositoryContext.UserRoleRepository.Get(testUser.UserId);
                Assert.IsEmpty(actualUserRoles);
            }
            finally
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                repositoryContext.Dispose();
            }
        }
 public void Dispose()
 {
     _db?.Dispose();
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Clear the object
 /// </summary>
 public void Dispose()
 {
     repositoryContext.Dispose();
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 15
0
 public void Dispose()
 {
     _context.Dispose();
 }
        public void CRUD_Test()
        {
            var repositoryContext = new RepositoryContext();

            Account testAccount = TestEntities.GetTestAccount(
                1,
                Guid.Parse("64651A7C-CB82-4F45-92CA-397AD8519D75"),
                "AccRole");

            try
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                // create account
                repositoryContext.AccountRepository.Upsert(testAccount);

                // create
                AccountRole expectedAccountRole = TestEntities.GetTestAccountRole(
                    1,
                    Guid.Parse("7B46F4DD-1E5E-47F9-ADBB-A37A60B1BAB2"),
                    testAccount.AccountId,
                    "AccRoleOld");
                repositoryContext.AccountRoleRepository.Upsert(expectedAccountRole);

                // read by id
                AccountRole actualAccountRole =
                    repositoryContext.AccountRoleRepository.Get(expectedAccountRole.AccountRoleId);
                Assert.NotNull(actualAccountRole);
                Assert.True(EntityComparer.AreAccountRoleEqual(expectedAccountRole, actualAccountRole));

                if (expectedAccountRole.AccountRoleGuid.HasValue)
                {
                    // read by guid
                    actualAccountRole =
                        repositoryContext.AccountRoleRepository.Get(expectedAccountRole.AccountRoleGuid.Value);
                    Assert.NotNull(actualAccountRole);
                    Assert.True(EntityComparer.AreAccountRoleEqual(expectedAccountRole, actualAccountRole));
                }

                int?actualAccountRoleId;

                if (expectedAccountRole.AccountRoleGuid.HasValue)
                {
                    // read id by guid
                    actualAccountRoleId =
                        repositoryContext.AccountRoleRepository.GetId(expectedAccountRole.AccountRoleGuid.Value);
                    Assert.AreEqual(expectedAccountRole.AccountRoleId, actualAccountRoleId);
                }

                // read id by account id and role name
                actualAccountRoleId = repositoryContext.AccountRoleRepository.GetId(
                    expectedAccountRole.AccountId,
                    expectedAccountRole.RoleName);
                Assert.AreEqual(expectedAccountRole.AccountRoleId, actualAccountRoleId);

                // update
                AccountRole expectedAccountRoleNew = TestEntities.GetTestAccountRole(
                    2,
                    expectedAccountRole?.AccountRoleGuid.Value ?? null,
                    expectedAccountRole.AccountId,
                    "AccRoleNew");

                expectedAccountRoleNew.AccountRoleGuid = expectedAccountRole.AccountRoleGuid;
                repositoryContext.AccountRoleRepository.Upsert(expectedAccountRoleNew);
                Assert.AreEqual(expectedAccountRole.AccountRoleId, expectedAccountRoleNew.AccountRoleId);

                AccountRole actualAccountRoleNew =
                    repositoryContext.AccountRoleRepository.Get(expectedAccountRoleNew.AccountRoleId);
                Assert.NotNull(actualAccountRoleNew);
                Assert.True(EntityComparer.AreAccountRoleEqual(expectedAccountRoleNew, actualAccountRoleNew));

                // delete
                repositoryContext.AccountRoleRepository.Delete(expectedAccountRoleNew.AccountRoleId);

                // read by id
                actualAccountRole = repositoryContext.AccountRoleRepository.Get(expectedAccountRoleNew.AccountRoleId);
                Assert.Null(actualAccountRole);

                if (expectedAccountRoleNew.AccountRoleGuid.HasValue)
                {
                    // read by guid
                    actualAccountRole =
                        repositoryContext.AccountRoleRepository.Get(expectedAccountRoleNew.AccountRoleGuid.Value);
                    Assert.Null(actualAccountRole);

                    // read id by guid
                    actualAccountRoleId =
                        repositoryContext.AccountRoleRepository.GetId(expectedAccountRoleNew.AccountRoleGuid.Value);
                    Assert.Null(actualAccountRoleId);
                }

                // read id by account id and role number
                actualAccountRoleId = repositoryContext.AccountRoleRepository.GetId(
                    expectedAccountRoleNew.AccountId,
                    expectedAccountRoleNew.RoleName);
                Assert.Null(actualAccountRoleId);

                // test by account

                // create account roles
                var expectedAccountRoles = new List <AccountRole>
                {
                    TestEntities.GetTestAccountRole(
                        1,
                        Guid.Parse("AF8F597E-82A3-4184-932D-6AA31DA4E6F2"),
                        testAccount.AccountId,
                        "AccRole1")
                };

                foreach (AccountRole accountRole in expectedAccountRoles)
                {
                    repositoryContext.AccountRoleRepository.Upsert(accountRole);
                }

                // read by account
                var actualAccountRoles = new List <AccountRole>
                {
                    repositoryContext.AccountRoleRepository.GetByAccount(testAccount.AccountId)
                };
                Assert.AreEqual(expectedAccountRoles.Count, actualAccountRoles.Count);

                foreach (AccountRole accountRole in expectedAccountRoles)
                {
                    actualAccountRole =
                        actualAccountRoles.Single(ar => ar.AccountRoleGuid == accountRole.AccountRoleGuid);
                    Assert.True(EntityComparer.AreAccountRoleEqual(accountRole, actualAccountRole));
                }

                // delete by account
                repositoryContext.AccountRoleRepository.DeleteByAccount(testAccount.AccountId);

                // read by account
                actualAccountRoles = new List <AccountRole>
                {
                    repositoryContext.AccountRoleRepository.GetByAccount(testAccount.AccountId)
                };
                Assert.IsEmpty(actualAccountRoles);
            }
            finally
            {
                // delete test account
                TestDataCleaner.DeleteTestAccount(repositoryContext, testAccount.AccountId);

                repositoryContext.Dispose();
            }
        }
Ejemplo n.º 17
0
 void IDisposable.Dispose()
 {
     TestDataContext.Dispose();
     Client.Dispose();
     Server.Dispose();
 }
Ejemplo n.º 18
0
 public void Dispose()
 {
     _context.Database.EnsureDeleted();
     _context.Dispose();
 }
Ejemplo n.º 19
0
 public void Dispose(bool disposing)
 {
     _db.Dispose();
 }
Ejemplo n.º 20
0
 public void Cleanup()
 {
     context.Dispose();
     context           = null;
     paymentRepository = null;
 }
Ejemplo n.º 21
0
 public void Rollback()
 {
     _repoContext.Dispose();
 }