// [TestMethod]
        public void GetUsers_RunAddUser_AndResultListUser()
        {
            // Assign
            string login    = "******";
            string name     = "Name";
            string surName  = "SurName";
            string password = "******";
            //HiveDatabaseService databaseService = new HiveDatabaseService(connectionString);
            AddUserOperations addOperations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            sut.DoUserOperations(addOperations).Wait();

            // Act
            List <User> users = sut.GetUsers().Result.ToList();

            // Assert
            //Assert.IsTrue(resultAdd);
            Assert.IsTrue(users.Count > 0);
            User user = users.Where(a => a.Key == addOperations.KeyUser).SingleOrDefault();

            Assert.IsNotNull(user);
            Assert.AreEqual(login, user.Login);
            Assert.AreEqual(name, user.Name);
            Assert.AreEqual(surName, user.SurName);
            Assert.AreEqual(addOperations.Key, user.LongKey);
            Assert.AreEqual(password, user.Password);
            Assert.IsFalse(user.IsDeleted);
        }
        // [TestMethod]
        public void GetUser_RunAddUser_AndResultUser()
        {
            //Assign
            string login    = "******";
            string name     = "Name";
            string surName  = "SurName";
            string password = "******";
            // HiveDatabaseService databaseService = new  HiveDatabaseService(connectionString);
            AddUserOperations addOperations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            sut.DoUserOperations(addOperations).Wait();;


            //Act
            User user = sut.GetUser(addOperations.KeyUser).Result;

            //Assert

            Assert.AreEqual(login, user.Login);
            Assert.AreEqual(name, user.Name);
            Assert.AreEqual(surName, user.SurName);
            Assert.AreEqual(addOperations.Key, user.LongKey);
            Assert.AreEqual(password, user.Password);
            Assert.IsFalse(user.IsDeleted);
        }
        // [TestMethod]
        public void AddFile_RunAddUserAndAddFile_AndResultNewKey()
        {
            //Assign



            string login    = "******";
            string name     = "Name";
            string surName  = "SurName";
            string password = "******";

            AddUserOperations addUserOperations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            //HiveDatabaseService databaseService = new  HiveDatabaseService(connectionString);
            sut.DoUserOperations(addUserOperations).Wait();;
            User user = sut.GetUser(addUserOperations.KeyUser).Result;


            string fileName  = "filename";
            string extension = "extension";
            ResultService <AddFileOperations> addFileOperations = AddFileOperations
                                                                  .CreateFileOperations(user, fileName, extension)
                                                                  .OnError(a => throw new Exception(a));

            //Act
            //sut.DoFileOperations(addFileOperations).Wait();;
            addFileOperations.OnSuccess(a => sut.DoFileOperations(a).Wait());


            //Assert
            Assert.IsNotNull(user);
        }
        // [TestMethod]
        public void CloneFile_RunAddUserAndAddFileAndCloneFile_AndResultDeleteFile()
        {
            string login    = "******";
            string name     = "Name";
            string surName  = "SurName";
            string password = "******";

            AddUserOperations addUserOperations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            //HiveDatabaseService databaseService = new  HiveDatabaseService(connectionString);
            sut.DoUserOperations(addUserOperations).Wait();;
            User user = sut.GetUser(addUserOperations.KeyUser).Result;


            AddUserOperations addUserOperationsOther = AddUserOperations.CreateUserOperations(login, password, name, surName);

            sut.DoUserOperations(addUserOperationsOther).Wait();;
            User userOther = sut.GetUser(addUserOperationsOther.KeyUser).Result;


            string            fileName          = "filename";
            string            extension         = "extension";
            AddFileOperations addFileOperations = AddFileOperations.CreateFileOperations(user, fileName, extension).OnError(a => throw new Exception(a)).Value;;

            sut.DoFileOperations(addFileOperations).Wait();

            File file = sut.GetFile(addFileOperations.KeyUserFile).Result;

            CloneFileOperations cloneFileOperations = CloneFileOperations.CreateFileOperations(file, userOther).OnError(a => throw new Exception(a)).Value;;


            //Act
            sut.DoFileOperations(cloneFileOperations).Wait();

            // Assert
            File fileRead = sut.GetFile(cloneFileOperations.KeyUserFile).Result;


            Assert.AreEqual(fileName, fileRead.FileName);
            Assert.AreEqual(extension, fileRead.Extension);

            Assert.AreEqual(cloneFileOperations.KeyUser, fileRead.KeyUser);
            Assert.AreEqual(cloneFileOperations.KeyUserFile, fileRead.Key);
            Assert.AreEqual(cloneFileOperations.Key, fileRead.LongKey);
            Assert.AreEqual(cloneFileOperations.OperationDate.ToString("yyyy-MM-dd HH:mm:ss"), file.LastOperationDate.ToString("yyyy-MM-dd HH:mm:ss"));
            Assert.IsFalse(fileRead.IsDeleted);
            Assert.IsTrue(fileRead.IsCloned);
            Assert.AreEqual(addFileOperations.Key, fileRead.Parent);
        }
        public void GetFileUser_RunAddUserAndAddFile_AndResultListFile()
        {
            //Assign



            string login    = "******";
            string name     = "Name";
            string surName  = "SurName";
            string password = "******";

            AddUserOperations addUserOperations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            //HiveDatabaseService databaseService = new  HiveDatabaseService(connectionString);
            sut.DoUserOperations(addUserOperations).Wait();;
            User user = sut.GetUser(addUserOperations.KeyUser).Result;


            string            fileName          = "filename";
            string            extension         = "extension";
            AddFileOperations addFileOperations = AddFileOperations.CreateFileOperations(user, fileName, extension).OnError(a => throw new Exception(a)).Value;;

            //Act
            sut.DoFileOperations(addFileOperations).Wait();;

            //Assert
            IEnumerable <File> files = sut.GetUserFile(addFileOperations.KeyUser).Result;



            //Assert
            Assert.IsNotNull(user);
            Assert.IsNotNull(files);
            File file = files.SingleOrDefault();

            Assert.IsNotNull(file);
            Assert.AreEqual(fileName, file.FileName);
            Assert.AreEqual(extension, file.Extension);
            Assert.AreEqual(addFileOperations.KeyUser, file.KeyUser);
            Assert.AreEqual(addFileOperations.KeyUserFile, file.Key);
            Assert.AreEqual(addFileOperations.Key, file.LongKey);
            Assert.AreEqual(addFileOperations.OperationDate.ToString("yyyy-MM-dd HH:mm:ss"), file.LastOperationDate.ToString("yyyy-MM-dd HH:mm:ss"));
            Assert.IsFalse(file.IsDeleted);
            Assert.IsFalse(file.IsCloned);
        }
        // [TestMethod]
        public void AddUser_RunAddUser_AndResultNewKey()
        {
            //Assign



            string            login      = "******";
            string            name       = "Name";
            string            surName    = "SurName";
            string            password   = "******";
            AddUserOperations operations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            //HiveDatabaseService databaseService = new HiveDatabaseService(connectionString);

            //Act
            sut.DoUserOperations(operations).Wait();;

            //Assert
            //Assert.IsTrue(result);
        }
        // [TestMethod]
        public void ChangeUser_RunAddUserAndChangeUser_AndResultChangedUser()
        {
            //Assert
            string login    = "******";
            string name     = "Name";
            string surName  = "SurName";
            string password = "******";
            //HiveDatabaseService databaseService = new  HiveDatabaseService(connectionString);
            AddUserOperations addOperations = AddUserOperations.CreateUserOperations(login, password, name, surName);

            sut.DoUserOperations(addOperations).Wait();;
            User user = sut.GetUser(addOperations.KeyUser).Result;


            string newLogin    = "******";
            string newPassword = "******";
            string newName     = "Name2";
            string newSurName  = "SurName2";

            ChangeUserOperations changeOperations = ChangeUserOperations.CreateUserOperations(user)
                                                    .ChangeName(newName)
                                                    .ChangeLogin(newLogin)
                                                    .ChangePassword(newPassword)
                                                    .ChangeSurName(newSurName);

            //Act
            sut.DoUserOperations(changeOperations).Wait();;

            //Assert
            User userRead = sut.GetUser(addOperations.KeyUser).Result;

            Assert.AreEqual(newLogin, userRead.Login);
            Assert.AreEqual(newName, userRead.Name);
            Assert.AreEqual(newSurName, userRead.SurName);
            Assert.AreEqual(changeOperations.Key, userRead.LongKey);
            Assert.AreEqual(password, user.Password);
            Assert.IsFalse(user.IsDeleted);
        }