public void RenderSnippetAsyncWithMissingMessagingObjectWithWarning(ISnippetRenderer renderer, AzureIntegrationServicesModel model, ProcessManager processManager, ProcessManager missingProcessManager, TargetResourceTemplate resourceTemplate, TargetResourceSnippet resourceSnippet, WorkflowObject workflowObject, string snippetContent, string renderedContent, Exception e) { "Given a snippet renderer" .x(() => renderer = new LiquidSnippetRenderer(_mockLogger.Object)); "And a model" .x(() => model = _model); "And a missing process manager" .x(() => { missingProcessManager = new ProcessManager("MissingProcessManager") { Key = "MissingProcessManager" }; }); "And a workflow object" .x(() => { var messagingObject = model.FindMessagingObject("ContosoMessageBus:AppA:FtpTransformWorkflow"); messagingObject.messagingObject.Should().NotBeNull().And.BeOfType(typeof(ProcessManager)); processManager = (ProcessManager)messagingObject.messagingObject; resourceTemplate = processManager.Resources.First(); resourceSnippet = processManager.Snippets.First(); workflowObject = processManager.WorkflowModel.Activities.First(); }); "And a snippet content" .x(() => snippetContent = _missingProcessManagerSnippet); "When rendering the snippet" .x(async() => e = await Record.ExceptionAsync(async() => renderedContent = await renderer.RenderSnippetAsync(snippetContent, model, missingProcessManager, resourceTemplate, resourceSnippet, workflowObject))); "Then the render should succeed" .x(() => e.Should().BeNull()); "And the rendered content should not have expected values from the model" .x(() => { renderedContent.Should().NotBeNull().And.Be("").And.NotContainAny("{{").And.NotContainAny("}}"); // Verify warning was raised _mockLogger.Verify(l => l.Log( It.Is <LogLevel>(l => l == LogLevel.Warning), It.IsAny <EventId>(), It.Is <It.IsAnyType>((v, t) => v.ToString().Contains("does not appear in the target model", StringComparison.CurrentCultureIgnoreCase)), It.IsAny <Exception>(), It.Is <Func <It.IsAnyType, Exception, string> >((v, t) => true)), Times.Once); }); }
public void ConstructWithNullLogger(ISnippetRenderer renderer, ILogger logger, Exception e) { "Given a null renderer" .x(() => renderer.Should().BeNull()); "And a null logger" .x(() => logger.Should().BeNull()); "When constructing the renderer with null logger" .x(() => e = Record.Exception(() => new LiquidSnippetRenderer(logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("logger")); }
public void ConstructWithSuccess(ISnippetRenderer renderer, ILogger logger, Exception e) { "Given a null renderer" .x(() => renderer.Should().BeNull()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing the renderer" .x(() => e = Record.Exception(() => new LiquidSnippetRenderer(logger))); "Then the constructor should succeed" .x(() => e.Should().BeNull()); }
public void RenderSnippetAsyncWithSuccess(ISnippetRenderer renderer, AzureIntegrationServicesModel model, ProcessManager processManager, TargetResourceTemplate resourceTemplate, TargetResourceSnippet resourceSnippet, WorkflowObject workflowObject, string snippetContent, string renderedContent, Exception e) { "Given a snippet renderer" .x(() => renderer = new LiquidSnippetRenderer(_mockLogger.Object)); "And a model" .x(() => model = _model); "And a process manager" .x(() => { var messagingObject = model.FindMessagingObject("ContosoMessageBus:AppA:FtpTransformWorkflow"); messagingObject.messagingObject.Should().NotBeNull().And.BeOfType(typeof(ProcessManager)); processManager = (ProcessManager)messagingObject.messagingObject; resourceTemplate = processManager.Resources.First(); resourceSnippet = processManager.Snippets.First(); }); "And a workflow object" .x(() => { workflowObject = processManager.WorkflowModel.Activities.First(); }); "And a snippet content" .x(() => snippetContent = _snippetContent); "When rendering the snippet" .x(async() => e = await Record.ExceptionAsync(async() => renderedContent = await renderer.RenderSnippetAsync(snippetContent, model, processManager, resourceTemplate, resourceSnippet, workflowObject))); "Then the render should succeed" .x(() => e.Should().BeNull()); "And the rendered content should have expected values from the model" .x(() => { renderedContent.Should().NotBeNull().And.ContainAny($"StepName:_{workflowObject.Name.Replace(" ", "_", StringComparison.InvariantCulture)}").And.NotContainAny("{{").And.NotContainAny("}}"); }); }
public void RenderTemplateAsyncWithSnippetContentNullError(ISnippetRenderer renderer, AzureIntegrationServicesModel model, ProcessManager processManager, TargetResourceTemplate resourceTemplate, TargetResourceSnippet resourceSnippet, WorkflowObject workflowObject, string snippetContent, string renderedContent, Exception e) { "Given a snippet renderer" .x(() => renderer = new LiquidSnippetRenderer(_mockLogger.Object)); "And a model" .x(() => model = _model); "And a process manager" .x(() => { var messagingObject = model.FindMessagingObject("ContosoMessageBus:AppA:FtpTransformWorkflow"); messagingObject.messagingObject.Should().NotBeNull().And.BeOfType(typeof(ProcessManager)); processManager = (ProcessManager)messagingObject.messagingObject; resourceTemplate = processManager.Resources.First(); resourceSnippet = processManager.Snippets.First(); }); "And a workflow object" .x(() => { workflowObject = processManager.WorkflowModel.Activities.First(); }); "And null snippet content" .x(() => snippetContent = null); "When rendering the template" .x(async() => e = await Record.ExceptionAsync(async() => renderedContent = await renderer.RenderSnippetAsync(snippetContent, model, processManager, resourceTemplate, resourceSnippet, workflowObject))); "Then the render should error" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("snippetContent")); "And the rendered content should not have a value" .x(() => renderedContent.Should().BeNull()); }