public void RegisterUnit_RegisterSameUnitTwice_ArgumentException() { var eventBus = new WebParser <ParsingResult>(); var exception = Assert.ThrowsException <ArgumentException>(() => { eventBus.RegisterUnit <ModelInA, ModelInB>(new UnitA(eventBus)); eventBus.RegisterUnit <ModelInA, ModelInB>(new UnitA(eventBus)); }); StringAssert.EndsWith(exception.Message, "already set"); }
public void SampleOfParserSetupAndExecution() { var webParser = new WebParser <ParsingResult>(); webParser.RegisterUnit <ModelInA, ModelInB>(new UnitA(webParser)); webParser.RegisterUnit <ModelInB, ModelInC>(new UnitB(webParser)); webParser.ExecuteUnit <ModelInA, ModelInB>(new ModelInA()); Assert.AreEqual("a", webParser.Result.A); Assert.AreEqual("b", webParser.Result.B); Assert.AreEqual("UnitA > UnitB", webParser.ExecutionPath.ToString()); }
public Site911ParsingResult GetEventBusImplementation([FromUri] string id) { var httpClient = new HttpClient(); var parser = new WebParser <Site911ParsingResult>(); parser.RegisterUnit <A_SearchModelByIdRequestInput, A_SearchModelByIdRequestOutput>(new A_SearchModelByIdRequest(parser, httpClient)); parser.RegisterUnit <A_SearchModelByIdRequestOutput, B_ParseHtmlOutput>(new B_ParseHtml(parser, new HtmlDocument())); parser.RegisterUnit <B_ParseHtmlOutput, C_QueryResultOutput>(new C_RequestPartDetails(parser, httpClient)); parser.RegisterUnit <C_QueryResultOutput, Site911ParsingResult>(new D_ParseHtmlPartDetails(parser, new HtmlDocument())); parser.ExecuteUnit <A_SearchModelByIdRequestInput, A_SearchModelByIdRequestOutput>(new A_SearchModelByIdRequestInput { Id = id }); return(parser.Result); }
public void ExecuteUnit_ExecuteNotRegisteredUnit_ArgumentExceptionInExceptionProperty() { var eventBus = new WebParser <ParsingResult>(); eventBus.RegisterUnit <ModelInA, ModelInB>(new UnitA(eventBus)); eventBus.ExecuteUnit <ModelInB, ModelInC>(new ModelInB()); Assert.AreEqual(typeof(ArgumentException), eventBus.Exception.GetType()); StringAssert.EndsWith(eventBus.Exception.Message, "is not registered"); }