public void GivenItemWithRoute_WhenCreatedAndDetected_ShouldRouteAndUpdateIndex() { var item = new PlatformItem(); item.Route = new Route { RouteItems = new Collection <RouteItem> { new RouteItem { ModuleType = 1 }, new RouteItem { ModuleType = 3 }, new RouteItem { ModuleType = 4 } } }; ModuleA.SimulateNewItemCreated(item); item.Route.CurrentIndex.Should().Be(0); ModuleA.TestCurrentItemRoutings.Should().ContainValue(1, "port 1 is the path to ModuleC which is next in the route"); ModuleC.SimulateItemDetected(item); item.Route.CurrentIndex.Should().Be(1); ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "old routing task is fulfilled"); ModuleC.TestCurrentItemRoutings.Should().ContainValue(0, "port 0 is the path to ModuleD"); ModuleD.SimulateItemDetected(item); item.Route.CurrentIndex.Should().Be(2); ModuleC.TestCurrentItemRoutings.Should().HaveCount(0, "old routing task is fulfilled"); ModuleD.TestCurrentItemRoutings.Should().HaveCount(0, "item has no more route items"); }
private Ship AddModules(Ship ship, string[] modules) { foreach (string module in modules) { if (module == "A") { ship = new ModuleA(ship); } if (module == "B") { ship = new ModuleB(ship); } if (module == "C") { ship = new ModuleC(ship); } if (module == "D") { ship = new ModuleD(ship); } } return(ship); }