Exemplo n.º 1
0
		public void CanSetTable()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Table("   Pizza   ");
			hbmJoin.table.Should().Be("Pizza");
		}
Exemplo n.º 2
0
		public void CanSetTable()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Table("   Pizza   ");
			Assert.That(hbmJoin.table, Is.EqualTo("Pizza"));
		}
Exemplo n.º 3
0
		public void WhenSetTableNameEmptyThenThrows()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			Assert.That(() => mapper.Table(null), Throws.TypeOf<ArgumentNullException>());
			Assert.That(() => mapper.Table(""), Throws.TypeOf<ArgumentOutOfRangeException>());
			Assert.That(() => mapper.Table("    "), Throws.TypeOf<ArgumentOutOfRangeException>());
		}
Exemplo n.º 4
0
		public void WhenSetTableNameEmptyThenThrows()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Executing(x => x.Table(null)).Throws<ArgumentNullException>();
			mapper.Executing(x => x.Table("")).Throws<ArgumentOutOfRangeException>();
			mapper.Executing(x => x.Table("    ")).Throws<ArgumentOutOfRangeException>();
		}
Exemplo n.º 5
0
        public void Join(string splitGroupId, Action <IJoinMapper> splitMapping)
        {
            IJoinMapper splitGroup;

            if (!JoinMappers.TryGetValue(splitGroupId, out splitGroup))
            {
                var hbmJoin = new HbmJoin();
                splitGroup = new JoinMapper(Container, splitGroupId, hbmJoin, MapDoc);
                JoinMappers.Add(splitGroupId, splitGroup);
                classMapping.join = ArrayHelper.Append(classMapping.join, hbmJoin);
            }

            splitMapping(splitGroup);
        }
Exemplo n.º 6
0
        public void Join(string splitGroupId, Action <IJoinMapper> splitMapping)
        {
            IJoinMapper splitGroup;

            if (!JoinMappers.TryGetValue(splitGroupId, out splitGroup))
            {
                var hbmJoin = new HbmJoin();
                splitGroup = new JoinMapper(Container, splitGroupId, hbmJoin, MapDoc);
                var toAdd = new[] { hbmJoin };
                JoinMappers.Add(splitGroupId, splitGroup);
                classMapping.join = classMapping.join == null ? toAdd : classMapping.join.Concat(toAdd).ToArray();
            }

            splitMapping(splitGroup);
        }
Exemplo n.º 7
0
		public void WhenTableNameChangesValueThenNotify()
		{
			bool eventCalled = false;
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.TableNameChanged += (m, x) =>
			                           {
																	 m.Should().Be.SameInstanceAs(mapper);
																	 x.OldName.Should().Be("AA");
																	 x.NewName.Should().Be("Pizza");
																	 eventCalled = true;
																 };
			mapper.Table("   Pizza   ");
			eventCalled.Should().Be.True();
		}
Exemplo n.º 8
0
		public void WhenTableNameChangesValueThenNotify()
		{
			bool eventCalled = false;
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.TableNameChanged += (m, x) =>
									   {
																	 Assert.That(m, Is.SameAs(mapper));
																	 Assert.That(x.OldName, Is.EqualTo("AA"));
																	 Assert.That(x.NewName, Is.EqualTo("Pizza"));
																	 eventCalled = true;
																 };
			mapper.Table("   Pizza   ");
			Assert.That(eventCalled, Is.True);
		}
Exemplo n.º 9
0
		public void WhenAddPropertyThenAddItem()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);

			mapper.Property(For<MyClass>.Property(mc => mc.Something), x => { });

			hbmJoin.Properties.Should().Have.Count.EqualTo(1);
		}
Exemplo n.º 10
0
		public void WhenCallKeyMapperMoreThanOnceThenKeyMapperIsTheSame()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			IKeyMapper firstCallInstance = null;
			IKeyMapper secondCallInstance= null;

			mapper.Key(km => firstCallInstance = km);
			mapper.Key(km => secondCallInstance = km);

			firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance);
		}
Exemplo n.º 11
0
		public void WhenCallKeyMapperThenKeyMapperIsNotNull()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);

			mapper.Key(km => km.Should().Not.Be.Null());
		}
Exemplo n.º 12
0
		public void CallKeyMapper()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			var keyMapperCalled = false;

			mapper.Key(km => keyMapperCalled = true);

			keyMapperCalled.Should().Be.True();
		}
Exemplo n.º 13
0
		public void WhenCallKeyMapperThenKeyMapperIsNotNull()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);

			mapper.Key(km => Assert.That(km, Is.Not.Null));
		}
Exemplo n.º 14
0
		public void CanSetSchema()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Schema("pizza");
			hbmJoin.schema.Should().Be("pizza");
		}
Exemplo n.º 15
0
		public void SetSqlDelete()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.SqlDelete("blah");

			Assert.That(hbmJoin.SqlDelete, Is.Not.Null);
			Assert.That(hbmJoin.SqlDelete.Text[0], Is.EqualTo("blah"));
		}
Exemplo n.º 16
0
		public void SetSqlDelete()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.SqlDelete("blah");

			hbmJoin.SqlDelete.Should().Not.Be.Null();
			hbmJoin.SqlDelete.Text[0].Should().Be("blah");
		}
Exemplo n.º 17
0
		public void CanSetSchema()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Schema("pizza");
			Assert.That(hbmJoin.schema, Is.EqualTo("pizza"));
		}
Exemplo n.º 18
0
		public void CanSetOptional()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Optional(true);
			Assert.That(hbmJoin.optional, Is.True);
		}
Exemplo n.º 19
0
		public void CanSetFetch()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Fetch(FetchKind.Select);
			Assert.That(hbmJoin.fetch, Is.EqualTo(HbmJoinFetch.Select));
		}
Exemplo n.º 20
0
		public void WhenAddPropertyThenAddItem()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);

			mapper.Property(For<MyClass>.Property(mc => mc.Something), x => { });

			Assert.That(hbmJoin.Properties.Count(), Is.EqualTo(1));
		}
Exemplo n.º 21
0
		public void CanSetInverse()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Inverse(true);
			Assert.That(hbmJoin.inverse, Is.True);
		}
Exemplo n.º 22
0
		public void CanSetInverse()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Inverse(true);
			hbmJoin.inverse.Should().Be.True();
		}
Exemplo n.º 23
0
		public void CanSetSqlSubselect()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Subselect("blah");

			Assert.That(hbmJoin.Subselect, Is.Not.Null);
			Assert.That(hbmJoin.subselect.Text[0], Is.EqualTo("blah"));
		}
Exemplo n.º 24
0
		public void CanSetOptional()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Optional(true);
			hbmJoin.optional.Should().Be.True();
		}
Exemplo n.º 25
0
		public void CanSetCatalog()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Catalog("pizza");
			hbmJoin.catalog.Should().Be("pizza");
		}
Exemplo n.º 26
0
		public void CanSetFetch()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Fetch(FetchKind.Select);
			hbmJoin.fetch.Should().Be(HbmJoinFetch.Select);
		}
Exemplo n.º 27
0
		public void CanSetSqlSubselect()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			mapper.Subselect("blah");

			hbmJoin.Subselect.Should().Not.Be.Null();
			hbmJoin.subselect.Text[0].Should().Be("blah");
		}
Exemplo n.º 28
0
		public void CallKeyMapper()
		{
			var mapdoc = new HbmMapping();
			var hbmJoin = new HbmJoin();
			var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
			var keyMapperCalled = false;

			mapper.Key(km => keyMapperCalled = true);

			Assert.That(keyMapperCalled, Is.True);
		}