コード例 #1
0
        public async Task Should_properly_handle_activation()
        {
            ITupleSource <Member> leftSource = new TestTupleSource <Member>(new Tuple <Member>(new Member()
            {
                MemberId = 27, Name = "Frank"
            }));

            IFactSource <Address> rightSource = new TestFactSource <Address>();

            var testSink = new TestTupleSink <Address>();

            IBetaNode <Member, Address> betaNode = new JoinNode <Member, Address>(leftSource, rightSource,
                                                                                  new BetaCondition <Member, Address>((m, a) => true));

            betaNode.Connect(testSink);

            var sessionContext = new TestSession();
            var factContext    = new TestFactContext <Address>(sessionContext, new Address()
            {
                MemberId = 42, PostalCode = "68106"
            });

            await betaNode.Insert(factContext);

            Assert.That(testSink.Tuples.Count(), Is.EqualTo(1));
        }
コード例 #2
0
        public async Task Should_handle_inverse_activation()
        {
            ITupleSource <Member> leftSource = new TestTupleSource <Member>();

            IFactSource <Address> rightSource = new TestFactSource <Address>(
                new Address()
            {
                MemberId = 27, PostalCode = "68106"
            },
                new Address()
            {
                MemberId = 27, PostalCode = "74011"
            },
                new Address()
            {
                MemberId = 42, PostalCode = "74011"
            });

            var testSink = new TestTupleSink <Address>();

            IBetaNode <Member, Address> betaNode = new JoinNode <Member, Address>(leftSource, rightSource,
                                                                                  new BetaCondition <Member, Address>((m, a) => m.Right.MemberId == a.MemberId));

            betaNode.Connect(testSink);

            var sessionContext = new TestSession();
            var tupleContext   = new TestTupleContext <Member>(sessionContext, new Member {
                MemberId = 27, Name = "Frank"
            });

            await betaNode.Insert(tupleContext);

            Assert.That(testSink.Tuples.Count(), Is.EqualTo(2));
        }