public static void Main(string[] args) { string content = "this is some content that will be processed by this crazy sample code to replace umlauts like ä, ö, ü"; int maxLineLength = 15; Console.WriteLine($"input = {content}"); // build up var timeProvider = new TransientTypeDependency<ITimeProvider, LocalLongTimeProvider>(); var kernel = new StandardKernel(); var featureModuleLoader = new FeatureLoader(kernel); featureModuleLoader.Load(new WorkflowFeature(timeProvider)); // run var appFactory = kernel.Get<WorkflowFeature.IWorkflowFactory>(); var workflow = appFactory.CreateWorkflow(); var processedContent = workflow.Process(content, maxLineLength); Console.WriteLine($"output = {processedContent}"); }
public void ProcessDocument( WorkflowFeature.IWorkflowFactory factory, string output) { const string Input = "some text to process with ä, Ö and ü to replace."; const int MaxLineLength = 10; const int ExtraCharactersInLine = 5; // brackets, space + \r\n "establish the document workflow feature"._(() => { var timeProvider = new TransientTypeDependency<ITimeProvider, FakeTimeProvider>(); var kernel = new StandardKernel(); var loader = new FeatureLoader(kernel); loader.Load(new WorkflowFeature(timeProvider)); factory = kernel.Get<WorkflowFeature.IWorkflowFactory>(); }); "when processing a document"._(() => output = factory.CreateWorkflow().Process(Input, MaxLineLength)); "it should replace all umlauts"._(() => output .Should().NotContain("ä") .And.NotContain("ö") .And.NotContain("ü")); "it should wrap lines"._(() => output.GetLines() .Should().OnlyContain(x => x.Length < MaxLineLength + FakeTimeProvider.FakeTime.Length + ExtraCharactersInLine)); "it should stamp each line with local time"._(() => output.GetLines() .Should().OnlyContain(x => x.StartsWith($"[{FakeTimeProvider.FakeTime}] "))); }