コード例 #1
0
        public void RemoveReceptorInstance()
        {
            callSuccess = false;
            IReceptor         receptor = new TestReceptor();
            SemanticProcessor sp       = new SemanticProcessor();

            sp.Register <TestMembrane>(receptor);
            sp.RemoveTypeNotify <TestMembrane, TestSemanticType>(receptor);
            sp.ProcessInstance <TestMembrane, TestSemanticType>(true);
            Assert.That(!callSuccess, "Expected TestReceptor.Process to NOT be called.");
        }
コード例 #2
0
        public void UnitTests()
        {
            var signal   = new TestSignalMatch();
            var receptor = new TestReceptor();

            receptor.OnSignal(signal);
            Assert.AreEqual(1, receptor.matchCount);

            var signalNoMatch = new TestSignalNoMatch();

            receptor.OnSignal(signalNoMatch);
            Assert.AreEqual(1, receptor.matchCount);
        }
コード例 #3
0
        public void ReceptorInitialization()
        {
            receptorInitializerCalled = false;
            SemanticProcessor sp = new SemanticProcessor();

            sp.Register <TestMembrane, TestReceptor>((ir) =>
            {
                // Unfortunately, a cast is required, because ir is type declared as IReceptor
                // and I don't think it's possible to fix that because of the late callback.
                TestReceptor r            = (TestReceptor)ir;
                r.AFlag                   = true;
                receptorInitializerCalled = true;
            });
            sp.ProcessInstance <TestMembrane, TestSemanticType>(true);
            Assert.That(receptorInitializerCalled, "Expected TestReceptor initializer to be called to be called.");
        }