public void GivenModelNotModified_WhenCopyFrom_ThenModelStatelastModifyValuesNull()
        {
            CustomField expectedState = new PublicField
            {
                CreateTime = new DateTime(2005, 4, 30),
                CreatingUser = new User { DisplayName = "fredBob" }
            };
            CustomFieldModel target = new PublicFieldModel();

            target.CopyFrom(expectedState);

            Assert.IsNull(target.Audit.LastModifiedBy);
            Assert.IsFalse(target.Audit.LastModifyTime.HasValue);
        }
Esempio n. 2
0
        public void GivenModelNotModified_WhenCopyFrom_ThenModelStatelastModifyValuesNull()
        {
            CustomField expectedState = new PublicField
            {
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                }
            };
            CustomFieldModel target = new PublicFieldModel();

            target.CopyFrom(expectedState);

            Assert.IsNull(target.Audit.LastModifiedBy);
            Assert.IsFalse(target.Audit.LastModifyTime.HasValue);
        }
        public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            CustomField expectedState = new PublicField
            {
                CreateTime = new DateTime(2005, 4, 30),
                CreatingUser = new User { DisplayName = "fredBob" },
                LastModifyTime = new DateTime(2010, 5, 13),
                LastModifyingUser = new User { DisplayName = "jimGeorge" }
            };
            CustomFieldModel target = new PublicFieldModel();

            target.CopyFrom(expectedState);

            AuditModel actualState = target.Audit;
            Assert.AreEqual(expectedState.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expectedState.CreatingUser.DisplayName, actualState.CreatedBy);
            Assert.AreEqual(expectedState.LastModifyTime, actualState.LastModifyTime);
            Assert.AreEqual(expectedState.LastModifyingUser.DisplayName, actualState.LastModifiedBy);
        }
Esempio n. 4
0
        public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            CustomField expectedState = new PublicField
            {
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                },
                LastModifyTime    = new DateTime(2010, 5, 13),
                LastModifyingUser = new User {
                    DisplayName = "jimGeorge"
                }
            };
            CustomFieldModel target = new PublicFieldModel();

            target.CopyFrom(expectedState);

            AuditModel actualState = target.Audit;

            Assert.AreEqual(expectedState.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expectedState.CreatingUser.DisplayName, actualState.CreatedBy);
            Assert.AreEqual(expectedState.LastModifyTime, actualState.LastModifyTime);
            Assert.AreEqual(expectedState.LastModifyingUser.DisplayName, actualState.LastModifiedBy);
        }