Beispiel #1
0
        public void PendingUserUpdateDeletionDate()
        {
            var r = new Restrictions();

            var pending = new PendingUser
            {
                Id           = 1,
                DeletionDate = DateTime.Now
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            updates[pending] = new Restrictions.ShadowModifiedMember[]
            {
                new Restrictions.ShadowModifiedMember
                {
                    Member        = typeof(PendingUser).GetProperty("DeletionDate"),
                    CurrentValue  = pending.DeletionDate,
                    OriginalValue = null
                }
            };

            string ignored;

            Assert.IsTrue(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                pending
            }, new List <int>(), out ignored));
        }
Beispiel #2
0
        public void UpdateUsersInList()
        {
            var r = new Restrictions();

            var user = new User
            {
                Id           = 1,
                CreationDate = DateTime.UtcNow
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            updates[user] = new Restrictions.ShadowModifiedMember[]
            {
                new Restrictions.ShadowModifiedMember
                {
                    Member        = typeof(User).GetProperty("CreationDate"),
                    CurrentValue  = user.CreationDate,
                    OriginalValue = null
                }
            };

            string ignored;

            Assert.IsTrue(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                user
            }, new List <int>()
            {
                1
            }, out ignored), ignored);
        }
Beispiel #3
0
        public void UserAttributeUpdateWithUserId()
        {
            var r = new Restrictions();

            var attr = new UserAttribute
            {
                UserId = 1
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            updates[attr] = new Restrictions.ShadowModifiedMember[]
            {
                new Restrictions.ShadowModifiedMember
                {
                    Member        = typeof(UserAttribute).GetProperty("UserId"),
                    CurrentValue  = attr.Id,
                    OriginalValue = 2
                }
            };

            string ignored;

            Assert.IsTrue(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                attr
            }, new List <int>()
            {
                1
            }, out ignored));
        }
Beispiel #4
0
        public void NoPendingUserUpdateOnNonDeletionDate()
        {
            var r = new Restrictions();

            var pending = new PendingUser
            {
                Id = 1
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            updates[pending] = new Restrictions.ShadowModifiedMember[]
            {
                new Restrictions.ShadowModifiedMember
                {
                    Member        = typeof(PendingUser).GetProperty("Id"),
                    CurrentValue  = pending.Id,
                    OriginalValue = 2
                }
            };

            string ignored;

            Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                pending
            }, new List <int>(), out ignored));
            Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                pending
            }, new List <int>()
            {
                1
            }, out ignored));
        }
Beispiel #5
0
        public void NoUserHistoryUpdates()
        {
            var r = new Restrictions();

            var history = new UserHistory
            {
                Id = 1
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            updates[history] = new Restrictions.ShadowModifiedMember[]
            {
                new Restrictions.ShadowModifiedMember
                {
                    Member        = typeof(UserHistory).GetProperty("Id"),
                    CurrentValue  = history.Id,
                    OriginalValue = 2
                }
            };

            string ignored;

            Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                history
            }, new List <int>()
            {
                1
            }, out ignored));
        }
Beispiel #6
0
        public void NoUserTypeIdUpdate()
        {
            var r = new Restrictions();

            var user = new User
            {
                Id         = 1,
                UserTypeId = 2
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            updates[user] = new Restrictions.ShadowModifiedMember[]
            {
                new Restrictions.ShadowModifiedMember
                {
                    Member        = typeof(User).GetProperty("UserTypeId"),
                    CurrentValue  = user.UserTypeId,
                    OriginalValue = 1
                }
            };

            string ignored;

            Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                user
            }, new List <int>()
            {
                1
            }, out ignored));
            Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>()
            {
                user
            }, new List <int>(), out ignored));
        }
Beispiel #7
0
        public void UpdateUsersInList()
        {
            var r = new Restrictions();

            var user = new User
            {
                Id = 1,
                CreationDate = DateTime.UtcNow
            };

            var updates = new Dictionary<object, Restrictions.ShadowModifiedMember[]>();
            updates[user] = new Restrictions.ShadowModifiedMember[]
                { 
                    new Restrictions.ShadowModifiedMember
                    { 
                        Member = typeof(User).GetProperty("CreationDate"),
                        CurrentValue = user.CreationDate,
                        OriginalValue = null
                    }
                };

            string ignored;
            Assert.IsTrue(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>() { user }, new List<int>() { 1 }, out ignored), ignored);
        }
