コード例 #1
0
        public void ProcessorAdding()
        {
            var c1 = CreateSimpleCore();
            var c2 = CreateSimpleCore();
            var c3 = CreateSimpleCore();
            var c4 = CreateSimpleCore();

            connectNetwork(c1, c2, c3, c4);

            patchingAdding(c1, c2, c3, c4);

            var testInPort = new InPortBlock(1, createSimplePortFactory());

            c3.OutPorts.Connect(3, testInPort, 0);

            setData(c1, c2);

            coresTick(4, c1, c2, c3, c4);

            var packet = testInPort.DequeuePacket();

            Assert.NotNull(packet);
            Assert.AreEqual(0, packet.Label);
            Assert.AreEqual(15, packet.Data);
        }
コード例 #2
0
        public void InPortBlock()
        {
            var portFactory = new Mock <IPortFactory>();

            portFactory.Setup(t => t.CreateInputPort()).Returns(() => new InPort());
            portFactory.Setup(t => t.CreateOutputPort()).Returns(() => new OutPort());

            var inPortBlock  = new InPortBlock(2, portFactory.Object);
            var outPortBlock = new OutPortBlock(2, portFactory.Object);

            inPortBlock.Connect(0, outPortBlock, 1);

            var packet = Mock.Of <IPacket>();

            outPortBlock.Enqueue(1, packet);

            outPortBlock.Tick();

            Assert.AreEqual(1, inPortBlock.Count());
            Assert.AreEqual(packet, inPortBlock.DequeuePacket());
        }