Пример #1
0
        public async Task ShouldPublishRegistrationMessageOnRegister()
        {
            await RunTest(
                async (settings, connectionFactory, endpoint) =>
            {
                RabbitMq.Common.Connection.IInstance connection = A.Fake <RabbitMq.Common.Connection.IInstance>();

                A.CallTo(() => connectionFactory.Create(settings)).Returns(connection);

                await endpoint.Initialize();

                With.Component.IIdentity registrar      = new With.Component.Identity("registrar");
                With.Component.IIdentity entityIdentity = new With.Component.Identity("entity");
                With.Component.IEntity entity           = new With.Component.Entity(entityIdentity, null, null, null);

                IObserver <With.Message.IMessage> consumer = A.Fake <IObserver <With.Message.IMessage> >();

                endpoint.Register(registrar, entity, consumer);

                A.CallTo(() => connection.Publish(ExchangeName, "REGISTRATION.entity", A <With.Message.IMessage> .That.IsInstanceOf(typeof(With.Message.IRegister)))).MustHaveHappened(Repeated.Exactly.Once);
            }
                );
        }
Пример #2
0
        public async Task ShouldBindConsumerOnRegister()
        {
            await RunTest(
                async (settings, connectionFactory, endpoint) =>
            {
                RabbitMq.Common.Connection.IInstance connection = A.Fake <RabbitMq.Common.Connection.IInstance>();

                A.CallTo(() => connectionFactory.Create(settings)).Returns(connection);

                await endpoint.Initialize();

                With.Component.IIdentity registrar      = new With.Component.Identity("registrar");
                With.Component.IIdentity entityIdentity = new With.Component.Identity("entity");
                With.Component.IEntity entity           = new With.Component.Entity(entityIdentity, null, null, null);

                IObserver <With.Message.IMessage> consumer = A.Fake <IObserver <With.Message.IMessage> >();

                endpoint.Register(registrar, entity, consumer);

                A.CallTo(() => connection.BindConsumer("entity", consumer)).MustHaveHappened(Repeated.Exactly.Once);
            }
                );
        }