Beispiel #8
0
        public void NoUserTypeIdUpdate()
        {
            var r = new Restrictions();

            var user = new User
            {
                Id = 1,
                UserTypeId = 2
            };

            var updates = new Dictionary<object, Restrictions.ShadowModifiedMember[]>();
            updates[user] = new Restrictions.ShadowModifiedMember[]
                { 
                    new Restrictions.ShadowModifiedMember
                    { 
                        Member = typeof(User).GetProperty("UserTypeId"),
                        CurrentValue = user.UserTypeId,
                        OriginalValue = 1
                    }
                };

            string ignored;
            Assert.IsFalse(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>() { user }, new List<int>() { 1 }, out ignored));
            Assert.IsFalse(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>() { user }, new List<int>(), out ignored));
        }
Beispiel #9
0
        public void PendingUserUpdateDeletionDate()
        {
            var r = new Restrictions();

            var pending = new PendingUser
            {
                Id = 1,
                DeletionDate = DateTime.Now
            };

            var updates = new Dictionary<object, Restrictions.ShadowModifiedMember[]>();
            updates[pending] = new Restrictions.ShadowModifiedMember[]
                {
                    new Restrictions.ShadowModifiedMember
                    {
                        Member = typeof(PendingUser).GetProperty("DeletionDate"),
                        CurrentValue = pending.DeletionDate,
                        OriginalValue = null
                    }
                };

            string ignored;
            Assert.IsTrue(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>() { pending }, new List<int>(), out ignored));
        }
Beispiel #10
0
        public void NoPendingUserUpdateOnNonDeletionDate()
        {
            var r = new Restrictions();

            var pending = new PendingUser
            {
                Id = 1
            };

            var updates = new Dictionary<object, Restrictions.ShadowModifiedMember[]>();
            updates[pending] = new Restrictions.ShadowModifiedMember[]
                {
                    new Restrictions.ShadowModifiedMember
                    {
                        Member = typeof(PendingUser).GetProperty("Id"),
                        CurrentValue = pending.Id,
                        OriginalValue = 2
                    }
                };

            string ignored;
            Assert.IsFalse(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>(){pending}, new List<int>(), out ignored));
            Assert.IsFalse(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>(){pending}, new List<int>() { 1 }, out ignored));
        }
Beispiel #11
0
        public void UserAttributeUpdateWithUserId()
        {
            var r = new Restrictions();

            var attr = new UserAttribute
            {
                UserId = 1
            };

            var updates = new Dictionary<object, Restrictions.ShadowModifiedMember[]>();
            updates[attr] = new Restrictions.ShadowModifiedMember[]
                {
                    new Restrictions.ShadowModifiedMember
                    {
                        Member = typeof(UserAttribute).GetProperty("UserId"),
                        CurrentValue = attr.Id,
                        OriginalValue = 2
                    }
                };

            string ignored;
            Assert.IsTrue(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>() { attr }, new List<int>() { 1 }, out ignored));
        }
Beispiel #12
0
        public void NoUserHistoryUpdates()
        {
            var r = new Restrictions();

            var history = new UserHistory
            {
                Id = 1
            };

            var updates = new Dictionary<object, Restrictions.ShadowModifiedMember[]>();
            updates[history] = new Restrictions.ShadowModifiedMember[]
                {
                    new Restrictions.ShadowModifiedMember
                    {
                        Member = typeof(UserHistory).GetProperty("Id"),
                        CurrentValue = history.Id,
                        OriginalValue = 2
                    }
                };

            string ignored;
            Assert.IsFalse(r.IsValidChangeSet(updates, new List<object>(), new List<object>(), new List<object>() { history }, new List<int>() { 1 }, out ignored));
        }