public void TestGetStringValue() { var customer = new Customer(); var propertyInfo = GetCustomerProperty("PersonalManager"); Assert.IsNotNull(propertyInfo); Assert.AreEqual("Bob", propertyInfo.GetStringValue(customer)); var createdProperty = GetCustomerProperty("Created"); var createdByProperty = GetCustomerProperty("CreatedBy"); Assert.IsNotNull(createdProperty); Assert.IsNull(createdProperty.GetStringValue(customer)); Assert.IsNull(createdByProperty.GetStringValue(customer)); customer.UpdateModificationContext(DateTime.Now, UnitTestHelper.TEST_USER); Assert.AreEqual(customer.Created.ToString(), createdProperty.GetStringValue(customer)); Assert.AreEqual(customer.CreatedBy, createdByProperty.GetStringValue(customer)); Assert.AreEqual(UnitTestHelper.TEST_USER, createdByProperty.GetStringValue(customer)); var baseTypeProperty = typeof(Type).GetProperty("BaseType", BindingFlags.Public | BindingFlags.Instance); Assert.IsNotNull(baseTypeProperty); Assert.AreEqual(typeof(DomainObjectBase).ToString(), baseTypeProperty.GetStringValue(typeof(Customer))); }
public void TestUpdateModificationContext_BlankArg() { var customer = new Customer(); Assert.Throws<ArgumentException>(() => customer.UpdateModificationContext(DateTime.Now, null)); Assert.Throws<ArgumentException>(() => customer.UpdateModificationContext(DateTime.Now, String.Empty)); Assert.Throws<ArgumentException>(() => customer.UpdateModificationContext(DateTime.Now, UnitTestHelper.BLANK_STRING)); }
public void TestUpdateModificationContext() { var customer = new Customer(); Assert.IsTrue(customer.IsNew); Assert.IsNull(customer.Created); Assert.IsNull(customer.CreatedBy); Assert.IsNull(customer.Modified); Assert.IsNull(customer.ModifiedBy); Assert.AreEqual(0, customer.Version); var updated = DateTime.Now; customer.UpdateModificationContext(updated, UnitTestHelper.TEST_USER); Assert.IsFalse(customer.IsNew); Assert.AreEqual(updated, customer.Created); Assert.AreEqual(UnitTestHelper.TEST_USER, customer.CreatedBy); Assert.AreEqual(updated, customer.Modified); Assert.AreEqual(UnitTestHelper.TEST_USER, customer.ModifiedBy); Assert.AreEqual(1, customer.Version); var futureUpdated = new DateTime(2050, 03, 24, 14, 32, 45); const string ANOTHER_TEST_USER = "******"; customer.UpdateModificationContext(futureUpdated, ANOTHER_TEST_USER); Assert.IsFalse(customer.IsNew); Assert.AreEqual(updated, customer.Created); Assert.AreEqual(UnitTestHelper.TEST_USER, customer.CreatedBy); Assert.AreEqual(futureUpdated, customer.Modified); Assert.AreEqual(ANOTHER_TEST_USER, customer.ModifiedBy); Assert.AreEqual(2, customer.Version); }