Example #1
0
        public void GivenItemWithRoute_WhenTargetFull_ShouldNotRouteSingleItem()
        {
            ModuleB.LimitItemCount = 1;
            ModuleB.Entities.PlatformItems.Add(new PlatformItem {
                ItemId = 99
            });
            var item = new PlatformItem {
                ItemId = 1
            };

            item.Route = new Route
            {
                RouteItems = new Collection <RouteItem>
                {
                    new RouteItem {
                        ModuleType = 1
                    },
                    new RouteItem {
                        ModuleType = 2
                    },
                }
            };

            ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "must not route because target port is full");

            ModuleA.SimulateItemDetected(item);

            ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "must not route because target port is still full");
        }
Example #2
0
        public void GivenItemWithRoute_WhenTargetPortFull_ShouldNotRouteSingleItem()
        {
            ModuleB.SimulateIsFull(0);
            var item = new PlatformItem();

            item.Route = new Route
            {
                RouteItems = new Collection <RouteItem>
                {
                    new RouteItem {
                        ModuleType = 1
                    },
                    new RouteItem {
                        ModuleType = 2
                    },
                }
            };

            ModuleA.SimulateNewItemCreated(item);

            ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "must not route because target port is full");

            ModuleA.SimulateItemDetected(item);

            ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "must not route because target port is still full");
        }
Example #3
0
        public void GivenItemWithRoute_WhenDetectedPingPong_ShouldRouteAndUpdateIndex()
        {
            var item = new PlatformItem();

            item.Route = new Route
            {
                RouteItems = new Collection <RouteItem>
                {
                    new RouteItem {
                        ModuleType = 1
                    },
                    new RouteItem {
                        ModuleType = 2
                    },
                    new RouteItem {
                        ModuleType = 1
                    }
                }
            };

            ModuleA.SimulateNewItemCreated(item);
            item.Route.CurrentIndex.Should().Be(0);
            ModuleA.TestCurrentItemRoutings.Should().ContainValue(0, "port 0 is the path to ModuleB which is next in the route");

            ModuleB.SimulateItemDetected(item);
            item.Route.CurrentIndex.Should().Be(1);
            ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "old routing task is fulfilled");
            ModuleB.TestCurrentItemRoutings.Should().ContainValue(0, "port 0 is the path to ModuleA");

            ModuleA.SimulateItemDetected(item);
            item.Route.CurrentIndex.Should().Be(2);
            ModuleB.TestCurrentItemRoutings.Should().HaveCount(0, "old routing task is fulfilled");
            ModuleA.TestCurrentItemRoutings.Should().HaveCount(0, "item has no more route items");
        }
Example #4
0
        public void GivenModuleFullAndRouteAll_WhenNotFullAnymore_ShouldRouteAll()
        {
            var item = new PlatformItem();

            ModuleB.LimitItemCount = 1;
            ModuleB.Entities.PlatformItems.Add(item);
            ModuleBusManager.ForcePath(ModuleA, ModuleB, 0, 0);

            ModuleA.SimulateItemDetected(item);

            ModuleA.TestCurrentAllPortRoutings.Should().HaveCount(1);
        }
Example #5
0
        public void GivenItemInModule_WhenDetectedAgain_NothingHappens()
        {
            var item = new PlatformItem();

            ModuleA.Entities.PlatformItems.Add(item);
            ModuleA.MonitorEvents();

            // simulate a circulating buffer within ModuleA, where items detected multiple times
            ModuleA.SimulateItemDetected(item);
            ModuleA.SimulateItemDetected(item);

            ModuleA.Entities.PlatformItems.Count.Should().Be(1, "only one item is in ModuleA even if detected multiple times");
            ModuleA.ShouldNotRaise("CurrentItemCountChangedEvent");
        }
Example #6
0
        public void GivenItemWithRoute_GivenFull_WhenNotFullAnymore_ShouldRouteSingleItem()
        {
            var item = new PlatformItem {
                ItemId = 1
            };

            item.Route = CreateRoute();
            ModuleB.SimulateIsFull(0);
            ModuleA.SimulateNewItemCreated(item);
            ModuleA.SimulateItemDetected(item);

            ModuleA.TestCurrentItemRoutings.Should().BeEmpty();
            ModuleB.SimulateIsNotFull(0);
            ModuleA.SimulateItemDetected(item);

            ModuleA.TestCurrentItemRoutings.Should().HaveCount(1);
        }