public void AddOrUpdateSet_BricksetUserSetExists_UpdatesAndReturnsModel() { var set = ModelsSetup.GetSetUnderTest(); var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); set = InsertData(set); InsertData(bricksetUser); var bricksetUserSetUnderTest = new BricksetUserSet { Set = set, Wanted = true }; _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, bricksetUserSetUnderTest); bricksetUserSetUnderTest.Wanted = false; bricksetUserSetUnderTest.Owned = true; bricksetUserSetUnderTest.QuantityOwned = 2; var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, bricksetUserSetUnderTest); Check.That(bricksetUserSet).HasFieldsWithSameValues(bricksetUserSetUnderTest); Check.That(bricksetUserSet.Wanted).IsFalse(); }
public void GetOwnedSets_BricksetUserExists_ReturnsListOfOwnedSets() { var wantedSet = ModelsSetup.GetSetUnderTest(); var ownedSet = ModelsSetup.GetSecondSetUnderTest(); var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); wantedSet = InsertData(wantedSet); ownedSet = InsertData(ownedSet); InsertData(bricksetUser); var bricksetUserSetWanted = new BricksetUserSet { Set = wantedSet, Wanted = true }; var bricksetUserSetOwned = new BricksetUserSet { Set = ownedSet, Owned = true }; _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, bricksetUserSetWanted); _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, bricksetUserSetOwned); var bricksetUserSetList = _bricksetUserRepository.GetOwnedSets(bricksetUser.BricksetUsername).ToList(); Check.That(bricksetUserSetList).CountIs(1); Check.That(bricksetUserSetList.Select(bricksetUserSet => bricksetUserSet.Set.SetId)).Contains(bricksetUserSetOwned.Set.SetId); }
public void AddOrUpdateSet_NullBricksetUserSet_ReturnsNull() { var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUser); var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, null); Check.That(bricksetUserSet).IsNull(); }
public void Get_BricksetUserExists_ReturnsModel() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); var bricksetUser = _bricksetUserRepository.Get(bricksetUserUnderTest.BricksetUsername); Check.That(bricksetUser.BricksetUsername).IsEqualTo(bricksetUserUnderTest.BricksetUsername); }
public void Exists_ValidUsernameAndExists_ReturnsTrue() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); var bricksetUserExists = _bricksetUserRepository.Exists(bricksetUserUnderTest.BricksetUsername); Check.That(bricksetUserExists).IsTrue(); }
public void Get_BricksetUserDoesNotExist_ReturnsNull() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); var bricksetUser = _bricksetUserRepository.Get("username"); Check.That(bricksetUser).IsNull(); }
public void UpdateUserSynchronizationTimestamp_BricksetUserDoesNotExist_ReturnsNull() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); var bricksetUser = _bricksetUserRepository.UpdateUserSynchronizationTimestamp(Guid.NewGuid().ToString(), DateTimeOffset.Now); Check.That(bricksetUser).IsNull(); }
public void GetAllUsernames_BricksetUserTypeDoesNotExist_ReturnsEmptyList() { var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUser); var usernameList = _bricksetUserRepository.GetAllUsernames(BricksetUserType.Friend); Check.That(usernameList).IsEmpty(); }
public void Remove_ValidUsernameAndDoesNotExist_ReturnsFalse() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); var removedUser = _bricksetUserRepository.Remove(Guid.NewGuid().ToString()); Check.That(removedUser).IsFalse(); }
public void GetSet_InvalidSetId_ReturnsNull() { var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUser); var bricksetUserSet = _bricksetUserRepository.GetSet(bricksetUser.BricksetUsername, 0); Check.That(bricksetUserSet).IsNull(); }
public void GetAllUsernames_BricksetUserTypeExists_ReturnsListOfUsernames() { var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUser); var usernameList = _bricksetUserRepository.GetAllUsernames(bricksetUser.UserType); Check.That(usernameList).Not.IsEmpty(); Check.That(usernameList.First()).IsEqualTo(bricksetUser.BricksetUsername); }
public void Remove_ValidUsernameAndExists_ReturnsTrueAndRemovesUser() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); string bricksetUsernameUnderTest = bricksetUserUnderTest.BricksetUsername; InsertData(bricksetUserUnderTest); var removedUser = _bricksetUserRepository.Remove(bricksetUsernameUnderTest); Check.That(removedUser).IsTrue(); Check.That(_bricksetUserRepository.Exists(bricksetUsernameUnderTest)).IsFalse(); }
public void Add_BricksetUserDoesNotExist_InsertsAndReturnsModel() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); const string newUsername = "******"; var bricksetUser = _bricksetUserRepository.Add(bricksetUserUnderTest.UserType, newUsername); Check.That(bricksetUser.BricksetUsername).IsEqualTo(newUsername); }
public void UpdateUserSynchronizationTimestamp_BricksetUserExists_UpdatesUserSynchronizationTimestampAndReturnsModel() { var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest(); InsertData(bricksetUserUnderTest); var synchronizationTimestamp = DateTimeOffset.Now.AddHours(-2); var bricksetUser = _bricksetUserRepository.UpdateUserSynchronizationTimestamp(bricksetUserUnderTest.BricksetUsername, synchronizationTimestamp); Check.That(bricksetUser).IsNotNull(); Check.That(bricksetUser.UserSynchronizationTimestamp).IsEqualTo(synchronizationTimestamp); }
public void AddOrUpdateSet_InvalidUsername_ReturnsNull(string username) { var set = ModelsSetup.GetSetUnderTest(); var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); InsertData(set); InsertData(bricksetUser); var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet(username, new BricksetUserSet { Set = new Set { SetId = set.SetId } }); Check.That(bricksetUserSet).IsNull(); }
public void AddOrUpdateSet_BricksetUserSetLinkedSetDoesNotExist_ReturnsNull() { var set = ModelsSetup.GetSetUnderTest(); var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); set = InsertData(set); InsertData(bricksetUser); var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, new BricksetUserSet { Set = new Set { SetId = set.SetId + 1 } }); Check.That(bricksetUserSet).IsNull(); }
public void GetSet_BricksetUserHasSetId_ReturnsModel() { var set = ModelsSetup.GetSetUnderTest(); var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); set = InsertData(set); InsertData(bricksetUser); var bricksetUserSetUnderTest = new BricksetUserSet { Set = set, Wanted = true }; _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, bricksetUserSetUnderTest); var bricksetUserSet = _bricksetUserRepository.GetSet(bricksetUser.BricksetUsername, bricksetUserSetUnderTest.Set.SetId); Check.That(bricksetUserSet.Set.SetId).IsEqualTo(bricksetUserSetUnderTest.Set.SetId); }
public void AddOrUpdateSet_BricksetUserSetDoesNotExist_InsertsAndReturnsModel() { var set = ModelsSetup.GetSetUnderTest(); var bricksetUser = ModelsSetup.GetBricksetUserUnderTest(); set = InsertData(set); InsertData(bricksetUser); var bricksetUserSetUnderTest = new BricksetUserSet { Set = set, Wanted = false, Owned = true, QuantityOwned = 10 }; var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, bricksetUserSetUnderTest); Check.That(bricksetUserSet).HasFieldsWithSameValues(bricksetUserSetUnderTest); }