Esempio n. 1
0
        public void Behaviour_should_also_work_with_method_calls()
        {
            var SUT = new YakShayBus();
            SUT.RegisterType<SomeTestClass>();
            var resultingMessages = new List<Message>();
            var msg = new
            {
                SomePartOfTheUID = "A",
                AnotherPartOfTheUID = "B",
                SomeFlag = true,
                SomeString = "ABC"
            };

            SUT.Handle(
                Message.FromAction(x => x.MethodToInvoke(SomePartOfTheUID: "A", AnotherPartOfTheUID: "B", SomeFlag: true, SomeString: "ABC"))
                , x => resultingMessages.Add(x));

            resultingMessages.Count.ShouldBe(1);
            resultingMessages.First().ToFriendlyString().ShouldBe(new Message("OnMethodWasInvoked", new
            {
                SomePartOfTheUID = "A",
                AnotherPartOfTheUID = "B",
                SomeString = "ABC",
                AnotherInt = 123
            }).ToFriendlyString());
        }
Esempio n. 2
0
        public void Invoking_a_message_that_does_not_have_the_unique_ids_should_not_generate_events()
        {
            var SUT = new YakShayBus();
            SUT.RegisterType<SomeTestClass>();
            var resultingMessages = new List<Message>();
            var msg = new Message("MethodToInvoke", new
            {
                NotPartOfTheKey = "A",
                AnotherPartOfTheUID = "B",
                SomeFlag = true,
                SomeString = "ABC"
            });

            SUT.Handle(msg, x => resultingMessages.Add(x));

            resultingMessages.ShouldBeEmpty();
        }
Esempio n. 3
0
        public void Message_should_get_processed_and_generate_a_single_InterceptThis_message_with_the_correct_parameters()
        {
            var SUT = new YakShayBus();
            SUT.RegisterType<SomeTestClass>();
            var ms = new MessageStore();
            var msg = new Message("MethodToInvoke", new
            {
                SomePartOfTheUID = "A",
                AnotherPartOfTheUID = "B",
                SomeFlag = true,
                SomeString = "ABC"
            });

            SUT.Handle(msg, ms.Add);

            ms.msgs.Count.ShouldBe(1);
            ms.msgs.First().ToFriendlyString().ShouldBe(new Message("OnMethodWasInvoked", new
            {
                SomePartOfTheUID = "A",
                AnotherPartOfTheUID = "B",
                SomeString = "ABC",
                AnotherInt = 123
            }).ToFriendlyString());

            var ArInstance = new SomeTestClass { SomePartOfTheUID = "A", AnotherPartOfTheUID = "B" };
            var AnotherArInstance = new SomeTestClass { SomePartOfTheUID = "X", AnotherPartOfTheUID = "Y" };
            SUT.ApplyHistory(ArInstance, ms.Filter);
            SUT.ApplyHistory(AnotherArInstance, ms.Filter);

            ArInstance.HasMethodBeenCalled.ShouldBe(true);
            AnotherArInstance.HasMethodBeenCalled.ShouldBe(false);
        }