public async Task C130_AllowMultipleMessages()
 {
     await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), new TestSub()).UseLoggerForAuditing()).AllowMultipleMessages().ReceiveAsync(new EventData {
         Subject = "X"
     }, new EventData {
         Subject = "X"
     });
 }
        public async Task A110_Unknown_Subject()
        {
            var ts = new TestSub();
            var ed = new EventData {
                Subject = "Other.Something", Action = "CREATE", Username = "******"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);

            Assert.IsFalse(ts.MessageReceived);
        }
        public async Task B120_Unknown_Action()
        {
            var ts = new TestSubS();
            var ed = new EventData <string> {
                Subject = "Test.Blah.123", Action = "OTHER", Username = "******", Value = "TEST"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);

            Assert.IsFalse(ts.MessageReceived);
        }
        public void C110_TooManySubjectSubscribers()
        {
            var ed = new EventData <string> {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******", Value = "TEST"
            };

            ExpectException.Throws <EventSubscriberException>(
                "There are 2 IEventSubscriber instances subscribing to Subject 'Test.Blah.123' and Action 'CREATE'; there must be only a single subscriber.",
                async() => await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), new TestSub(), new TestSubS()).UseLoggerForAuditing()).ReceiveAsync(ed));
        }
        public async Task A150_Receive_OK_ExceptionContinue()
        {
            var ts = new TestSub(@throw: true, unhandledExceptionHandling: UnhandledExceptionHandling.Continue);
            var ed = new EventData {
                Subject = "Test.Blah.123", Action = "UPDATE", Username = "******"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);

            Assert.IsTrue(ts.MessageReceived);
        }
Esempio n. 6
0
        public async Task A120_Unknown_Action()
        {
            var ts = new TestSub();
            var ed = new EventData {
                Subject = "Test.Blah.123", Action = "OTHER", Username = "******"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts)).ReceiveAsync(ed);

            Assert.IsFalse(ts.MessageReceived);
        }
        public async Task A130_Receive_OK_OriginatingUser()
        {
            var ts = new TestSub(RunAsUser.Originating);
            var ed = new EventData {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);

            Assert.IsTrue(ts.MessageReceived);
            Assert.AreEqual("TestUser", ts.Username);
        }
        public async Task B150_Receive_OK_ExceptionContinue()
        {
            var ts = new TestSubS(@throw: true, unhandledExceptionHandling: UnhandledExceptionHandling.Continue);
            var ed = new EventData <string> {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******", Value = "TEST"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);

            Assert.IsTrue(ts.MessageReceived);
            Assert.AreEqual("TEST", ts.Value);
            Assert.AreEqual(typeof(string), ts.ValueType);
        }
Esempio n. 9
0
        public async Task A140_Receive_OK_SystemUser()
        {
            EventSubscriberHost.SystemUsername = "******";
            var ts = new TestSub(RunAsUser.System);
            var ed = new EventData {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts)).ReceiveAsync(ed);

            Assert.IsTrue(ts.MessageReceived);
            Assert.AreEqual("SystemUser", ts.Username);
        }
Esempio n. 10
0
        public async Task B130_Receive_OK_OriginatingUser()
        {
            var ts = new TestSubS(RunAsUser.Originating);
            var ed = new EventData <string> {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******", Value = "TEST"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts)).ReceiveAsync(ed);

            Assert.IsTrue(ts.MessageReceived);
            Assert.AreEqual("TestUser", ts.Username);
            Assert.AreEqual("TEST", ts.Value);
            Assert.AreEqual(typeof(string), ts.ValueType);
        }
        public async Task B140_Receive_OK_SystemUser()
        {
            EventSubscriberHost.SystemUsername = "******";
            var ts = new TestSubS(RunAsUser.System);
            var ed = new EventData <string> {
                Subject = "Test.Blah.123", Action = "UPDATE", Username = "******", Value = "TEST"
            };
            await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);

            Assert.IsTrue(ts.MessageReceived);
            Assert.AreEqual("SystemUser", ts.Username);
            Assert.AreEqual("TEST", ts.Value);
            Assert.AreEqual(typeof(string), ts.ValueType);
        }
        public async Task A160_Receive_OK_ExceptionStop()
        {
            var ts = new TestSub(@throw: true, unhandledExceptionHandling: UnhandledExceptionHandling.Stop);
            var ed = new EventData {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******"
            };

            try
            {
                await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts).UseLoggerForAuditing()).ReceiveAsync(ed);
            }
            catch (DivideByZeroException)
            {
                Assert.IsTrue(ts.MessageReceived);
                return;
            }

            Assert.Fail();
        }
Esempio n. 13
0
        public async Task B160_Receive_OK_ExceptionStop()
        {
            var ts = new TestSubS(@throw: true, unhandledExceptionHandling: UnhandledExceptionHandling.Stop);
            var ed = new EventData <string> {
                Subject = "Test.Blah.123", Action = "CREATE", Username = "******", Value = "TEST"
            };

            try
            {
                await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), ts)).ReceiveAsync(ed);
            }
            catch (DivideByZeroException)
            {
                Assert.IsTrue(ts.MessageReceived);
                Assert.AreEqual("TEST", ts.Value);
                Assert.AreEqual(typeof(string), ts.ValueType);
                return;
            }

            Assert.Fail();
        }
 public void C120_DoNotAllowMultipleMessages()
 {
     ExpectException.Throws <EventSubscriberException>(
         "The EventDataSubscriberHost does not AllowMultipleMessages; there were 2 event messages.",
         async() => await EventDataSubscriberHost.Create(new EventSubscriberHostArgs(TestSetUp.CreateLogger(), new TestSub()).UseLoggerForAuditing()).ReceiveAsync(new EventData(), new EventData()));
 }