public void EventsAreNotRedispatched() { EventNotifier notifier = new EventNotifier(); int callCount = 0; notifier.OnEvent <TestEvent>(evnt => ++ callCount); notifier.DispatchEvents(); Assert.Equal(0, callCount); notifier.Submit(TestEvent.Create()); notifier.DispatchEvents(); Assert.Equal(1, callCount); callCount = 0; notifier.DispatchEvents(); Assert.Equal(0, callCount); notifier.Submit(TestEvent.Create()); notifier.Submit(TestEvent.Create()); notifier.Submit(TestEvent.Create()); notifier.DispatchEvents(); Assert.Equal(3, callCount); callCount = 0; notifier.DispatchEvents(); Assert.Equal(0, callCount); }
static EventData[] CreateEvent(long number, string stream) { return(new[] { new EventData(Guid.NewGuid(), typeof(TestEvent).AssemblyQualifiedName, true, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(TestEvent.Create(number, stream))), null) }); }
public void should_Publish_Attribute() { var e = TestEvent.Create(1); this.Given(f => f.GivenInitEventPublisher()) .When(f => f.WhenPublish(e)) .Then(f => f.ThenSuccess()) .BDDfy(); }
private void WhenPublishList() { List <EventModel> models = new List <EventModel>(); for (int i = 0; i < 10; i++) { EventModel model = new EventModel(TestEvent.Create(i)); models.Add(model); } this.IsPublish = this.publisher.Publish(this.topic, models).GetAwaiter().GetResult(); }
private void should_Process_RetryNotice() { this.exchange += "Process_RetryNotice"; this.queue += "Process_RetryNotice"; EventModel model = new EventModel(TestEvent.Create(1)); this.consumeOptions.NoticeRetriesCount = 3; this.Given(f => f.GivenInitProcessorFailure()) .When(f => f.WhenSubscribe()) .When(f => f.WhenProcess(model)) .Then(f => f.ThenSuccess()) .BDDfy(); }
public void should_Subscribe_Normal() { this.exchange += "Subscribe_Normal"; this.queue += "Subscribe_Normal"; EventModel model = new EventModel(TestEvent.Create(1)); PublishMessage msg = new PublishMessage(model, this.serializer); this.Given(f => f.GivenInitProcessor()) .When(f => f.WhenSubscribe()) .When(f => f.WhenPublish(msg, 1)) .Then(f => f.ThenProcess(model)) .BDDfy(); }
public void should_Expand_Normal() { this.topic += "Expand"; this.exchange += "Expand"; EventModel model = new EventModel(TestEvent.Create(1)); PublishMessage msg = new PublishMessage(model, this.serializer); this.Given(f => f.GivenInitProcessor()) .When(f => f.WhenSubcribe()) .When(f => f.WhenPublish(msg, 5000)) .When(f => f.WhenMonitorConsumer()) .BDDfy(); }
public void should_GetAttributeOptions() { var e = TestEvent.Create(1); var options = MQPublisherExtensions.GetAttributeOptions(e.GetType()); Assert.NotNull(options); Assert.Equal(options.MQProvider, this.providerName); Assert.Equal(topic, options.Topic); var e1 = TestEvent1.Create(1); options = MQPublisherExtensions.GetAttributeOptions(e1.GetType()); Assert.Null(options); }
private void should_IsExpand_True() { this.exchange += "expand"; this.queue += "expand"; this.consumer = new RabbitConsumer(serviceProvider, FakeConfig.ProviderName, serializer); EventModel model = new EventModel(TestEvent.Create(1)); PublishMessage msg = new PublishMessage(model, this.serializer); this.Given(f => f.GivenInitProcessor()) .When(f => f.WhenSubscribe()) .When(f => f.WhenPublish(msg, 500)) .When(f => f.WhenIsExpand()) .Then(f => f.ThenSuccess()) .BDDfy(); }
public void EventsAreNotRedispatchedWithConcurrentDispatch() { EventNotifier notifier = new EventNotifier(); int callCount = 0; notifier.OnEvent <TestEvent>(evnt => { notifier.Submit(TestEvent.Create()); ++callCount; }); notifier.DispatchEvents(); Assert.Equal(0, callCount); notifier.Submit(TestEvent.Create()); notifier.DispatchEvents(); Assert.Equal(1, callCount); for (int i = 0; i < 20; ++i) { callCount = 0; notifier.DispatchEvents(); Assert.Equal(1, callCount); } notifier.Submit(TestEvent.Create()); notifier.Submit(TestEvent.Create()); notifier.Submit(TestEvent.Create()); for (int i = 0; i < 20; ++i) { callCount = 0; notifier.DispatchEvents(); Assert.Equal(4, callCount); } }
private void WhenPublishSingle() { EventModel model = new EventModel(TestEvent.Create(100)); this.IsPublish = this.publisher.Publish(this.topic, model).GetAwaiter().GetResult(); }