public void Test_PubSubConfig_Validate()
        {
            // Arrange
            var config = new PubSubConfig();

            // Act and Assert - overlap here as it was an easier approach for this use-case.
            // Top level validation.
            Assert.Throws <ValidateException>(() => config.ThrowIfInvalid());
            config.ProjectId = "test";
            AssertExtensions.DoesNotThrow(() => config.ThrowIfInvalid());
            config.ToString().Contains("SenderInfo: [NOT SET]").Should().BeTrue();

            // Assert on the sender config validity.
            config.Sender = new SenderConfig();
            Assert.Throws <ValidateException>(() => config.ThrowIfInvalid());
            config.Sender.EntityName = "test";
            AssertExtensions.DoesNotThrow(() => config.ThrowIfInvalid());
            config.ProjectId = null;
            Assert.Throws <ValidateException>(() => config.ThrowIfInvalid());
            config.ProjectId = "test";
            AssertExtensions.DoesNotThrow(() => config.ThrowIfInvalid());
            config.ToString().Contains("SenderInfo: [NOT SET]").Should().BeFalse();

            // Assert on the receiverConfig config validity.
            config.ReceiverConfig = new ReceiverConfig();
            Assert.Throws <ValidateException>(() => config.ThrowIfInvalid());
            config.ReceiverConfig.EntityName = "test";
            AssertExtensions.DoesNotThrow(() => config.ThrowIfInvalid());
            config.ProjectId = null;
            Assert.Throws <ValidateException>(() => config.ThrowIfInvalid());
            config.ProjectId = "test";
            AssertExtensions.DoesNotThrow(() => config.ThrowIfInvalid());
            config.ToString().Contains("ReceiverInfo: [NOT SET]").Should().BeFalse();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PubSubMessenger"/> class.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="logger">The logger.</param>
        public PubSubMessenger([NotNull] PubSubConfig config, ILogger logger = null)
        {
            // Validate configuration and throw if invalid.
            config.ThrowIfInvalid();

            Config  = config;
            _logger = logger;

            Name = config.ProjectId;
        }