public void TestAuthenticationOnLogin() { using (var s = new DiskServiceImpl(GetPersistence())) { s.Login("nananana", "blub"); } }
public void TestWriteFail() { using (var s = new DiskServiceImpl(GetPersistenceWithData())) { s.WriteBlock(new UserDto { Login = "******", HashedPassword = "******" }, _disk.Id, 33, new byte[33]); } }
public void TestReadFail() { using (var s = new DiskServiceImpl(GetPersistenceWithData())) { s.ReadBlock(new UserDto { Login = "******", HashedPassword = "******" }, _disk.Id, 33); } }
public void TestAuthenticationOnCreateDisk() { using (var s = new DiskServiceImpl(GetPersistence())) { s.Login("nananana", "blub"); var disk = s.CreateDisk(new UserDto { Login = "******", HashedPassword = "******" }, new DiskOptionsDto { BlockSize = 1000, MasterBlockSize = 1000, SerializedFileSystemOptions = new byte[10] }); } }
public void TestCreateDiskBad() { using (var persistence = GetPersistence()) { var s = new DiskServiceImpl(persistence); var disk = s.CreateDisk(new UserDto { Login = "******", HashedPassword = "******" }, null); Assert.IsNull(disk); } }
public void TestWriteRead() { using (var s = new DiskServiceImpl(GetPersistenceWithData())) { var expected = new byte[100]; new Random(1).NextBytes(expected); s.WriteBlock(_userDto, _disk.Id, 33, expected); var actual = s.ReadBlock(_userDto, _disk.Id, 33); for (var i = 0; i < expected.Length; i++) Assert.AreEqual(expected[i], actual[i]); } }
public void TestCreateDiskSuccess() { using (var persistence = GetPersistenceWithUser()) { var user = persistence.CreateUser(_userDto.Login, _userDto.HashedPassword); var s = new DiskServiceImpl(persistence); var disk = s.CreateDisk(user, new DiskOptionsDto()); Assert.AreEqual(user.Id, disk.UserId); Assert.AreEqual(1, persistence.Disks(user).Count); Assert.AreEqual(user.Id, persistence.Disks(user).First().UserId); Assert.AreEqual(user.Id, disk.UserId); Assert.AreEqual(1, disk.UserId); } }
public void TestRegistrationFail() { using (var persistence = GetPersistence()) { var u = persistence.CreateUser("bla", "blub"); var s = new DiskServiceImpl(persistence); s.Register(u.Login, "blub"); } }
public void TestLogin() { using (var persistence = GetPersistence()) { persistence.CreateUser("bla", "blub"); var s = new DiskServiceImpl(persistence); var user = s.Login("bla", "blub"); Assert.AreEqual("bla", user.Login); Assert.AreEqual("blub", user.HashedPassword); } }
public void TestDisksEmpty() { using (var persistence = GetPersistenceWithUser()) { var s = new DiskServiceImpl(persistence); Assert.AreEqual(0, s.Disks(_userDto).Count); } }
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); } }
public void TestLoginFail() { using (var persistence = GetPersistence()) { persistence.CreateUser("bla", "test"); var s = new DiskServiceImpl(persistence); s.Login("bla", "blub"); } }
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)); } }
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); } }
public void TestReadWriteOptions() { 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); var b = new byte[] { 1, 2, 3 }; s.SetDiskOptions(user, disk, new DiskOptionsDto { SerializedFileSystemOptions = b }); var actual = s.GetDiskOptions(user, disk); Assert.AreEqual(b.Length, actual.SerializedFileSystemOptions.Length); Assert.AreEqual(1, actual.SerializedFileSystemOptions[0]); Assert.AreEqual(2, actual.SerializedFileSystemOptions[1]); Assert.AreEqual(3, actual.SerializedFileSystemOptions[2]); } }
public void TestRegistration() { using (var persistence = GetPersistence()) { var s = new DiskServiceImpl(persistence); var user = s.Register("bla", "blub"); Assert.AreEqual("bla", user.Login); Assert.AreEqual("blub", user.HashedPassword); Assert.IsFalse(persistence.LoginFree("bla")); } }
public void TestRegisterAndLogin() { using (var persistence = GetPersistence()) { var s = new DiskServiceImpl(persistence); s.Register(_userDto.Login, _userDto.HashedPassword); var user = s.Login(_userDto.Login, _userDto.HashedPassword); Assert.IsNotNull(user); } }
public void TestSynchronizationStateRemoteChanges() { 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); var clonedDisk = new DiskDto { LastServerVersion = 9, LocalVersion = 9, UserId = user.Id, Id = disk.Id }; Assert.AreEqual(SynchronizationState.RemoteChanges, s.FetchSynchronizationState(user, clonedDisk)); } }
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); } }