public void CanSetPersister() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); rc.Persister<SingleTableEntityPersister>(); Assert.That(mapdoc.RootClasses[0].Persister, Is.StringContaining("SingleTableEntityPersister")); }
public void WhenMapExternalMemberAsComponentIdThenThrows() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, For<Person>.Property(x => x.Id)); mapper.Executing(m => m.ComponentAsId(For<User>.Property(x => x.Id), map => map.Access(Accessor.Field))).Throws<ArgumentOutOfRangeException>(); }
public void CanSetPersister() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); rc.Persister<SingleTableEntityPersister>(); mapdoc.RootClasses[0].Persister.Should().Contain("SingleTableEntityPersister"); }
public void WhenSetMoreSyncThenAddAll() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); rc.Synchronize("T1", "T2", "T3", null); mapdoc.RootClasses[0].Synchronize.Select(x => x.table).Should().Have.SameValuesAs("T1", "T2", "T3"); }
public void WhenSetSyncMixedWithNullAndEmptyThenAddOnlyValid() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); rc.Synchronize("", " ATable ", " ", null); mapdoc.RootClasses[0].Synchronize.Single().table.Should().Be("ATable"); }
public void WhenSetMoreSyncThenAddAll() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); rc.Synchronize("T1", "T2", "T3", null); Assert.That(mapdoc.RootClasses[0].Synchronize.Select(x => x.table), Is.EquivalentTo(new [] {"T1", "T2", "T3"})); }
public void WhenMixSimpleIdWithComponentAsIdThenThrows() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, For<Person>.Property(x => x.Id)); mapper.Id(For<Person>.Property(x => x.Poid), pm => { }); Assert.That(() => mapper.ComponentAsId(For<Person>.Property(x => x.Id), map => map.Property(For<PersonId>.Property(x => x.Email), pm => { })), Throws.TypeOf<MappingException>()); }
public void WhenMixSimpleIdWithComposedIdThenThrows() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, For<Person>.Property(x => x.Id)); mapper.Id(For<Person>.Property(x => x.Poid), pm => { }); Executing.This(() => mapper.ComposedId(map => map.Property(For<Person>.Property(x => x.Name), pm => { })) ).Should().Throw<MappingException>(); }
public void WhenDefineMoreJoinsThenTableNameShouldBeUnique() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x => x.Id)); mapper.Join("T1", x => { }); mapper.Join("T2",x => { }); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Joins.Should().Have.Count.EqualTo(2); hbmClass.Joins.Select(x=> x.table).Should().Have.UniqueValues(); }
public void WhenDefineMoreJoinsThenTableNameShouldBeUnique() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x => x.Id)); mapper.Join("T1", x => { }); mapper.Join("T2",x => { }); var hbmClass = mapdoc.RootClasses[0]; Assert.That(hbmClass.Joins.Count(), Is.EqualTo(2)); Assert.That(hbmClass.Joins.Select(x => x.table), Is.Unique); }
public void WhenDefineJoinThenAddJoinWithTableNameAndKey() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x=> x.Id)); mapper.Join("MyTable",x => { }); var hbmClass = mapdoc.RootClasses[0]; var hbmJoin = hbmClass.Joins.Single(); hbmJoin.table.Should().Be("MyTable"); hbmJoin.key.Should().Not.Be.Null(); hbmJoin.key.column1.Should().Not.Be.Null(); }
public void WhenSameNameThenOverrideCondition() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, typeof(EntitySimple).GetProperty("Id")); rc.Filter("filter1", f => f.Condition("condition1")); rc.Filter("filter2", f => f.Condition("condition2")); rc.Filter("filter1", f => f.Condition("anothercondition1")); mapdoc.RootClasses[0].filter.Length.Should().Be(2); mapdoc.RootClasses[0].filter.Satisfy(filters => filters.Any(f => f.name == "filter1" && f.condition == "anothercondition1")); mapdoc.RootClasses[0].filter.Satisfy(filters => filters.Any(f => f.name == "filter2" && f.condition == "condition2")); }
public void WhenSetTwoVersionPropertiesInTwoActionThenSetTheTwoValuesWithoutLostTheFirst() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimpleWithVersion), mapdoc, typeof(EntitySimpleWithVersion).GetProperty("Id")); rc.Version(typeof(EntitySimpleWithVersion).GetProperty("EntityVersion"), vm => vm.Generated(VersionGeneration.Always)); rc.Version(typeof(EntitySimpleWithVersion).GetProperty("EntityVersion"), vm => vm.Column("pizza")); var hbmVersion = mapdoc.RootClasses[0].Version; hbmVersion.generated.Should().Be(HbmVersionGeneration.Always); hbmVersion.column1.Should().Be("pizza"); }
public void WhenDefineJoinThenAddJoinWithTableNameAndKey() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x=> x.Id)); mapper.Join("MyTable",x => { }); var hbmClass = mapdoc.RootClasses[0]; var hbmJoin = hbmClass.Joins.Single(); Assert.That(hbmJoin.table, Is.EqualTo("MyTable")); Assert.That(hbmJoin.key, Is.Not.Null); Assert.That(hbmJoin.key.column1, Is.Not.Null); }
protected override void RegisterClasses() { ClassMapper .Add(() => ClassProvider.Tabs()) .If(() => ClassProvider.TabsCards(), () => IsCards) .If(() => ClassProvider.TabsPills(), () => IsPills) .If(() => ClassProvider.TabsFullWidth(), () => IsFullWidth) .If(() => ClassProvider.TabsJustified(), () => IsJustified) .If(() => ClassProvider.TabsVertical(), () => IsVertical); base.RegisterClasses(); }
protected void SetClassMap() { ClassMapper .Clear() .If(BaseClassName, () => NavTheme == MenuTheme.Light) .If("light", () => NavTheme == MenuTheme.Light); MainClassMapper .Clear() .Add($"{BaseClassName}-main") .If("wide", () => ContentWidth == "Fixed"); }
public override void OnCreate() { try { base.OnCreate(); Instance = this; ClassMapper.SetMappers(); RegisterActivityLifecycleCallbacks(this); //A great place to initialize Xamarin.Insights and Dependency Services! Client client = new Client(AppSettings.Cert); if (AppSettings.TurnSecurityProtocolType3072On) { ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; HttpClient clientHttp = new HttpClient(new Xamarin.Android.Net.AndroidClientHandler()); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; } if (AppSettings.TurnTrustFailureOnWebException) { //If you are Getting this error >>> System.Net.WebException: Error: TrustFailure /// then Set it to true ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; System.Security.Cryptography.AesCryptoServiceProvider b = new System.Security.Cryptography.AesCryptoServiceProvider(); } //OneSignal Notification //====================================== OneSignalNotification.RegisterNotificationDevice(); if (AppSettings.ShowAdmobBanner || AppSettings.ShowAdmobInterstitial || AppSettings.ShowAdmobRewardVideo) { MobileAds.Initialize(this, AppSettings.AdAppKey); } //Init Settings SharedPref.Init(); //App restarted after crash AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironmentOnUnhandledExceptionRaiser; AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; } catch (Exception exception) { Console.WriteLine(exception); } }
public void WhenComposedIdCustomizedMoreThanOnceThenMerge() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, null); mapper.ComposedId(map => map.Property(For<Person>.Property(x => x.Email), pm => { })); mapper.ComposedId(map => map.ManyToOne(For<Person>.Property(x => x.User), pm => { })); var hbmClass = mapdoc.RootClasses[0]; Assert.That(hbmClass.Id, Is.Null); var hbmCompositeId = hbmClass.CompositeId; Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); }
public void WhenDefineJoinThenCallJoinMapper() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x => x.Id)); var called = false; mapper.Join("MyTable", x => { Assert.That(x, Is.Not.Null); called = true; }); Assert.That(called, Is.True); }
protected override void RegisterClasses() { ClassMapper .Add(() => ClassProvider.Table()) .If(() => ClassProvider.TableFullWidth(), () => IsFullWidth) .If(() => ClassProvider.TableStriped(), () => IsStriped) .If(() => ClassProvider.TableBordered(), () => IsBordered) .If(() => ClassProvider.TableHoverable(), () => IsHoverable) .If(() => ClassProvider.TableNarrow(), () => IsNarrow) .If(() => ClassProvider.TableBorderless(), () => IsBorderless); base.RegisterClasses(); }
public void WhenComposedIdCustomizedMoreThanOnceThenMerge() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, null); mapper.ComposedId(map => map.Property(For<Person>.Property(x => x.Email), pm => { })); mapper.ComposedId(map => map.ManyToOne(For<Person>.Property(x => x.User), pm => { })); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Id.Should().Be.Null(); var hbmCompositeId = hbmClass.CompositeId; hbmCompositeId.Items.Should().Have.Count.EqualTo(2); }
public virtual string GetSelectAllSql <T>() where T : class { ClassMap classMap = ClassMapper.GetClassMap <T>(); StringBuilder sb = new StringBuilder(); sb.Append("SELECT "); sb.Append(string.Join(", ", classMap.SelectProperties.Select(x => this.EncapsulateSelect(x)))); sb.Append(" FROM "); sb.Append(this.GetTableIdentifier <T>()); return(sb.ToString()); }
public void TestClassMapperViaTableMappingOverride() { // Setup ClassMapper.Add <ClassMapperTableAttributeTestClass>("[sales].[Person]"); ClassMapper.Add <ClassMapperTableAttributeTestClass>("[hr].[Person]", true); // Act var actual = ClassMappedNameCache.Get <ClassMapperTableAttributeTestClass>(); var expected = "[dbo].[Person]"; // Assert Assert.AreEqual(expected, actual); }
protected override void OnInitialized() { _currentInstance = DotNetObjectReference.Create(this); var prefixCls = "ant-upload"; ClassMapper .Add(prefixCls) .Get(() => $"{prefixCls}-select-{ListType}") .If($"{prefixCls}-drag", () => Upload?.Drag == true) .If($"{prefixCls}-drag-hover", () => Upload?._dragHover == true) .Add($"{prefixCls}-select") .If($"{prefixCls}-rtl", () => RTL); }
public void ClassMapperTest() { const string superClass = "superClass"; var elementFinder = new FakeClassElementFinder(NewClassName, new[] { superClass }); var mapper = new ClassMapper(elementFinder); var mappedClass = mapper.GetMappedItem(); var mappedName = mappedClass.Name; var mappedSupperClass = mappedClass.SuperClasses.FirstOrDefault(); Assert.AreEqual(NewClassName, mappedName); Assert.AreEqual(superClass, mappedSupperClass); }
protected void SetClass() { ClassMapperLabel.Clear() .Add($"{_prefixCls}-wrapper") .If($"{_prefixCls}-wrapper-checked", () => Checked ?? false); ClassMapper.Clear() .Add(_prefixCls) .If($"{_prefixCls}-checked", () => Checked ?? false) .If($"{_prefixCls}-disabled", () => Disabled) .If($"{_prefixCls}-indeterminate", () => Checked == null) .If($"{_prefixCls}-rtl", () => RTL); }
/// <inheritdoc/> protected override void OnInitialized() { base.OnInitialized(); ClassMapper .Add("mdc-switch") .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass) .AddIf("mdc-switch--disabled", () => AppliedDisabled) .AddIf("mdc-switch--checked", () => ReportingValue); OnValueSet += OnValueSetCallback; OnDisabledSet += OnDisabledSetCallback; }
public void WhenDefineMoreJoinsThenTableNameShouldBeUnique() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); mapper.Join("T1", x => { }); mapper.Join("T2", x => { }); var hbmClass = mapdoc.RootClasses[0]; Assert.That(hbmClass.Joins.Count(), Is.EqualTo(2)); Assert.That(hbmClass.Joins.Select(x => x.table), Is.Unique); }
public void WhenDefineJoinThenCallJoinMapper() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x => x.Id)); var called = false; mapper.Join("MyTable", x => { x.Should().Not.Be.Null(); called = true; }); called.Should().Be.True(); }
public void WhenDefineMoreJoinsThenTableNameShouldBeUnique() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); mapper.Join("T1", x => { }); mapper.Join("T2", x => { }); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Joins.Should().Have.Count.EqualTo(2); hbmClass.Joins.Select(x => x.table).Should().Have.UniqueValues(); }
public virtual string GetSelectCountSql <T>(IEnumerable <IPredicate> whereConditions) where T : class { ClassMap classMap = ClassMapper.GetClassMap <T>(); StringBuilder sb = new StringBuilder($"SELECT COUNT(*) FROM {this.GetTableIdentifier(classMap)}"); if (whereConditions.Any()) { sb.Append(" "); sb.Append(this.GetWhereClause(whereConditions)); } return(sb.ToString()); }
// Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor protected override void OnInitialized() { base.OnInitialized(); ItemArray = Items.ToArray(); MBItemValidation appliedItemValidation = CascadingDefaults.AppliedItemValidation(ItemValidation); ForceShouldRenderToTrue = true; ReportingValue = ValidateItemList(ItemArray, appliedItemValidation); ClassMapper.AddIf("mb-mdc-radio-group-vertical", () => Vertical); }
public void CanSetNaturalId() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimpleWithNaturalId), mapdoc, typeof(EntitySimpleWithNaturalId).GetProperty("Id")); rc.NaturalId(nidm => nidm.Property(typeof(EntitySimpleWithNaturalId).GetProperty("Code"), pm => { })); mapdoc.RootClasses[0].Properties.Should("The property should be only inside natural-id").Have.Count.EqualTo(0); var hbmNaturalId = mapdoc.RootClasses[0].naturalid; hbmNaturalId.Should().Not.Be.Null(); hbmNaturalId.Properties.Should().Have.Count.EqualTo(1); }
public void WhenDefineJoinThenCallJoinMapper() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); var called = false; mapper.Join("MyTable", x => { x.Should().Not.Be.Null(); called = true; }); called.Should().Be.True(); }
public void WhenDefineJoinThenAddJoinWithTableNameAndKey() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); mapper.Join("MyTable", x => { }); var hbmClass = mapdoc.RootClasses[0]; var hbmJoin = hbmClass.Joins.Single(); hbmJoin.table.Should().Be("MyTable"); hbmJoin.key.Should().Not.Be.Null(); hbmJoin.key.column1.Should().Not.Be.Null(); }
public void WhenSetTwoCachePropertiesInTwoActionsThenSetTheTwoValuesWithoutLostTheFirst() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimpleWithNaturalId), mapdoc, typeof(EntitySimpleWithNaturalId).GetProperty("Id")); rc.Cache(ch => ch.Region("pizza")); rc.Cache(ch => ch.Usage(CacheUsage.NonstrictReadWrite)); var hbmCache = mapdoc.RootClasses[0].cache; hbmCache.Should().Not.Be.Null(); hbmCache.region.Should().Be("pizza"); hbmCache.usage.Should().Be(HbmCacheUsage.NonstrictReadWrite); }
public void TestClass_StaticFieldsMap() { const string staticFieldId = "newStaticFieldId"; var assignStatement = BuildAssignment(new[] { staticFieldId }); var elementFinder = new FakeClassElementFinder(NewClassName, new[] { assignStatement }); var mapper = new ClassMapper(elementFinder); var mappedClass = mapper.GetMappedItem(); var mappedField = mappedClass.Fields.FirstOrDefault(); var mappedFieldName = mappedField.Identifier.GetField(); Assert.AreEqual(staticFieldId, mappedFieldName); Assert.IsTrue(mappedField.IsStatic); }
// Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor protected override void OnInitialized() { base.OnInitialized(); ClassMapper .Add("mdc-list") .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass && NumberOfLines == 1 && AppliedListType != MBListType.Dense) .AddIf("mdc-card--outlined", () => (CascadingDefaults.AppliedStyle(AppliedListStyle) == MBListStyle.Outlined)) .AddIf("mdc-list--two-line", () => (NumberOfLines == 2)) .AddIf("mb-list--three-line", () => (NumberOfLines == 3)) .AddIf("mdc-list--non-interactive", () => NonInteractive) .AddIf("mdc-list--dense", () => AppliedListType == MBListType.Dense) .AddIf("mdc-list--avatar-list", () => AppliedListType == MBListType.Avatar); }
public void TestFluentMapMappingOverride() { // Setup FluentMapper .Entity <FluentMapperTestClass>() .Table("[sc].[Table]", true); // Act var actual = ClassMapper.Get <FluentMapperTestClass>(); var expected = "[sc].[Table]"; // Assert Assert.AreEqual(expected, actual); }
public void WhenDefineJoinThenCallJoinMapper() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); var called = false; mapper.Join("MyTable", x => { Assert.That(x, Is.Not.Null); called = true; }); Assert.That(called, Is.True); }
/// <inheritdoc/> protected override void OnInitialized() { base.OnInitialized(); ClassMapper .Add("mdc-select") .AddIf(DensityInfo.CssClassName, () => DensityInfo.ApplyCssClass) .AddIf("mdc-select--filled", () => AppliedInputStyle == MBSelectInputStyle.Filled) .AddIf("mdc-select--outlined", () => AppliedInputStyle == MBSelectInputStyle.Outlined) .AddIf("mdc-select--no-label", () => string.IsNullOrWhiteSpace(Label)) .AddIf("mdc-select--disabled", () => AppliedDisabled); OnValueSet += OnValueSetCallback; }
public void WhenDefineJoinThenAddJoinWithTableNameAndKey() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); mapper.Join("MyTable", x => { }); var hbmClass = mapdoc.RootClasses[0]; var hbmJoin = hbmClass.Joins.Single(); Assert.That(hbmJoin.table, Is.EqualTo("MyTable")); Assert.That(hbmJoin.key, Is.Not.Null); Assert.That(hbmJoin.key.column1, Is.Not.Null); }
/// <summary> /// 获取类映射 /// </summary> /// <param name="t">类型</param> /// <returns></returns> public virtual ClassMapper GetMapper(Type t) { List <PropertyInfo> propertys = ReflectionUtils.TypePropertiesCache(t); TableAttribute attribute = ReflectionUtils.CustomAttributesCache(t); ClassMapper map = new ClassMapper { TableName = attribute == null ? "" : attribute.TableName, PrimaryKey = attribute == null ? "" : attribute.PrimaryKey, PrimaryKeyType = attribute == null ? PrimaryKeyType.Assigned : attribute.PrimaryKeyType, Properties = propertys }; return(map); }
public void WhenDefineMoreJoinsWithSameIdThenUseSameJoinMapperInstance() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For<MyClass>.Property(x => x.Id)); IJoinMapper firstCallInstance = null; IJoinMapper secondCallInstance = null; mapper.Join("T1", x => firstCallInstance = x); mapper.Join("T1", x => secondCallInstance = x); firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Joins.Should().Have.Count.EqualTo(1); }
public void TestClass_MethodMap() { const string newMethodName = "newMethod"; const string instancePointer = "InstancePointer"; var methodElementsFinder = new FakeInstanceMethodElementFinder(newMethodName, new[] { instancePointer }); var elementFinder = new FakeClassElementFinder(NewClassName, new[] { methodElementsFinder }); var mapper = new ClassMapper(elementFinder); var mappedClass = mapper.GetMappedItem(); var mappedMethods = mappedClass.Methods.FirstOrDefault(); var mappedMethodsName = mappedMethods.Name; Assert.AreEqual(newMethodName, mappedMethodsName); }
public void WhenDefineMoreJoinsWithSameIdThenUseSameJoinMapperInstance() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(MyClass), mapdoc, For <MyClass> .Property(x => x.Id)); IJoinMapper firstCallInstance = null; IJoinMapper secondCallInstance = null; mapper.Join("T1", x => firstCallInstance = x); mapper.Join("T1", x => secondCallInstance = x); Assert.That(firstCallInstance, Is.SameAs(secondCallInstance)); var hbmClass = mapdoc.RootClasses[0]; Assert.That(hbmClass.Joins.Count(), Is.EqualTo(1)); }
public void WhenComposedIdCustomizedMoreThanOnceThenMerge() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, null); mapper.ComposedId(map => map.Property(For <Person> .Property(x => x.Email), pm => { })); mapper.ComposedId(map => map.ManyToOne(For <Person> .Property(x => x.User), pm => { })); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Id.Should().Be.Null(); var hbmCompositeId = hbmClass.CompositeId; hbmCompositeId.Items.Should().Have.Count.EqualTo(2); }
public void WhenComponentIdCustomizedMoreThanOnceThenMerge() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, For<Person>.Property(x => x.Id)); mapper.ComponentAsId(For<Person>.Property(x => x.Id), map => { map.Property(For<PersonId>.Property(x => x.Email), pm => { }); map.ManyToOne(For<PersonId>.Property(x => x.User), pm => { }); }); mapper.ComponentAsId(For<Person>.Property(x => x.Id), map => map.Access(Accessor.Field)); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Id.Should().Be.Null(); var hbmCompositeId = hbmClass.CompositeId; hbmCompositeId.Items.Should().Have.Count.EqualTo(2); hbmCompositeId.access.Should().Contain("field"); }
public void WhenClassWithComponentIdThenTheIdIsConpositeId() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, For<Person>.Property(x => x.Id)); mapper.ComponentAsId(For<Person>.Property(x => x.Id), map => { map.Property(For<PersonId>.Property(x => x.Email), pm => { }); map.ManyToOne(For<PersonId>.Property(x => x.User), pm => { }); }); var hbmClass = mapdoc.RootClasses[0]; hbmClass.Id.Should().Be.Null(); var hbmCompositeId = hbmClass.CompositeId; hbmCompositeId.Should().Not.Be.Null(); [email protected]().Not.Be.Null(); hbmCompositeId.Items.Should().Have.Count.EqualTo(2); hbmCompositeId.Items.Select(x => x.GetType()).Should().Have.SameValuesAs(typeof(HbmKeyProperty),typeof(HbmKeyManyToOne)); }
public void WhenClassWithComposedIdThenTheIdIsConpositeId() { var mapdoc = new HbmMapping(); var mapper = new ClassMapper(typeof(Person), mapdoc, null); mapper.ComposedId(map => { map.Property(For<Person>.Property(x => x.Email), pm => { }); map.ManyToOne(For<Person>.Property(x => x.User), pm => { }); }); var hbmClass = mapdoc.RootClasses[0]; Assert.That(hbmClass.Id, Is.Null); var hbmCompositeId = hbmClass.CompositeId; Assert.That(hbmCompositeId, Is.Not.Null); Assert.That(hbmCompositeId.@class, Is.Null); Assert.That(hbmCompositeId.Items, Has.Length.EqualTo(2)); Assert.That(hbmCompositeId.Items.Select(x => x.GetType()), Is.EquivalentTo(new [] {typeof(HbmKeyProperty), typeof(HbmKeyManyToOne)})); }
public void WhenSetSyncWithNullThenDoesNotThrows() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); rc.Executing(x=>x.Synchronize(null)).NotThrows(); }
public void WhenSetSyncWithNullThenDoesNotThrows() { var mapdoc = new HbmMapping(); var rc = new ClassMapper(typeof(EntitySimple), mapdoc, For<EntitySimple>.Property(x => x.Id)); Assert.That(() => rc.Synchronize(null), Throws.Nothing); }