public void CanAddNewUserToRepository()
 {
     using (var repo = new DBRepository(GetDBContext()))
     {
         repo.CreateUser(new User
         {
             CreateDate = DateTime.Now,
             Email = "*****@*****.**",
             Info = "This is good user",
             IsApproved = true,
             Login = "******",
             Role = Roles.Admin,
             UserId = Guid.NewGuid(),
             PasswordHash = "df",
             PasswordSalt = "dfdf"
         });
         repo.SaveChanges();
     }
     using (var repo = new DBRepository(GetDBContext()))
     {
         try
         {
             var user = repo.Users.FirstOrDefault(x => x.Login == "alkor");
             Assert.IsNotNull(user);
             Assert.IsTrue(user.IsApproved);
             Assert.AreEqual(user.Email, "*****@*****.**");
         }
         catch
         {
             Assert.Fail();
         }
     }
 }
        public void CanCreatePresentationFromRepositoryAndHaveAccessFromUser()
        {
            using (var repo = new DBRepository(GetDBContext()))
            {
                if (repo.Users != null)
                {
                    var user = repo.Users.ToArray()[0];
                    repo.CreatePresentation(new Presentation { CreateDate = DateTime.Now, Description = "Simple Presentation", Name = "Presentation", User = user, PresentationId = Guid.NewGuid() });
                    repo.SaveChanges();

                    Presentation presentation = repo.Presentations.FirstOrDefault(x => x.Name == "Presentation");

                    Assert.IsNotNull(presentation);
                    Assert.AreEqual(presentation.User.UserId, user.UserId);
                    Assert.AreEqual(presentation.Description, "Simple Presentation");
                }
                else
                {
                    Assert.Fail("No Users in Repository");
                }
            }
        }
        public void CanDeleteUserFromRepository()
        {
            using (var repo = new DBRepository(GetDBContext()))
            {
                if (repo.Users != null)
                {
                    User user = repo.Users.ToArray()[0];
                    repo.DeleteUser(user);
                    repo.SaveChanges();

                    User testUser = repo.Users.FirstOrDefault(x => x.UserId == user.UserId);
                    Assert.IsNull(testUser);
                }
                else
                {
                    Assert.Fail("No Users in Repository");
                }
            }
        }
        public void CanUpdateUserFromRepository()
        {
            using (var repo = new DBRepository(GetDBContext()))
            {
                if (repo.Users != null)
                {
                    User updateUser = repo.Users.ToArray()[0];
                    updateUser.Info = "someInfo";
                    updateUser.Login = "******";
                    updateUser.Email = "no email";

                    repo.UpdateUser(updateUser);
                    repo.SaveChanges();

                    User testUser = repo.Users.FirstOrDefault(x => x.UserId == updateUser.UserId);
                    if (testUser != null)
                    {
                        Assert.AreEqual(testUser.Login, updateUser.Login);
                        Assert.AreEqual(testUser.Email, updateUser.Email);
                        Assert.AreEqual(testUser.Info, updateUser.Info);
                    }
                }

            }
        }