public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            ServiceRequest expectedState = new ServiceRequest
            {
                PriorityId         = 1,
                SubjectId          = 1,
                FulfillmentDetails = new List <ServiceRequestFulfillment> {
                    new ServiceRequestFulfillment {
                        FulfillmentStatusId = 1
                    }
                },
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                },
                LastModifyTime    = new DateTime(2010, 5, 13),
                LastModifyingUser = new User {
                    DisplayName = "jimGeorge"
                }
            };
            ServiceRequestModel target = new ServiceRequestModel();

            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);
        }
        public void GivenModelNotModified_AndViewModelAuditDataAlreadySet_WhenCopyFrom_ThenModelStatelastModifyValuesNull()
        {
            ServiceRequest expectedState = new ServiceRequest
            {
                PriorityId         = 1,
                SubjectId          = 1,
                FulfillmentDetails = new List <ServiceRequestFulfillment> {
                    new ServiceRequestFulfillment {
                        FulfillmentStatusId = 1
                    }
                },
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                }
            };
            ServiceRequestModel target = new ServiceRequestModel();

            target.Audit = new AuditModel {
                LastModifiedBy = "bob", LastModifyTime = DateTime.Now
            };

            target.CopyFrom(expectedState);

            Assert.IsNull(target.Audit.LastModifiedBy);
            Assert.IsFalse(target.Audit.LastModifyTime.HasValue);
        }
        public void WhenContruct_ThenDefaultsSet()
        {
            Target = new ServiceRequestModel();

            Assert.AreEqual(1, Target.SelectedPriorityId);
            Assert.AreEqual(1, Target.SelectedSubjectId);
            Assert.AreEqual(1, Target.SelectedStatusId);
        }
 public void InitializeTest()
 {
     Target   = new ServiceRequestModel();
     TestData = new TestData();
 }