コード例 #1
0
        public void TestSimpleAutoColumn()
        {
            var property1 = "zip";
            var property2 = "location";

            var mofObject = new MofObject();
            mofObject.set(property1, "55130");
            mofObject.set(property2, "Mainz");

            var mofObject2 = new MofObject();
            mofObject2.set(property1, "65474");
            mofObject2.set(property2, "Bischofsheim");

            var extent = new MofUriExtent("datenmeister:///test");
            extent.elements().add(mofObject);
            extent.elements().add(mofObject2);
            var creator = new ColumnCreator(null, null, null);
            var result = creator.FindColumnsForTable(extent);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Columns.Count(), Is.EqualTo(2));
            var firstColumn = result.Columns.FirstOrDefault(x => x.name == "zip");
            var secondColumn = result.Columns.FirstOrDefault(x => x.name == "location");

            Assert.That(firstColumn, Is.Not.Null);
            Assert.That(secondColumn, Is.Not.Null);

            Assert.That(firstColumn.isEnumeration, Is.False);

            Assert.That(result.Properties.Count, Is.EqualTo(2));
            Assert.That(result.Properties[0], Is.EqualTo("zip"));
            Assert.That(result.Properties[1], Is.EqualTo("location"));
        }
コード例 #2
0
        public void TestMultiplePropertyFilter()
        {
            var properties = new[] { property1, property2 };

            var mofObject = new MofObject();
            mofObject.set(property1, "55130");
            mofObject.set(property2, "Mainz");

            var mofObject2 = new MofObject();
            mofObject2.set(property1, "65474");
            mofObject2.set(property2, "Bischofsheim");

            var mofObject3 = new MofObject();

            var mofExtent = new MofUriExtent("datenmeister:///");
            Assert.That(mofExtent.elements().add(mofObject), Is.True);
            Assert.That(mofExtent.elements().add(mofObject2), Is.True);
            Assert.That(mofExtent.elements().add(mofObject3), Is.True);

            var result = Filter.WhenOneOfThePropertyContains(
                mofExtent.elements(),
                properties,
                "Mai");

            Assert.That(result.size(), Is.EqualTo(1));
            Assert.That(result.ElementAt(0), Is.EqualTo(mofObject));

            result = Filter.WhenOneOfThePropertyContains(
                mofExtent.elements(),
                properties,
                "55130");

            Assert.That(result.size(), Is.EqualTo(1));
            Assert.That(result.ElementAt(0), Is.EqualTo(mofObject));

            result = Filter.WhenOneOfThePropertyContains(
                mofExtent.elements(),
                properties,
                "Bisch");

            Assert.That(result.size(), Is.EqualTo(1));
            Assert.That(result.ElementAt(0), Is.EqualTo(mofObject2));

            result = Filter.WhenOneOfThePropertyContains(
                mofExtent.elements(),
                properties,
                "xyz");

            Assert.That(result.size(), Is.EqualTo(0));

            result = Filter.WhenOneOfThePropertyContains(
                mofExtent.elements(),
                properties,
                "i");

            Assert.That(result.size(), Is.EqualTo(2));
            Assert.That(result.Contains(mofObject), Is.True);
            Assert.That(result.Contains(mofObject2), Is.True);
        }
コード例 #3
0
        public void TestInMemoryMofObject()
        {
            var mofObject = new MofObject();
            Assert.That(mofObject.isSet(property1), Is.False);
            mofObject.set(property1, "Test");
            mofObject.set(property2, property1);

            Assert.That(mofObject.isSet(property1),Is.True);
            Assert.That(mofObject.isSet(property2),Is.True);

            Assert.That(mofObject.get(property1).ToString(), Is.EqualTo("Test"));
            Assert.That(mofObject.get(property2), Is.EqualTo(property1));
        }
コード例 #4
0
        public void TestEnumerationAutoColumn()
        {
            var property1 = "zip";
            var property2 = "location";
            var property3 = "other";

            var mofObject = new MofObject();
            mofObject.set(property1, "55130");
            mofObject.set(property2, "Mainz");

            var mofObject2 = new MofObject();
            mofObject2.set(property1, "65474");
            mofObject2.set(property2, "Bischofsheim");

            var enumeration = new MofReflectiveSequence();
            enumeration.add(new MofObject());
            mofObject2.set(property3, enumeration);

            var extent = new MofUriExtent("datenmeister:///test");
            extent.elements().add(mofObject);
            extent.elements().add(mofObject2);

            // Execute the stuff
            var creator = new ColumnCreator(null, null, null);
            var result = creator.FindColumnsForTable(extent);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Columns.Count(), Is.EqualTo(3));
            var firstColumn = result.Columns.FirstOrDefault(x => x.name == "zip");
            var secondColumn = result.Columns.FirstOrDefault(x => x.name == "location");
            var thirdColumn = result.Columns.FirstOrDefault(x => x.name == "other");

            Assert.That(firstColumn, Is.Not.Null);
            Assert.That(secondColumn, Is.Not.Null);

            Assert.That(firstColumn.isEnumeration, Is.False);
            Assert.That(secondColumn.isEnumeration, Is.False);
            Assert.That(thirdColumn.isEnumeration, Is.True);
        }
コード例 #5
0
        private MofReflectiveSequence CreateReflectiveSequence()
        {
            var reflectiveSequence = new MofReflectiveSequence();

            var value = new MofObject();
            value.set(property1, 3);
            value.set(property3, "A"); // A = 3
            reflectiveSequence.add(value);

            value = new MofObject();
            value.set(property1, 1);
            value.set(property3, "B"); // A = 3, B = 1
            reflectiveSequence.add(value);

            value = new MofObject();
            value.set(property1, 2);
            value.set(property3, "A"); // A = 5, B = 1
            reflectiveSequence.add(value);

            value = new MofObject();
            value.set(property1, 3);
            value.set(property3, "B"); // A = 5, B = 4
            reflectiveSequence.add(value);

            value = new MofObject();
            value.set(property1, 4);
            value.set(property2, 4);
            value.set(property3, "A"); // A = 9, B = 4
            reflectiveSequence.add(value);

            value = new MofObject();
            value.set(property2, 3);
            reflectiveSequence.add(value);
            return reflectiveSequence;
        }