public void SC002RuleRuleWithSuccess(SC002PropertySchemaAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an source model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And the model has a migration target " .x(() => { TestHelper.CopySourceToTarget(model); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new SC002PropertySchemaAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then there should be no exception" .x(() => e.Should().BeNull()); "And there should be no context errors" .x(() => context.Errors.Should().HaveCount(0)); "And the routing properties should be set" .x(() => { model.Should().NotBeNull(); model.MigrationTarget.Should().NotBeNull(); model.MigrationTarget.MessageBus.Should().NotBeNull(); model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3); model.MigrationTarget.MessageBus.Applications[0].Messages.Should().HaveCount(3); model.MigrationTarget.MessageBus.Applications[0].Messages[0].Name = "Test.Schemas.DocumentSchema1"; model.MigrationTarget.MessageBus.Applications[0].Messages[0].RoutingProperties.Should().HaveCount(1); model.MigrationTarget.MessageBus.Applications[0].Messages[0].RoutingProperties.First().Key.Should().Be("Test.Schemas.PropertySchema1.Property1"); model.MigrationTarget.MessageBus.Applications[0].Messages[0].RoutingProperties.First().Value.Should().Be("some xpath 1"); model.MigrationTarget.MessageBus.Applications[0].Messages[1].Name = "Test.Schemas.DocumentSchema2"; model.MigrationTarget.MessageBus.Applications[0].Messages[1].RoutingProperties.Should().HaveCount(0); }); }
public void ConstructWithNullContext(SC002PropertySchemaAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And null context" .x(() => context.Should().BeNull()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing with a null context" .x(() => e = Record.Exception(() => new SC002PropertySchemaAnalyzer(model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("context")); }
public void ConstructWithSuccess(SC002PropertySchemaAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing" .x(() => e = Record.Exception(() => new SC002PropertySchemaAnalyzer(model, context, logger))); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); }
public void SC002RuleSkippedIfModelIsEmpty(SC002PropertySchemaAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an source model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new SC002PropertySchemaAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then there should be no exception" .x(() => e.Should().BeNull()); "And there should be no context errors" .x(() => context.Errors.Should().HaveCount(0)); }