public void IdenticalLoadHistories_NotChanged()
            {
                var history = new LoadHistoryEntity();
                var actual  = _svc.HasLoadChanged(history, history);

                actual.Should().BeFalse();
            }
            public void DifferentPropertyValues_HasChanged()
            {
                var orig = new LoadHistoryEntity
                {
                    LineHaulRate = 1m
                };
                var latest = new LoadHistoryEntity
                {
                    LineHaulRate = 2m
                };
                var actual = _svc.HasLoadChanged(orig, latest);

                actual.Should().BeTrue();
            }
            public void NullLatestPropertyValue_HasChanged()
            {
                var orig = new LoadHistoryEntity
                {
                    Comments = "comments"
                };
                var latest = new LoadHistoryEntity
                {
                    Comments = null
                };
                var actual = _svc.HasLoadChanged(orig, latest);

                actual.Should().BeTrue();
            }
Ejemplo n.º 4
0
        public bool HasLoadChanged(LoadHistoryEntity originalValues, LoadHistoryEntity newValues)
        {
            var type = typeof(LoadHistoryEntity);

            foreach (PropertyInfo pi in type.GetProperties())
            {
                object value1 = type.GetProperty(pi.Name).GetValue(originalValues, null);
                object value2 = type.GetProperty(pi.Name).GetValue(newValues, null);

                if (value1 != value2 && (value1 == null || !value1.Equals(value2)))
                {
                    return(true);
                }
            }
            return(false);
        }