コード例 #1
0
        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);
        }
コード例 #2
0
        public void PopulateForm()
        {
            User User = new User(Ef.TempItems.First().ItemID.Value);

            User.EffectiveDate = new DateTime(2015, 3, 1);
            GeneralInfoEntity Entity = User.EffectiveRecord.CreateEntityAndApplyPolicy<GeneralInfoEntity>(CopyValuesFromPrevious: true);
            Entity.First_Name.Value = "Bobby";
            User.PersistToDatabase();

            User = new User(Ef.TempItems.First().ItemID.Value);

            User.EffectiveDate = new DateTime(2015, 1, 1);
            GeneralInfoForm Form = new GeneralInfoForm()
            {
                GeneralInfoID = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>().EntityID,
            };
            Form.BindTo(User);
            Form.PopulateForm();

            Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>();

            Assert.NotNull(Entity);
            Assert.Equal(Entity.First_Name.Value, Form.First_Name);
            Assert.Equal(Entity.Last_Name.Value, Form.Last_Name);
            Assert.Equal(Entity.EntityID.Value, Form.GeneralInfoID);

            User = new User(Ef.TempItems.First().ItemID.Value);

            User.EffectiveDate = new DateTime(2015, 1, 1);
            Form = new GeneralInfoForm();
            Form.BindTo(User);
            Form.PopulateForm();

            Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>();

            Assert.NotNull(Entity);
            Assert.Equal(Entity.First_Name.Value, Form.First_Name);
            Assert.Equal(Entity.Last_Name.Value, Form.Last_Name);
            Assert.Equal(Entity.EntityID.Value, Form.GeneralInfoID);

            User = new User(Ef.TempItems.First().ItemID.Value);
            User.EffectiveDate = new DateTime(2015, 3, 1);
            Form = new GeneralInfoForm()
            {
                GeneralInfoID = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>().EntityID,
                Effective_Date = new DateTime(2015, 3, 1),
            };
            Form.BindTo(User);
            Form.PopulateForm();

            Entity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>();

            Assert.NotNull(Entity);
            Assert.Equal(Entity.First_Name.Value, Form.First_Name);
            Assert.Equal(Entity.Last_Name.Value, Form.Last_Name);
            Assert.Equal(Entity.EntityID.Value, Form.GeneralInfoID);
            Assert.Equal("Bobby", Form.First_Name);
        }
コード例 #3
0
        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);
        }