public void ParseSchemasResourceDefinitionNotFound(DocumentSchemaParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForParsing(); var schema = model.FindResourceDefinitionByKey("test-app-1-container-key:document-schema-1", ModelConstants.ResourceDefinitionSchema); schema.Key = "a-key-that-will-not-be-found"; }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new DocumentSchemaParser(model, context, logger)); "When parsing" .x(() => e = Record.Exception(() => parser.Parse())); "Then the code should not throw an exception" .x(() => { // Parsing should be successful e.Should().BeNull(); // Check that there is an error in the context. context.Errors.Count.Should().Be(1); }); }
public void ParseSchemasHappyPath(DocumentSchemaParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForParsing(); var schema = model.FindResourceDefinitionByKey("test-app-1-container-key:document-schema-1", ModelConstants.ResourceDefinitionSchema); schema?.Resources.Clear(); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new DocumentSchemaParser(model, context, logger)); "When parsing" .x(() => e = Record.Exception(() => parser.Parse())); "Then the code should not throw an exception" .x(() => { // Parsing should be successful e.Should().BeNull(); // Check that the resources for the schema are created in the model. var schemaResourceDefinition = model.FindResourceDefinitionByKey("test-app-1-container-key:document-schema-1", ModelConstants.ResourceDefinitionSchema); schemaResourceDefinition.Resources.Count.Should().Be(1); // schema entry schemaResourceDefinition.Resources[0].Name.Should().Be("DocumentSchema1"); schemaResourceDefinition.Resources[0].Resources.Count.Should().Be(1); // message type var schemaResource = schemaResourceDefinition.Resources[0]; var schema = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Schemas[0]; schema.Resource.Should().Be(schemaResource); // The pointer to the resource should be set. schemaResource.ParentRefId.Should().Be(schemaResourceDefinition.RefId); // The parent ref ID should be set. schemaResource.SourceObject.Should().Be(schema); // The resource should have a pointer to the source object. }); }
public void ParseIsSkippedIfModelIsMissing(DocumentSchemaParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { "Given a model" .x(() => { model = new AzureIntegrationServicesModel(); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new DocumentSchemaParser(model, context, logger)); "When parsing" .x(() => e = Record.Exception(() => parser.Parse())); "Then the code should not throw an exception" .x(() => e.Should().BeNull()); }
public void ConstructWithSuccess(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given a parser" .x(() => parser.Should().BeNull()); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = new MigrationContext()); "When constructing" .x(() => e = Record.Exception(() => parser = new DocumentSchemaParser(model, context, logger))); "Then the parser constructor should succeed" .x(() => { e.Should().BeNull(); parser.Should().NotBeNull(); }); }