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"]); }
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); }
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); }
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); }