コード例 #1
0
		public void WhenRegisterSubclassWithNoRootThenThrows()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));

			Assert.That(() => inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Throws.TypeOf<MappingException>());
		}
コード例 #2
0
		public void WhenRegisterSubclassBeforeRootThenIsRegistered()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));

			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
		}
コード例 #3
0
		public void WhenRegisteredAsRootThenDoesNotRegisterTheStrategy()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
			inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
			inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
		}
コード例 #4
0
		public void WhenRegisteredSubclassThenTheStrategyIsDefinedEvenForRoot()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
			inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
			inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
			inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
		}
コード例 #5
0
		public void WhenRegisteredJoinedDeepSubclassThenTheStrategyIsDefinedEvenForRoot()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassEntity(typeof(Inherited2));
			Assert.That(inspector.IsTablePerClass(typeof(MyClass)), Is.True);
			Assert.That(inspector.IsTablePerClassHierarchy(typeof(MyClass)), Is.False);
			Assert.That(inspector.IsTablePerConcreteClass(typeof(MyClass)), Is.False);
		}
コード例 #6
0
		public void WhenRegisteredAsDeppJoinedSubclassThenIsRegistered()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassEntity(typeof(Inherited2));

			inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.True();
			inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False();
			inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
		}
コード例 #7
0
		public void WhenRegisteredAsJoinedSubclassThenIsRegistered()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassEntity(typeof(Inherited1));

			Assert.That(inspector.IsTablePerClass(typeof(Inherited1)), Is.True);
			Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited1)), Is.False);
			Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited1)), Is.False);
		}
コード例 #8
0
		public void WhenRegisteredAsComponetThenCantRegisterAsSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsComponent(typeof (MyComponent));

			Assert.That(() =>
			{
				inspector.AddAsTablePerClassHierarchyEntity(typeof (MyComponent));
				inspector.IsTablePerClassHierarchy(typeof (MyComponent));
			}, Throws.TypeOf<MappingException>());
		}
コード例 #9
0
		public void WhenRegisteredAsComponetThenCantRegisterAsSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsComponent(typeof (MyComponent));

			Executing.This(() =>
			               {
			               	inspector.AddAsTablePerClassHierarchyEntity(typeof (MyComponent));
			               	inspector.IsTablePerClassHierarchy(typeof (MyComponent));
			               }).Should().Throw<MappingException>();
		}
コード例 #10
0
		public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof (MyClass));
			inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1));

			Assert.That(() =>
			{
				inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1));
				inspector.IsTablePerClassHierarchy(typeof (Inherited1));
			}, Throws.TypeOf<MappingException>());
		}
コード例 #11
0
		public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof (MyClass));
			inspector.AddAsTablePerClassHierarchyEntity(typeof (Inherited1));

			Executing.This(() =>
			               {
			               	inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1));
			               	inspector.IsTablePerClassHierarchy(typeof (Inherited1));
			               }).Should().Throw<MappingException>();
		}
コード例 #12
0
 private bool MatchTablePerClass(System.Type type)
 {
     return(!declaredModel.IsTablePerClassHierarchy(type) && !declaredModel.IsTablePerConcreteClass(type));
 }