Ejemplo n.º 1
0
        public void NavigationService_weighs_values()
        {
            RoomService roomService = NSubstitute.Substitute.For <RoomService>();
            FloorPlan   plan        = new FloorPlan(20, 20, fill: true);

            RoomPlan roomPlan = new RoomPlan
            {
                Name       = "Test",
                Width      = 5,
                Height     = 5,
                WallValue  = 20,
                FloorValue = 1,
                DoorTile   = new DoorTile(4, 2, cost: 3, notes: "Door")
            };
            IFloorRoom room = roomService.GenerateRoom(roomPlan);

            plan.AddRoom(room, new Location(3, 12));

            var display = plan.Print();

            Debug.WriteLine(display);

            NavigationService navService = NSubstitute.Substitute.For <NavigationService>(plan);
            var path = navService.FindPath(new Location(1, 1), new Location(5, 14));

            display = plan.Print(path);
            Debug.Write(display);
        }
        public void FloorPlan_displays_agents()
        {
            var plan = new FloorPlan();            //NSubstitute.Substitute.For<FloorPlan>();

            plan.FloorTiles.AddRange(_FillArea(3, 1));

            plan.AddAgent("Test Agent", new Agent().Move(new Location(1, 0)));
            string display = plan.Print();

            Debug.Write(display);
            display.ShouldBeEquivalentTo("+@+" + Environment.NewLine);
        }
        public void Agent_follows_path()
        {
            RoomService roomService = NSubstitute.Substitute.For <RoomService>();
            var         plan        = new FloorPlan(5, 4, fill: true);

            var agent = new Agent();            // NSubstitute.Substitute.For<Agent>();

            agent.Move(new Location(1, 1));
            plan.AddAgent("Test Agent", agent);

            NavigationService navService = NSubstitute.Substitute.For <NavigationService>(plan);

            agent.SetPath(navService.FindPath(agent.Point, new Location(3, 2)));

            var display = plan.Print(agent.Path);

            Debug.WriteLine(display);

            agent.Path.Count.ShouldBeEquivalentTo(3);

            display.ShouldBeEquivalentTo("+++++" + Environment.NewLine + "+@__+" + Environment.NewLine + "+_BC+"
                                         + Environment.NewLine + "+++++" + Environment.NewLine);

            agent.FollowPath(plan).Should().BeTrue();
            display = plan.Print(agent.Path);
            Debug.WriteLine(display);
            display.ShouldBeEquivalentTo("+++++" + Environment.NewLine + "+A__+" + Environment.NewLine + "+_@C+"
                                         + Environment.NewLine + "+++++" + Environment.NewLine);

            agent.FollowPath(plan).Should().BeTrue();
            display = plan.Print(agent.Path);
            Debug.WriteLine(display);
            display.ShouldBeEquivalentTo("+++++" + Environment.NewLine + "+A__+" + Environment.NewLine + "+_B@+"
                                         + Environment.NewLine + "+++++" + Environment.NewLine);

            agent.FollowPath(plan).Should().BeFalse();
        }
        public void FloorPlan_displays_paths()
        {
            var plan = new FloorPlan();

            plan.FloorTiles.AddRange(_FillArea(2, 2));

            var path = new List <Location>();

            path.Add(new Location(0, 0));
            path.Add(new Location(1, 1));
            string display = plan.Print(path);

            Debug.Write(display);
            display.ShouldBeEquivalentTo("A+" + Environment.NewLine + "+B" + Environment.NewLine);
        }
Ejemplo n.º 5
0
        public void NavigationService_works()
        {
            var plan = new FloorPlan();

            plan.FloorTiles.AddRange(_FillArea(20, 10, 1));
            plan.GetFloorTile(1, 0).Cost = 3;
            plan.GetFloorTile(0, 1).Cost = 2;
            plan.GetFloorTile(1, 1).Cost = 2;
            plan.GetFloorTile(1, 8).Cost = 3;
            plan.GetFloorTile(0, 8).Cost = 3;

            NavigationService service = NSubstitute.Substitute.For <NavigationService>(plan);
            var path = service.FindPath(new Location(0, 0), new Location(14, 8));

            Debug.Write(plan.Print(path));
        }
        public void FloorPlan_displays_costs()
        {
            var plan = new FloorPlan();

            plan.FloorTiles.Add(new FloorTile(0, 0));
            plan.FloorTiles.Add(new FloorTile(1, 0, cost: -1));
            plan.FloorTiles.Add(new FloorTile(2, 0, cost: 1));
            plan.FloorTiles.Add(new FloorTile(3, 0, cost: 2));
            plan.FloorTiles.Add(new FloorTile(4, 0, cost: 3));
            plan.FloorTiles.Add(new FloorTile(0, 1, cost: 4));
            plan.FloorTiles.Add(new FloorTile(2, 1, cost: 6));
            plan.FloorTiles.Add(new FloorTile(3, 1, cost: 99));
            plan.FloorTiles.Add(new FloorTile(1, 1, cost: 5));

            string display = plan.Print();

            Debug.Write(display);
            display.ShouldBeEquivalentTo("++_23" + Environment.NewLine + "456X+" + Environment.NewLine);
        }