Пример #1
0
        public void TestUpdateDisk()
        {
            using (var persistence = GetPersistence())
            {
                var user = persistence.CreateUser(_userDto.Login, _userDto.HashedPassword);

                var disk = persistence.CreateDisk(user, new DiskOptionsDto());
                disk.LocalVersion = 10;
                disk.LastServerVersion = 10;
                persistence.UpdateDisk(disk);

                var s = new DiskServiceImpl(persistence);

                disk.NewestBlock = 77;
                s.UpdateDisk(user, disk);
                Assert.AreEqual(77, s.Disks(user).First().NewestBlock);
            }
        }
Пример #2
0
        public void TestSynchronizationStateUpToDate()
        {
            using (var persistence = GetPersistence())
            {
                var user = persistence.CreateUser(_userDto.Login, _userDto.HashedPassword);
                persistence.CreateDisk(user, new DiskOptionsDto());

                var s = new DiskServiceImpl(persistence);

                var clonedDisk = s.Disks(user).First();
                Assert.AreEqual(SynchronizationState.UpToDate, s.FetchSynchronizationState(user, clonedDisk));
            }
        }
Пример #3
0
 public void TestDisks()
 {
     using (var persistence = GetPersistenceWithUser())
     {
         var disk = new DiskDto { UserId = _userDto.Id, Id = 1 };
         persistence.CreateDisk(_userDto, new DiskOptionsDto());
         var s = new DiskServiceImpl(persistence);
         Assert.AreEqual(1, s.Disks(_userDto).Count);
         Assert.AreEqual(disk.Id, s.Disks(_userDto).First().Id);
     }
 }
Пример #4
0
 public void TestDisksEmpty()
 {
     using (var persistence = GetPersistenceWithUser())
     {
         var s = new DiskServiceImpl(persistence);
         Assert.AreEqual(0, s.Disks(_userDto).Count);
     }
 }
Пример #5
0
 public void TestDeleteDisks()
 {
     using (var persistence = GetPersistence())
     {
         var user = persistence.CreateUser(_userDto.Login, _userDto.HashedPassword);
         var disk = persistence.CreateDisk(user, new DiskOptionsDto());
         var s = new DiskServiceImpl(persistence);
         Assert.IsTrue(s.DeleteDisk(user, disk));
         Assert.AreEqual(0, s.Disks(user).Count);
     }
 }