public void TestUpdatesProperties_GivenBo_UserNameAndDate_AndSecurityController() { //-------------Setup Test Pack ------------------ new Engine(); new Car(); ContactPerson contactPerson = new ContactPerson(); IBOProp dateBoProp = contactPerson.Props["DateLastUpdated"]; IBOProp userBoProp = contactPerson.Props["UserLastUpdated"]; contactPerson.CancelEdits(); ISecurityController securityController = new MySecurityController(); BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson, securityController); //-------------Test Pre-conditions -------------- //-------------Execute test --------------------- DateTime beforeUpdate = DateTime.Now; log.Update(); DateTime afterUpdate = DateTime.Now; //-------------Test Result ---------------------- Assert.IsNotNull(userBoProp.Value); Assert.AreEqual("MyUserName", userBoProp.Value); Assert.IsNotNull(dateBoProp.Value); Assert.IsTrue(beforeUpdate <= (DateTime)dateBoProp.Value); Assert.IsTrue(afterUpdate >= (DateTime)dateBoProp.Value); }
public void TestCancelEdits() { ContactPerson myContact = new ContactPerson(); Assert.IsFalse(myContact.Status.IsValid()); myContact.Surname = "My Surname"; Assert.IsTrue(myContact.Status.IsValid()); Assert.AreEqual("My Surname", myContact.Surname); myContact.CancelEdits(); Assert.IsFalse(myContact.Status.IsValid()); Assert.IsTrue(myContact.Surname.Length == 0); }
public void TestUpdatesProperties_GivenBo_WithoutUserNameAndDate() { //-------------Setup Test Pack ------------------ new Engine(); new Car(); ContactPerson contactPerson = new ContactPerson(); contactPerson.Props.Remove("DateLastUpdated"); contactPerson.Props.Remove("UserLastUpdated"); contactPerson.CancelEdits(); ISecurityController securityController = new MySecurityController(); GlobalRegistry.SecurityController = securityController; BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson); //-------------Test Pre-conditions -------------- //-------------Execute test --------------------- log.Update(); //-------------Test Result ---------------------- //Should give no errors. }
public void TestCancelEdits() { ContactPerson myContact = new ContactPerson(); Assert.IsFalse(myContact.Status.IsValid()); myContact.Surname = "My Surname"; Assert.IsTrue(myContact.Status.IsValid()); Assert.AreEqual("My Surname", myContact.Surname); myContact.CancelEdits(); Assert.IsFalse(myContact.Status.IsValid()); Assert.IsTrue(myContact.Surname.Length == 0); }
public void TestUpdatesProperties_GivenBo_WithoutUserNameAndDate() { //-------------Setup Test Pack ------------------ new Engine(); new Car(); ContactPerson contactPerson = new ContactPerson(); contactPerson.Props.Remove("DateLastUpdated"); contactPerson.Props.Remove("UserLastUpdated"); contactPerson.CancelEdits(); ISecurityController securityController = new MySecurityController(); GlobalRegistry.SecurityController = securityController; BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson); //-------------Test Pre-conditions -------------- //-------------Execute test --------------------- log.Update(); //-------------Test Result ---------------------- //Should give no errors. }
public void TestUpdatesProperties_GivenBo_UserNameAndDate_AndSecurityController() { //-------------Setup Test Pack ------------------ new Engine(); new Car(); ContactPerson contactPerson = new ContactPerson(); IBOProp dateBoProp = contactPerson.Props["DateLastUpdated"]; IBOProp userBoProp = contactPerson.Props["UserLastUpdated"]; contactPerson.CancelEdits(); ISecurityController securityController = new MySecurityController(); BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson, securityController); //-------------Test Pre-conditions -------------- //-------------Execute test --------------------- DateTime beforeUpdate = DateTime.Now; log.Update(); DateTime afterUpdate = DateTime.Now; //-------------Test Result ---------------------- Assert.IsNotNull(userBoProp.Value); Assert.AreEqual("MyUserName", userBoProp.Value); Assert.IsNotNull(dateBoProp.Value); Assert.IsTrue(beforeUpdate <= (DateTime)dateBoProp.Value); Assert.IsTrue(afterUpdate >= (DateTime)dateBoProp.Value); }