コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public void Get_SetDoesNotExist_ReturnsNull()
        {
            var setUnderTest = ModelsSetup.GetSetUnderTest();

            InsertData(setUnderTest);

            var set = _setRepository.Get(setUnderTest.SetId + 1);

            Check.That(set).IsNull();
        }
コード例 #4
0
        public void Get_SetExists_ReturnsModel()
        {
            var setUnderTest = ModelsSetup.GetSetUnderTest();

            InsertData(setUnderTest);

            var set = _setRepository.Get(setUnderTest.SetId);

            Check.That(set.SetId).IsEqualTo(setUnderTest.SetId);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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();
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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();
        }
コード例 #13
0
        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();
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }