Beispiel #1
0
        public void C120_DoNotAllowMultipleMessages()
        {
            var sp = TestSetUp.CreateServiceProvider();

            ExpectException.Throws<EventSubscriberException>(
                "The 'EventDataSubscriberHost' does not AllowMultipleMessages; there were 2 event messages.",
                async () => await new EventDataSubscriberHost(EventSubscriberHostArgs.Create(typeof(TestSub)).UseServiceProvider(sp).UseLoggerForAuditing()).ReceiveAsync(new EventData(), new EventData()));
        }
Beispiel #2
0
        public void Ctor_NoIEventSubscriber()
        {
            var sp = TestSetUp.CreateServiceProvider();

            ExpectException.Throws <ArgumentException>("*", () => EventSubscriberHostArgs.Create(sp));
            ExpectException.Throws <ArgumentException>("*", () => EventSubscriberHostArgs.Create(sp, (Type[])null));
            ExpectException.Throws <ArgumentException>("*", () => EventSubscriberHostArgs.Create(sp, new Type[] { }));
        }
Beispiel #3
0
        public void C110_TooManySubjectSubscribers()
        {
            var ed = new EventData<string> { Subject = "Test.Blah.123", Action = "CREATE", Username = "******", Value = "TEST" };
            var sp = TestSetUp.CreateServiceProvider();

            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 new EventDataSubscriberHost(EventSubscriberHostArgs.Create(typeof(TestSub), typeof(TestSubS)).UseServiceProvider(sp).UseLoggerForAuditing()).ReceiveAsync(ed));
        }
Beispiel #4
0
        public async Task C130_AllowMultipleMessages()
        {
            var sp = TestSetUp.CreateServiceProvider();

            await new EventDataSubscriberHost(EventSubscriberHostArgs.Create(sp, typeof(TestSub)).UseLoggerForAuditing()).AllowMultipleMessages().ReceiveAsync(new EventData {
                Subject = "X"
            }, new EventData {
                Subject = "X"
            });
        }
Beispiel #5
0
 private EventDataSubscriberHost CreateTestHost<T>(Func<T> create) where T : class
 {
     var sp = TestSetUp.CreateServiceProvider(sc => sc.AddTransient(_ => create()));
     return new EventDataSubscriberHost(EventSubscriberHostArgs.Create(typeof(T)).UseServiceProvider(sp).UseLoggerForAuditing());
 }
Beispiel #6
0
        public void Ctor_NoSubscribersInAssembly()
        {
            var sp = TestSetUp.CreateServiceProvider();

            ExpectException.Throws <ArgumentException>("*", () => EventSubscriberHostArgs.Create(sp, typeof(TestAttribute).Assembly));
        }