Exemplo n.º 1
0
        /// <summary>
        /// A convenience method for creating an adapter for an outlet pair.
        /// This will automatically connect the adapter to the internal outlet and pass events between the adapter and external outlet.
        ///
        /// The external outlet should be the outlet the world can interact with, while the internal outlet is the corresponding outlet of
        /// our internal pipe system - the implementation of this pipe.
        /// </summary>
        protected IAdapterInlet <TMessage> CreateAndConnectAdapter <TMessage>(IOutlet <TMessage> internalOutlet, IOutlet <TMessage> externalOutlet)
        {
            var promisedPipe = new Promised <IPipe>();

            promisedPipe.Fulfill(this);

            var adapterInlet = new AdapterInlet <TMessage>(promisedPipe);

            SharedResource.ConnectTo(adapterInlet.SharedResource);

            adapterInlets.Add(adapterInlet);
            inletOutletBiLookup.Add(adapterInlet, externalOutlet);

            // Do not check if the graph forms a tree - it probably doesn't as all adapters are connected
            // to this pipe. However, messages should never be passed in a cycle or violate the "tree-ness" nevertheless.
            adapterInlet.ConnectTo(internalOutlet, false);
            return(adapterInlet);
        }
Exemplo n.º 2
0
        public void Add_CanAddASinglePair()
        {
            // Act
            biLookup.Add(1, "1");

            // Assert
            biLookup[1].Should().BeEquivalentTo("1");
            biLookup["1"].Should().BeEquivalentTo(1);
        }