예제 #1
0
        public void AssertThat_IdRef_FindsSingleMatch_SearchingDownFromFloorWithSameIdAsSearchId()
        {
            IdRef i = new IdRef("u1", SearchDirection.Down, RefFilter.All, false, false);

            var matches = i.Match(_floors, -1);

            Assert.AreEqual(1, matches.Count());
        }
예제 #2
0
        public void AssertThat_IdRef_FindsNothing_SearchingDownFromFloorBelow()
        {
            IdRef i = new IdRef("d", SearchDirection.Down, RefFilter.All, false, false);

            var matches = i.Match(_floors, 5);

            Assert.AreEqual(0, matches.Count());
        }
예제 #3
0
        public void AssertThat_IdRef_DoesNotFindFloorWithGivenId_SearchingUpFromFloorAbove()
        {
            IdRef i = new IdRef("d", SearchDirection.Up, RefFilter.All, false, false);

            var matches = i.Match(_floors, 7);

            Assert.AreEqual(0, matches.Count());
        }
예제 #4
0
        public void AssertThat_IdRef_FindsFloorWithGivenId_SearchingUpFromFloorBelow()
        {
            IdRef i = new IdRef("d", SearchDirection.Up, RefFilter.All, false, false);

            var matches = i.Match(_floors, 5);

            Assert.AreEqual(1, matches.Count());
            Assert.AreEqual(_floors[6], matches.Single());
        }
예제 #5
0
        public void AssertThat_IdRef_FindsHightestFloorFirst_SearchingDown()
        {
            IdRef i = new IdRef("g", SearchDirection.Down, RefFilter.All, false, false);

            var matches = i.Match(_floors, 12).ToArray();

            Assert.AreEqual(3, matches.Count());
            Assert.AreEqual(3, matches[0].Index);
            Assert.AreEqual(2, matches[1].Index);
            Assert.AreEqual(1, matches[2].Index);
        }
예제 #6
0
        public void AssertThat_IdRef_FindsLowestFloorFirst_SearchingUp()
        {
            IdRef i = new IdRef("a", SearchDirection.Up, RefFilter.All, false, false);

            var matches = i.Match(_floors, 0).ToArray();

            Assert.AreEqual(3, matches.Count());
            Assert.AreEqual(9, matches[0].Index);
            Assert.AreEqual(10, matches[1].Index);
            Assert.AreEqual(11, matches[2].Index);
        }
예제 #7
0
        public void AssertThat_BaseRef_SelectsFirstSections_WhenFilterFirstIsSpecified()
        {
            IdRef bot = new IdRef("skylobby", SearchDirection.Up, RefFilter.All, false, false);
            IdRef top = new IdRef("skylobby", SearchDirection.Up, RefFilter.First, false, false);

            var b       = bot.Match(_floors, null).ToArray();
            var matched = top.MatchFrom(_floors, bot, b).ToArray();

            Assert.AreEqual(2, matched.Count());
            Assert.IsTrue(matched.Any(a => a.Key.Index == 4 && a.Value.Index == 8));
            Assert.IsTrue(matched.Any(a => a.Key.Index == 8 && a.Value.Index == 12));
        }
예제 #8
0
        public void AssertThat_BaseRef_MatchFrom_SelectsNonOverlappingSections_WhenNonOverlappingModeIsSpecified()
        {
            IdRef residential = new IdRef("residential", SearchDirection.Up, RefFilter.All, false, false);
            IdRef skylobby    = new IdRef("skylobby", SearchDirection.Up, RefFilter.First, true, false);

            var res     = residential.Match(_floors, null).ToArray();
            var matched = skylobby.MatchFrom(_floors, residential, res).ToArray();

            //We should have matched all the residential floors, paired with the next skylobby up
            //Then filtered these floors into groups which overlap, and take the first (i.e. lowest floor to next skylobby)
            Assert.AreEqual(3, matched.Count());
            Assert.IsTrue(matched.Any(a => a.Key.Index == 1 && a.Value.Index == 4));
            Assert.IsTrue(matched.Any(a => a.Key.Index == 5 && a.Value.Index == 8));
            Assert.IsTrue(matched.Any(a => a.Key.Index == 9 && a.Value.Index == 12));
        }