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_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 Get_SetDoesNotExist_ReturnsNull() { var setUnderTest = ModelsSetup.GetSetUnderTest(); InsertData(setUnderTest); var set = _setRepository.Get(setUnderTest.SetId + 1); Check.That(set).IsNull(); }
public void Get_SetExists_ReturnsModel() { var setUnderTest = ModelsSetup.GetSetUnderTest(); InsertData(setUnderTest); var set = _setRepository.Get(setUnderTest.SetId); Check.That(set.SetId).IsEqualTo(setUnderTest.SetId); }
public void AddOrUpdate_NewValidSet_InsertsModel() { var setUnderTest = ModelsSetup.GetSetUnderTest(); _setRepository.AddOrUpdate(setUnderTest); var set = _setRepository.Get(setUnderTest.SetId); Check.That(set).IsNotNull(); Check.That(set.SetId).IsEqualTo(setUnderTest.SetId); }
public void AllForTheme_SetForThemeDoesNotExist_ReturnsEmpty() { var set = ModelsSetup.GetSetUnderTest(); set.Theme = InsertData(ModelsSetup.GetThemeUnderTest(Guid.NewGuid().ToString())); InsertData(set); var allSetsForTheme = _setRepository.AllForTheme(ModelsSetup.NonExistentThemeName); Check.That(allSetsForTheme).IsEmpty(); }
public void SearchBy_SearchTermDoesNotExist_ReturnsEmpty() { var setUnderTest = ModelsSetup.GetSetUnderTest(); setUnderTest.Name = "SETUNDERTEST"; InsertData(setUnderTest); var searchResult = _setRepository.SearchBy($"{setUnderTest.Name}_NONEXISTANT"); Check.That(searchResult).IsEmpty(); }
public void AddOrUpdateSet_BricksetUserDoesNotExist_ReturnsNull() { var set = ModelsSetup.GetSetUnderTest(); InsertData(set); var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet("username", new BricksetUserSet { Set = new Set { SetId = set.SetId } }); Check.That(bricksetUserSet).IsNull(); }
public void AllForCategory_CategoryDoesNotExist_ReturnsEmpty() { var category = InsertData(ModelsSetup.CategoryReferenceData); var setUnderTest = ModelsSetup.GetSetUnderTest(); setUnderTest.Category = category; InsertData(setUnderTest); var allSetsForCategory = _setRepository.AllForCategory($"{ModelsSetup.CategoryReferenceDataValue}_NON-EXISTENT"); Check.That(allSetsForCategory).IsEmpty(); }
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 AddOrUpdate_ExistingValidSet_UpdatesModel() { var setUnderTest = ModelsSetup.GetSetUnderTest(); _setRepository.AddOrUpdate(setUnderTest); var setFromDb = _setRepository.Get(setUnderTest.SetId); setFromDb.Name = "NEW NAME"; _setRepository.AddOrUpdate(setFromDb); var set = _setRepository.Get(setUnderTest.SetId); Check.That(set).HasFieldsWithSameValues(setFromDb); }
public void AllForPriceRange_PriceDoesNotExist_ReturnsEmpty() { var set = ModelsSetup.GetSetUnderTest(); set.Prices.Add(new Price { Region = PriceRegion.CA, Value = 10 }); InsertData(set); var allSetsForPriceRange = _setRepository.AllForPriceRange(PriceRegion.CA, 0, 5); Check.That(allSetsForPriceRange).IsEmpty(); }
public void AllForPriceRange_InvalidPrice_ReturnsEmpty(float minPrice, float maxPrice) { var set = ModelsSetup.GetSetUnderTest(); set.Prices.Add(new Price { Region = PriceRegion.CA, Value = 1 }); InsertData(set); var allSetsForPriceRange = _setRepository.AllForPriceRange(PriceRegion.CA, minPrice, maxPrice); Check.That(allSetsForPriceRange).IsEmpty(); }
public void AllForPriceRange_PriceExists_ReturnsModel() { var set = ModelsSetup.GetSetUnderTest(); set.Prices.Add(new Price { Region = PriceRegion.CA, Value = 1 }); InsertData(set); var allSetsForPriceRange = _setRepository.AllForPriceRange(PriceRegion.CA, 0, 5); Check.That(allSetsForPriceRange).CountIs(1); Check.That(allSetsForPriceRange.First().SetId).IsEqualTo(set.SetId); }
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); }