Exemplo n.º 1
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();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void AddOrUpdateSet_NullBricksetUserSet_ReturnsNull()
        {
            var bricksetUser = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUser);

            var bricksetUserSet = _bricksetUserRepository.AddOrUpdateSet(bricksetUser.BricksetUsername, null);

            Check.That(bricksetUserSet).IsNull();
        }
Exemplo n.º 4
0
        public void Get_BricksetUserExists_ReturnsModel()
        {
            var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUserUnderTest);

            var bricksetUser = _bricksetUserRepository.Get(bricksetUserUnderTest.BricksetUsername);

            Check.That(bricksetUser.BricksetUsername).IsEqualTo(bricksetUserUnderTest.BricksetUsername);
        }
Exemplo n.º 5
0
        public void Exists_ValidUsernameAndExists_ReturnsTrue()
        {
            var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUserUnderTest);

            var bricksetUserExists = _bricksetUserRepository.Exists(bricksetUserUnderTest.BricksetUsername);

            Check.That(bricksetUserExists).IsTrue();
        }
Exemplo n.º 6
0
        public void Get_BricksetUserDoesNotExist_ReturnsNull()
        {
            var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUserUnderTest);

            var bricksetUser = _bricksetUserRepository.Get("username");

            Check.That(bricksetUser).IsNull();
        }
Exemplo n.º 7
0
        public void UpdateUserSynchronizationTimestamp_BricksetUserDoesNotExist_ReturnsNull()
        {
            var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUserUnderTest);

            var bricksetUser = _bricksetUserRepository.UpdateUserSynchronizationTimestamp(Guid.NewGuid().ToString(), DateTimeOffset.Now);

            Check.That(bricksetUser).IsNull();
        }
Exemplo n.º 8
0
        public void GetAllUsernames_BricksetUserTypeDoesNotExist_ReturnsEmptyList()
        {
            var bricksetUser = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUser);

            var usernameList = _bricksetUserRepository.GetAllUsernames(BricksetUserType.Friend);

            Check.That(usernameList).IsEmpty();
        }
Exemplo n.º 9
0
        public void Remove_ValidUsernameAndDoesNotExist_ReturnsFalse()
        {
            var bricksetUserUnderTest = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUserUnderTest);

            var removedUser = _bricksetUserRepository.Remove(Guid.NewGuid().ToString());

            Check.That(removedUser).IsFalse();
        }
Exemplo n.º 10
0
        public void GetSet_InvalidSetId_ReturnsNull()
        {
            var bricksetUser = ModelsSetup.GetBricksetUserUnderTest();

            InsertData(bricksetUser);

            var bricksetUserSet = _bricksetUserRepository.GetSet(bricksetUser.BricksetUsername, 0);

            Check.That(bricksetUserSet).IsNull();
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }