Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
0
        public void GivenItemCreatedInModuleA_WhenDetectedInModuleB_ShouldMoveItem()
        {
            var item = new PlatformItem();

            ModuleA.SimulateNewItemCreated(item);

            ModuleB.SimulateItemDetected(item);

            ModuleA.Entities.PlatformItems.Count.Should().Be(0, "item is now in ModuleB and cannot exist in ModuleA at the same time");
            ModuleB.Entities.PlatformItems.Contains(item).Should().BeTrue("item was detected in ModuleB");
        }
Ejemplo n.º 4
0
        public void GivenItemWithRouteAndAlreadyCreated_WhenDetected_ShouldUpdateRoute()
        {
            var item = new PlatformItem {
                ItemId = 1
            };

            item.Route = CreateRoute();
            ModuleA.SimulateNewItemCreated(item);

            ModuleB.SimulateItemDetected(item);

            var route = ModuleB.Entities.PlatformItems.First().Route;

            route.Should().NotBeNull();
            route.CurrentIndex.Should().Be(1);
        }
Ejemplo n.º 5
0
        public void GivenItemAlreadyCreated_WhenDetectedAgain_ShouldMoveShirt()
        {
            var item = new PlatformItem {
                ItemId = 1
            };

            ModuleA.SimulateNewItemCreated(item);

            ModuleB.SimulateItemDetected(new PlatformItem {
                ItemId = 1
            });

            ModuleA.Entities.PlatformItems.Should().HaveCount(0);
            ModuleB.ContainsItem(item.ItemId).Should().BeTrue();
            ModuleB.Entities.PlatformItems.First().Should().BeSameAs(item);
        }
Ejemplo n.º 6
0
        public void GivenItemAlreadyCreated_WhenDetectCreatedAgain_ShouldLogWarnAndRemoveOldItem()
        {
            var item = new PlatformItem {
                Id = 1, ItemId = 1
            };

            ModuleA.SimulateNewItemCreated(item);

            ModuleB.SimulateNewItemCreated(new PlatformItem {
                ItemId = 1
            });

            Logger.Verify(l => l.Warn(It.IsAny <string>()), Times.AtLeastOnce);
            ModuleA.Entities.PlatformItems.Should().HaveCount(0);
            ModuleB.Entities.PlatformItems.Should().HaveCount(1);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public void GivenItemWithRoute_WhenDetectedInWrongModule_ShouldNotUpdateIndexAndRouteBack()
        {
            var item = new PlatformItem();

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

            ModuleA.SimulateNewItemCreated(item);
            ModuleB.SimulateItemDetected(item);    // item detected in wrong module!

            ModuleB.TestCurrentItemRoutings.Should().ContainValue(0, "item was detected in wrong module and should go back to ModuleA");
            item.Route.CurrentIndex.Should().Be(0, "item has still to visit ModuleC");
        }
Ejemplo n.º 9
0
        public void WhenNewItemCreated_ShouldAddItemToModule()
        {
            ModuleA.SimulateNewItemCreated(new PlatformItem());

            ModuleA.Entities.PlatformItems.Count.Should().Be(1);
        }