public void PersistForm() { User User = null; User = new User(Ef.TempItems.First().ItemID.Value); User.EffectiveDate = new DateTime(2015, 1, 1); GeneralInfoForm Form = new GeneralInfoForm(); Form.BindTo(User); Form.PopulateForm(); Form.Effective_Date = new DateTime(2015, 4, 1); Form.GeneralInfoID = null; Form.First_Name = "Johnny"; Form.Last_Name = "Jones"; Form.PushValuesToModel(); User.PersistToDatabase(); User = new User(Ef.TempItems.First().ItemID.Value); User.EffectiveDate = new DateTime(2015, 4, 1); var Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>(); Assert.NotNull(Entity); Assert.Equal(Form.First_Name, Entity.First_Name.Value); Assert.Equal(Form.Last_Name, Entity.Last_Name.Value); User.EffectiveDate = new DateTime(2015, 1, 1); Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>(); Assert.NotNull(Entity); Assert.Equal("John", Entity.First_Name.Value); Assert.Equal("Smith", Entity.Last_Name.Value); }
public void EnsurePushingToModelWithNoEffectiveDateUsesNow() { User User = new User(Ef.TempItems.First().ItemID.Value); DateTime Today = DateTime.Now.Date; GeneralInfoForm GeneralInfo = new GeneralInfoForm(); GeneralInfo.BindTo(User); GeneralInfo.First_Name = "Johann"; GeneralInfo.PushValuesToModel(); User.PersistToDatabase(); User.Load(); User.EffectiveDate = DateTime.Now.Date; GeneralInfoEntity Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>(); Assert.Equal("Johann", Entity.First_Name.Value); Assert.Equal(Today, Entity.EffectiveDate.Date); User.EffectiveDate = new DateTime(2015, 1, 1); Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>(); Assert.Equal("John", Entity.First_Name.Value); }