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(); }
public void Test_PubSubConfig_ToStringFunctionalityNotSet() { // Arrange var config = new PubSubConfig { ProjectId = "12345", ReceiverConfig = new ReceiverConfig { EntityName = "entityName", EntitySubscriptionName = "subscriptionName", CreateEntityIfNotExists = true, EntityFilter = new KeyValuePair <string, string>("testkey", "testfilter"), ProjectId = "12345", ReadFromErrorEntity = true }, Sender = new SenderConfig { EntityName = "entityName", CreateEntityIfNotExists = true, ProjectId = "12345" } }; // Act var str = config.ToString(); // Assert str.Should().Be("ProjectId:12345, ReceiverInfo: EntityName: entityName, EntityDeadLetterName: entityName_deadletter, " + "EntitySubscriptionName: subscriptionName, EntityDeadLetterSubscriptionName: entityName_deadletter_default, " + "EntityFilter: [testkey, testfilter], CreateEntityIfNotExists: True, ReadFromErrorEntity: True, SenderInfo: EntityName: entityName, " + "EntityDeadLetterName: entityName_deadletter, CreateEntityIfNotExists: True"); }
public void Test_PubSubEntityConfig_ToStringFunctionalityNotSet() { // Arrange var config = new PubSubConfig() { ProjectId = "12345" }; // Act var str = config.ToString(); // Assert str.Should().Be("ProjectId:12345, ReceiverInfo: [NOT SET], SenderInfo: [NOT SET]"); }