Beispiel #1
0
        public void CanSetFormula()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Formula("SomeFormula");
            mapping.formula.Should().Be("SomeFormula");
        }
Beispiel #2
0
        public void AfterSetMultiColumnsCantSetSimpleColumn()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)"));
            mapper.Executing(x => x.Column(cm => cm.Length(50))).Throws <ConfOrm.MappingException>();
        }
        public void CatSetForeignKey()
        {
            var hbm    = new HbmMapKeyManyToMany();
            var mapper = new MapKeyManyToManyMapper(hbm);

            mapper.ForeignKey("pizza");
            hbm.foreignkey.Should().Be("pizza");
        }
        public void CatSetColumnByName()
        {
            var hbm    = new HbmMapKeyManyToMany();
            var mapper = new MapKeyManyToManyMapper(hbm);

            mapper.Column("pizza");
            hbm.column.Should().Be("pizza");
        }
Beispiel #5
0
        public void SettingColumnOverridesFormula()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Formula("formula");
            mapper.Column(cm => cm.Unique(true));
            mapping.formula.Should().Be.Null();
        }
Beispiel #6
0
        public void WhenSetMultiColumnsValuesThenAutoassignColumnNames()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Columns(cm => cm.Length(50), cm => cm.SqlType("VARCHAR(10)"));
            mapping.Columns.Should().Have.Count.EqualTo(2);
            mapping.Columns.All(cm => cm.name.Satisfy(n => !string.IsNullOrEmpty(n)));
        }
Beispiel #7
0
        public void WhenSetFormulaWithNullThenDoNothing()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column("MyColumn");
            mapper.Formula(null);
            mapping.formula.Should().Be.Null();
            mapping.column.Should().Not.Be.Null();
        }
Beispiel #8
0
        public void WhenSetColumnNameThenSetTheName()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column(cm => cm.Name("pepe"));

            mapping.Columns.Should().Have.Count.EqualTo(1);
            mapping.Columns.Single().name.Should().Be("pepe");
        }
Beispiel #9
0
        public void WhenSetOnlyColumnNameThenNoAddColumnTag()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column("pizza");

            mapping.Items.Should().Be.Null();
            mapping.column.Should().Be("pizza");
        }
Beispiel #10
0
        public void SettingColumnPlainValuesOverridesFormula()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Formula("formula");
            mapper.Column("colName");
            mapping.formula.Should().Be.Null();
            mapping.column.Should().Be("colName");
        }
Beispiel #11
0
        public void SettingFormulaOverridesColumnNodes()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column(cm => cm.SqlType("VARCHAR(80)"));
            mapper.Formula("formula");
            mapping.formula.Should().Be("formula");
            mapping.column.Should().Be(null);
            mapping.Items.Should().Be.Null();
        }
Beispiel #12
0
        public void WhenSetFormulaThenResetColumn()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column("MyColumn");
            mapper.Formula("SomeFormula");
            mapping.formula.Should().Be("SomeFormula");
            mapping.column.Should().Be.Null();
            mapping.Items.Should().Be.Null();
        }
        public void CanSetMultipleFormulas()
        {
            var mapping = new HbmMapKeyManyToMany();
            IMapKeyManyToManyMapper mapper = new MapKeyManyToManyMapper(mapping);

            mapper.Formulas("formula1", "formula2", "formula3");

            Assert.That(mapping.formula, Is.Null);
            Assert.That(mapping.Items, Has.Length.EqualTo(3));
            Assert.That(
                mapping.Items.Cast <HbmFormula>().Select(f => f.Text.Single()),
                Is.EquivalentTo(new[] { "formula1", "formula2", "formula3" }));
        }
Beispiel #14
0
        public void WhenSetColumnValuesThenAddColumnTag()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column(cm =>
            {
                cm.SqlType("VARCHAR(50)");
                cm.NotNullable(true);
            });
            mapping.Items.Should().Not.Be.Null();
            mapping.Columns.Should().Have.Count.EqualTo(1);
        }
Beispiel #15
0
        public void WhenSetMultiColumnsValuesThenAddColumns()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Columns(cm =>
            {
                cm.Name("column1");
                cm.Length(50);
            }, cm =>
            {
                cm.Name("column2");
                cm.SqlType("VARCHAR(10)");
            });
            mapping.Columns.Should().Have.Count.EqualTo(2);
        }
Beispiel #16
0
        public void WhenSetFormulaWithMultipleLinesThenSetFormulaNode()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);
            var formula = @"Line1
Line2";

            mapper.Formula(formula);
            mapping.formula.Should().Be.Null();
            mapping.Items.FirstOrDefault().Should().Not.Be.Null().And.Be.OfType <HbmFormula>();
            var hbmFormula = (HbmFormula)(mapping.Items.First());

            hbmFormula.Text.Length.Should().Be(2);
            hbmFormula.Text[0].Should().Be("Line1");
            hbmFormula.Text[1].Should().Be("Line2");
        }
        public void CanSetColumnsAndFormulas()
        {
            var mapping = new HbmMapKeyManyToMany();
            IMapKeyManyToManyMapper mapper = new MapKeyManyToManyMapper(mapping);

            mapper.ColumnsAndFormulas(x => x.Name("pizza"), x => x.Formula("risotto"), x => x.Name("pasta"));

            Assert.That(mapping.Items, Has.Length.EqualTo(3));
            Assert.That(mapping.Items[0], Is.TypeOf <HbmColumn>(), "first");
            Assert.That(mapping.Items[1], Is.TypeOf <HbmFormula>(), "second");
            Assert.That(mapping.Items[2], Is.TypeOf <HbmColumn>(), "third");
            Assert.That(((HbmColumn)mapping.Items[0]).name, Is.EqualTo("pizza"));
            Assert.That(((HbmFormula)mapping.Items[1]).Text, Has.Length.EqualTo(1).And.One.EqualTo("risotto"));
            Assert.That(((HbmColumn)mapping.Items[2]).name, Is.EqualTo("pasta"));
            Assert.That(mapping.column, Is.Null, "column");
            Assert.That(mapping.formula, Is.Null, "formula");
        }
Beispiel #18
0
        public void WhenSetColumnValuesMoreThanOnesThenMergeColumn()
        {
            var mapping = new HbmMapKeyManyToMany();
            var mapper  = new MapKeyManyToManyMapper(mapping);

            mapper.Column("pepe");
            mapper.Column(cm => cm.Length(50));
            mapper.Column(cm => cm.NotNullable(true));

            mapping.Items.Should().Not.Be.Null();
            var hbmColumn = mapping.Items.OfType <HbmColumn>().First();

            hbmColumn.name.Should().Be("pepe");
            hbmColumn.length.Should().Be("50");
            hbmColumn.notnull.Should().Be(true);
            hbmColumn.notnullSpecified.Should().Be(true);
        }