Esempio n. 1
0
        public void SegVsScenarioScenarioWins()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment("key1", "key1", "key1", "key1");
            cp1.PeriodType      = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime(2000, 1, 1);
            cp1.PeriodEndDate   = new DateTime(2000, 1, 2);

            cp2.AddScenario("key2", "key2", "key2", "key2");
            cp2.PeriodType      = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime(2000, 1, 1);
            cp2.PeriodEndDate   = new DateTime(2000, 1, 2);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // no segments before segments
            Assert.AreEqual(-1, CompareSegments(cuw1.contextRef.Segments, cuw2.contextRef.Segments), "segments are not equal");
            Assert.AreEqual(0, CompareDates(cuw1, cuw2), "dates are not equal");

            // no scenario before scenario
            Assert.AreEqual(-1, CompareScenarios(cuw2.contextRef.Scenarios, cuw1.contextRef.Scenarios), "scenario 1 sort wrong");

            Assert.AreEqual(-1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 2
0
        public void OneSegBeforeTwoScenarios()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddScenario("key11", "key11", "key11", "key11");
            cp1.AddScenario("key3", "key3", "key3", "key3");

            cp2.AddSegment("key1", "key1", "key1", "key1");

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // and compare them
            Assert.AreEqual(-1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 3
0
        private ContextProperty CreateDurationContextWithScenario(string id, string schema, string val, DateTime start, DateTime end)
        {
            ContextProperty cp = new ContextProperty();

            cp.ContextID       = id;
            cp.EntitySchema    = schema;
            cp.EntityValue     = val;
            cp.PeriodType      = Element.PeriodType.duration;
            cp.PeriodStartDate = start;
            cp.PeriodEndDate   = end;
            cp.AddScenario("og", "Audited", "rel", "http://www.StandardAdvantage.com/em/og/2004-12-28");
            return(cp);
        }
Esempio n. 4
0
        public void DurationScenarioBeforeNoSegNoScenarioInstant()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddScenario("key1", "key1", "key1", "key1");
            cp1.PeriodType      = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime(2000, 1, 1);
            cp1.PeriodEndDate   = new DateTime(2000, 1, 2);

            cp2.PeriodType      = Element.PeriodType.instant;
            cp2.PeriodStartDate = new DateTime(2000, 1, 1);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            Assert.AreEqual(1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(-1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 5
0
        public void BothHaveSegsAndScenariosCheckDates()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment("key1", "key1", "key1", "key1");
            cp1.AddScenario("key9", "key9", "key9", "key9");
            cp1.PeriodType      = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime(2000, 1, 1);
            cp1.PeriodEndDate   = new DateTime(2000, 1, 2);

            cp2.AddSegment("key1", "key1", "key1", "key1");
            cp2.AddScenario("key2", "key2", "key2", "key2");
            cp2.PeriodType      = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime(2000, 1, 1);
            cp2.PeriodEndDate   = new DateTime(2000, 1, 3);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // and compare them - no scen should be first
            Assert.AreEqual(-1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(1, Compare(cuw1, cuw2), "2 sort wrong");
        }