public async Task <bool> AddDefaultUser() { if (await _secureStorageService.IsDefaultUsernameDefined().ConfigureAwait(false)) { return(false); } var defaultUsername = Convert.ToBase64String(SHA256Hash.ComputeHash(Guid.NewGuid().ToString())); await _secureStorageService.SaveDefaultUsername(defaultUsername).ConfigureAwait(false); _bricksetUserRepository.Add(BricksetUserType.None, defaultUsername); return(true); }
public async Task SynchronizeBricksetPrimaryUser_UserSynchronizationTimestampNotSetAndDoesNotHaveRemoteSets_DoesNotUpdateLocalSetsAndUpdatesUserSynchronizationTimestamp() { const string testUser = "******"; _bricksetUserRepository.Add(BricksetUserType.Primary, testUser); var bricksetApiService = Substitute.For <IBricksetApiService>(); bricksetApiService .GetSets(Arg.Is <GetSetsParameters>(parameter => parameter.Owned.Value)) .Returns(new List <Sets>()); bricksetApiService .GetSets(Arg.Is <GetSetsParameters>(parameter => parameter.Wanted.Value)) .Returns(new List <Sets>()); var userSynchronizer = CreateTarget(bricksetApiService); await userSynchronizer.SynchronizeBricksetPrimaryUser(string.Empty, testUser, string.Empty).ConfigureAwait(false); var user = _bricksetUserRepository.Get(testUser); Check.That(user.Sets).IsEmpty(); Check.That(user.UserSynchronizationTimestamp).HasAValue(); }
public void Add_InvalidUsername_ReturnsNull(string username) { var bricksetUser = _bricksetUserRepository.Add(BricksetUserType.None, username); Check.That(bricksetUser).IsNull(); }