예제 #1
0
        public void TestObjectField()
        {
            User User = new User(Ef.TempItems.First().ItemID.Value);

            var Entity = User.EffectiveRecord.CreateEntity<StaticUserDataEntity>();
            Entity.Dictionary.Value = new Dictionary<string, object>()
            {
                { "TestKey", "TestValue" }
            };

            User.PersistToDatabase();
            User.Load();
            Entity = User.EffectiveRecord.GetFirstEntityOrDefault<StaticUserDataEntity>();
            Assert.Equal("TestValue", (string)Entity.Dictionary.Value["TestKey"]);
        }
예제 #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 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);
        }
예제 #4
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);
        }
예제 #5
0
        public void EnsureConcurrentUpdatesDontOverwriteEachOther()
        {
            User User1 = new User(Ef.TempItems.First().ItemID.Value);
            User User2 = new User(Ef.TempItems.First().ItemID.Value);

            User1.EffectiveRecord.GetFirstEntityOrDefault<UserTypeEntity>().UserType.Value = "Administrator";
            User2.EffectiveRecord.GetFirstEntityOrDefault<UserTypeEntity>().UserType.Value = "Pion";

            User1.PersistToDatabase();
            Assert.Throws(typeof(GuidMismatchException), () => { User2.PersistToDatabase(); });

            User2.Load();
            Assert.Equal("Administrator", User2.EffectiveRecord.GetFirstEntityOrDefault<UserTypeEntity>().UserType.Value);
        }
예제 #6
0
        public void EnsureButtSplicedEntitiesDontPersist()
        {
            User User = new User(Ef.TempItems.First().ItemID.Value);
            User.EffectiveDate = new DateTime(2015, 6, 1);

            var OldEntity = User.EffectiveRecord.GetFirstEntityOrDefault<GeneralInfoEntity>();
            OldEntity.EndEffectiveDate = new DateTime(2015, 7, 1);

            User.PersistToDatabase();

            Assert.Equal(1, User.AllEntities.Count(e => e.Type == TestEntityType.General_Info));
            User.Load();

            Assert.Equal(1, User.AllEntities.Count(e => e.Type == TestEntityType.General_Info));

            User.EffectiveDate = new DateTime(2015, 7, 1);

            User.EffectiveRecord.CreateEntityAndApplyPolicy<GeneralInfoEntity>(new DateTime(2015, 9, 1), CopyValuesFromPrevious: true);
            User.PersistToDatabase();

            Assert.Equal(1, User.AllEntities.Count(e => e.Type == TestEntityType.General_Info));
            User.Load();

            Assert.Equal(1, User.AllEntities.Count(e => e.Type == TestEntityType.General_Info));
            Assert.Equal(new DateTime(2015, 9, 1), User.AllEntities.First(e => e.Type == TestEntityType.General_Info).EndEffectiveDate);
        }