Exemple #1
0
        public void PublishAsync_Null_Message_Results_In_An_Exception()
        {
            var _busPublishersConsumersSeam = new BusPublishersConsumersSeamMock(PublicationResultStatus.Nacked);
            var _SUT = new PMCG.Messaging.Client.Bus(this.c_busConfiguration, _busPublishersConsumersSeam, this.c_connectionManager);

            _SUT.Connect();

            Assert.That(() => _SUT.PublishAsync <MyEvent>(null), Throws.TypeOf <ArgumentNullException>());
        }
Exemple #2
0
        public void PublishAsync_Valid_Acked()
        {
            var _busPublishersConsumersSeam = new BusPublishersConsumersSeamMock(PublicationResultStatus.Acked);
            var _SUT = new PMCG.Messaging.Client.Bus(this.c_busConfiguration, _busPublishersConsumersSeam, this.c_connectionManager);

            _SUT.Connect();
            var _message = new MyEvent(Guid.NewGuid(), "correlationid1", "detail", 1);

            var _result = _SUT.PublishAsync(_message);

            _result.Wait();

            Assert.AreEqual(TaskStatus.RanToCompletion, _result.Status);
            Assert.AreEqual(PMCG.Messaging.PublicationResultStatus.Published, _result.Result.Status);
        }
Exemple #3
0
        public void PublishAsync_Valid_Does_Publication_Configuration_Exists()
        {
            var _busConfigurationBuilder    = new BusConfigurationBuilder(TestingConfiguration.ConnectionSettingsString);
            var _busConfiguration           = _busConfigurationBuilder.Build();
            var _busPublishersConsumersSeam = new BusPublishersConsumersSeamMock(PublicationResultStatus.None);
            var _connectionManager          = Substitute.For <IConnectionManager>();

            _connectionManager.IsOpen.ReturnsForAnyArgs(true);
            var _SUT = new PMCG.Messaging.Client.Bus(_busConfiguration, _busPublishersConsumersSeam, _connectionManager);

            _SUT.Connect();
            var _message = new MyEvent(Guid.NewGuid(), "correlationid1", "detail", 1);

            var _result = _SUT.PublishAsync(_message);

            _result.Wait();

            Assert.AreEqual(TaskStatus.RanToCompletion, _result.Status);
            Assert.AreEqual(PMCG.Messaging.PublicationResultStatus.NoConfigurationFound, _result.Result.Status);
        }
Exemple #4
0
        public void PublishAsync_Where_Multiple_Publication_Configurations_Valid_Acked()
        {
            var _busConfigurationBuilder = new BusConfigurationBuilder(TestingConfiguration.ConnectionSettingsString);

            _busConfigurationBuilder.RegisterPublication <MyEvent>("", typeof(MyEvent).Name, MessageDeliveryMode.Persistent, message => "test.queue.1");
            _busConfigurationBuilder.RegisterPublication <MyEvent>("", typeof(MyEvent).Name, MessageDeliveryMode.Persistent, message => "test.queue.1");
            var _busConfiguration           = _busConfigurationBuilder.Build();
            var _busPublishersConsumersSeam = new BusPublishersConsumersSeamMock(PublicationResultStatus.Acked);
            var _SUT = new PMCG.Messaging.Client.Bus(_busConfiguration, _busPublishersConsumersSeam, this.c_connectionManager);

            _SUT.Connect();
            var _message = new MyEvent(Guid.NewGuid(), "correlationid1", "detail", 1);

            var _result = _SUT.PublishAsync(_message);

            _result.Wait();

            Assert.AreEqual(TaskStatus.RanToCompletion, _result.Status);
            Assert.AreEqual(PMCG.Messaging.PublicationResultStatus.Published, _result.Result.Status);
        }