public void WhenRegisteredAsEntityThenCantRegisterAsComponent()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyComponent));

			inspector.Executing(x => x.AddAsComponent(typeof(MyComponent))).Throws<MappingException>();
		}
		public void WhenRegisteredAsComponetThenCantRegisterAsRootEntity()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsComponent(typeof(MyComponent));

			Assert.That(() => inspector.AddAsRootEntity(typeof(MyComponent)), Throws.TypeOf<MappingException>());
		}
		public void WhenRegisteredAsSubclassThenIsEntity()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));

			Assert.That(inspector.IsEntity(typeof(Inherited1)), Is.True);
		}
		public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));

			inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
		}
		public void WhenRegisterUnionSubclassBeforeRootThenIsRegistered()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));

			inspector.AddAsRootEntity(typeof(MyClass));
			Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited1)), Is.True);
		}
		public void WhenRegisterSubclassBeforeRootThenIsRegistered()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));

			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
		}
		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();
		}
		public void WhenRegisteredAsJoinedSubclassThenIsEntity()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerClassEntity(typeof(Inherited1));

			inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
		}
		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();
		}
		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);
		}
		public void WhenRegisteredAsDeepUnionSubclassThenIsRegistered()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited2));

			Assert.That(inspector.IsTablePerClass(typeof(Inherited2)), Is.False);
			Assert.That(inspector.IsTablePerClassHierarchy(typeof(Inherited2)), Is.False);
			Assert.That(inspector.IsTablePerConcreteClass(typeof(Inherited2)), Is.True);
		}
		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();
		}
		public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsUnionSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof (MyClass));
			inspector.AddAsTablePerClassEntity(typeof (Inherited1));

			Assert.That(() =>
			{
				inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1));
				inspector.IsTablePerClass(typeof (Inherited1));
			}, Throws.TypeOf<MappingException>());
		}
		public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsUnionSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof (MyClass));
			inspector.AddAsTablePerClassEntity(typeof (Inherited1));

			Executing.This(() =>
			               {
			               	inspector.AddAsTablePerConcreteClassEntity(typeof (Inherited1));
			               	inspector.IsTablePerClass(typeof (Inherited1));
			               }).Should().Throw<MappingException>();
		}
		public void WhenRegisteredAsRootThenCantRegisterAsSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof (MyClass));
			Executing.This(() =>
			               {
			               	inspector.AddAsTablePerClassHierarchyEntity(typeof (MyClass));
			               	inspector.IsTablePerClassHierarchy(typeof (MyClass));
			               }).Should().Throw<MappingException>();
		}
		public void WhenRegisteredAsRootThenCantRegisterAsSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof (MyClass));
			Assert.That(() =>
			{
				inspector.AddAsTablePerClassHierarchyEntity(typeof (MyClass));
				inspector.IsTablePerClassHierarchy(typeof (MyClass));
			}, Throws.TypeOf<MappingException>());
		}
		public void WhenRegisteredAsRootThenIsEntity()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));

			Assert.That(inspector.IsEntity(typeof(MyClass)), Is.True);
		}
		public void WhenMultipleRootRegisteredThenThrowsMappingException()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsRootEntity(typeof(Inherited1));
			Assert.That(()=>
			{
				inspector.AddAsTablePerClassEntity(typeof(Inherited2));
				inspector.IsTablePerClass(typeof(Inherited2));
			}, Throws.TypeOf<MappingException>());
		}
		public void WhenRegisteredAsRootThenCantRegisterAsJoinedSubclass()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(MyClass))).Throws<MappingException>();
		}
		public void WhenMultipleRootRegisteredThenThrowsMappingException()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));
			inspector.AddAsRootEntity(typeof(Inherited1));
			Executing.This(()=>
			               {
			               	inspector.AddAsTablePerClassEntity(typeof(Inherited2));
											inspector.IsTablePerClass(typeof(Inherited2));
			               }).Should().Throw<MappingException>();
		}
		public void WhenRegisteredAsRootThenIsEntity()
		{
			var inspector = new ExplicitlyDeclaredModel();
			inspector.AddAsRootEntity(typeof(MyClass));

			inspector.IsEntity(typeof(MyClass)).Should().Be.True();
		}
Exemple #22
0
 void IModelExplicitDeclarationsHolder.AddAsRootEntity(System.Type type)
 {
     declaredModel.AddAsRootEntity(type);
 }