public void CanReadUser()
 {
     using (var scope = new IntegrationTestScope(this))
     {
         var user = this.UnitOfWork.UsersDBSet.Where(x => x.ApplicationUser != null).Include(x => x.ApplicationUser).First();
         Assert.True(user.ApplicationUser != null);
     }
 }
 public void CanReadAccount()
 {
     using (var scope = new IntegrationTestScope(this))
     {
         var accounts = this.UnitOfWork.TenantsDBSet.ToList();
         Assert.True(accounts.Count() > 0);
     }
 }
 public void CanUpdateUser()
 {
     using (var scope = new IntegrationTestScope(this))
     {
         var user = this.UnitOfWork.UsersDBSet.Where(x => x.ApplicationUser != null).Include(x => x.ApplicationUser).First();
         user.ApplicationUser.Email = "*****@*****.**";
         UnitOfWork.SaveChanges();
         Assert.True(UnitOfWork.UsersDBSet.Any(x => x.ApplicationUser.Email == "*****@*****.**"));
     }
 }
 public void CanDeleteUser()
 {
     using (var scope = new IntegrationTestScope(this))
     {
         var numberOfUsers = this.UnitOfWork.UsersDBSet.Count();
         var user          = this.UnitOfWork.UsersDBSet.First();
         this.UnitOfWork.UsersDBSet.Remove(user);
         this.UnitOfWork.SaveChanges();
         Assert.True(UnitOfWork.UsersDBSet.Count() == (numberOfUsers - 1));
     }
 }
 public void CanDeleteAccount()
 {
     using (var scope = new IntegrationTestScope(this))
     {
         var numberOfUsers = this.UnitOfWork.UsersDBSet.Count();
         var testTenant1 = this.UnitOfWork.TenantsDBSet.Single(x => x.Name == "TestTenant1");
         this.UnitOfWork.TenantsDBSet.Remove(testTenant1);
         this.UnitOfWork.SaveChanges();
         Assert.True(this.UnitOfWork.TenantsDBSet.SingleOrDefault(x => x.Name == "TestTenant1") == null);
         Assert.True(this.UnitOfWork.UsersDBSet.Count() < numberOfUsers);
     }
 }
 public void CanUpdateAccount()
 {
     string newName = "CanUpdateAccount_Account";
     using (var scope = new IntegrationTestScope(this))
     {
         var account = this.UnitOfWork.TenantsDBSet.Where(x => x.Users.Count() == 0).First();
         account.Name = newName;
         account.Users.Add(this.UnitOfWork.UsersDBSet.First());
         this.UnitOfWork.SaveChanges();
         Assert.True(this.UnitOfWork.TenantsDBSet.Where(x => x.Name == newName).Single().Users.Count() == 1);
     }
 }
        public void CanCreateNewAccount()
        {
            using (var scope = new IntegrationTestScope(this))
            {
                int numberOfAccounts = this.UnitOfWork.TenantsDBSet.Count();
                this.UnitOfWork.TenantsDBSet.Add(new Core.DomainModels.Tenants.Tenant()
                {
                    CreatedDate = DateTime.Now,
                    Name = "MyTestAccount"
                });

                this.UnitOfWork.SaveChanges();
                Assert.True(this.UnitOfWork.TenantsDBSet.Count() == (numberOfAccounts + 1));
            }
        }
        public void CanCreateNewUser()
        {
            using (var scope = new IntegrationTestScope(this))
            {
                int numberOfUsers   = this.UnitOfWork.UsersDBSet.Count();
                var emptyTenant     = this.UnitOfWork.TenantsDBSet.Single(x => x.Name == this.EmptyTenantName);
                var applicationUser = new ApplicationUser
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true
                };

                this.UserManager.CreateAsync(applicationUser, "Test#123").Wait();
                this.UnitOfWork.UsersDBSet.Add(new Core.DomainModels.Users.User(applicationUser, emptyTenant));
                this.UnitOfWork.SaveChanges();
                Assert.True(this.UnitOfWork.UsersDBSet.Count() == (numberOfUsers + 1));
            }
        }