/// <summary> /// Convert a <see cref="TrainLocationTimeModel" /> instance to a <see cref="TrainLocationTime" /> instance. /// </summary> /// <param name="model">The object to be converted.</param> /// <param name="locations">A dictionary of known locations, to use to resolve the location reference in the model.</param> /// <param name="notes">A dictionary of known footnotes, to use to resolve any footnote references in the model.</param> /// <param name="options">Document options to use to determine how to format strings.</param> /// <returns>A <see cref="TrainLocationTime" /> object containing the same data as the <c>model</c> parameter, with ID references resolved.</returns> /// <exception cref="NullReferenceException">Thrown if the <c>model</c> parameter is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">Thrown if the <c>options</c> parameter is <c>null</c>.</exception> public static TrainLocationTime ToTrainLocationTime( this TrainLocationTimeModel model, Dictionary <string, Location> locations, Dictionary <string, Note> notes, DocumentOptions options) { if (model is null) { throw new NullReferenceException(); } if (options is null) { throw new ArgumentNullException(nameof(options)); } TrainLocationTime output = new TrainLocationTime { Pass = model.Pass ?? false, ArrivalTime = model.Arrival?.ToTrainTime(notes), DepartureTime = model.Departure?.ToTrainTime(notes), Path = model.Path, Platform = model.Platform, Line = model.Line, FormattingStrings = options.FormattingStrings, }; if (model.LocationId != null && locations != null && locations.ContainsKey(model.LocationId)) { output.Location = locations[model.LocationId]; } return(output); }
public void DocumentOptionsClassCopyMethodReturnsNewObjectWithCorrectClockTypeProperty() { DocumentOptions testObject = GetDocumentOptions(); DocumentOptions testOutput = testObject.Copy(); Assert.AreEqual(testObject.ClockType, testOutput.ClockType); }
public void DocumentOptionsClassCopyMethodReturnsNewObjectWithCorrectGraphEditStyleProperty() { DocumentOptions testObject = GetDocumentOptions(); DocumentOptions testOutput = testObject.Copy(); Assert.AreEqual(testObject.GraphEditStyle, testOutput.GraphEditStyle); }
public void DocumentOptionsExtensionsClass_ToDocumentOptionsModelMethod_ThrowsArgumentNullException_IfParameterIsNull() { DocumentOptions testObject = null; _ = testObject.ToDocumentOptionsModel(); Assert.Fail(); }
public void DocumentOptionsClassCopyMethodReturnsNewObject() { DocumentOptions testObject = GetDocumentOptions(); DocumentOptions testOutput = testObject.Copy(); Assert.AreNotSame(testOutput, testObject); }
public void DocumentOptionsExtensionsClass_ToYamlDocumentOptionsModelMethod_ReturnsObjectWithCorrectDisplayTrainLabelsOnGraphsParameter_IfParameterIsNotNull() { DocumentOptions testParam = GetTestObject(); DocumentOptionsModel testOutput = testParam.ToYamlDocumentOptionsModel(); Assert.AreEqual(testParam.DisplayTrainLabelsOnGraphs, testOutput.DisplayTrainLabelsOnGraphs.Value); }
public void DocumentOptionsExtensionsClass_ToYamlDocumentOptionsModelMethod_ThrowsNullReferenceException_IfParameterIsNull() { DocumentOptions testParam = null; _ = testParam.ToYamlDocumentOptionsModel(); Assert.Fail(); }
public void DocumentOptionsExtensionsClass_ToYamlDocumentOptionsModelMethod_ReturnsObjectWithCorrectGraphEditStyleParameter_IfParameterIsNotNull() { DocumentOptions testParam = GetTestObject(); DocumentOptionsModel testOutput = testParam.ToYamlDocumentOptionsModel(); Assert.AreEqual(testParam.GraphEditStyle.ToString("g"), testOutput.GraphEditStyle); }
public void DocumentOptionsClassCopyMethodReturnsNewObjectWithCorrectDisplayTrainLabelsOnGraphsProperty() { DocumentOptions testObject = GetDocumentOptions(); DocumentOptions testOutput = testObject.Copy(); Assert.AreEqual(testObject.DisplayTrainLabelsOnGraphs, testOutput.DisplayTrainLabelsOnGraphs); }
private void dlgDocumentOptions_Load(object sender, EventArgs e) { if (_DocumentOptions == null) { _DocumentOptions = new DocumentOptions(); } pgOptions.SelectedObject = _DocumentOptions; }
public void TrainGraphModelClassSetPropertiesFromDocumentOptionsMethodSetsTooltipFormattingStringPropertyToEqualTooltipPropertyOfFormattingStringsPropertyOfParameter() { DocumentOptions testSource = GetDocumentOptions(); TrainGraphModel testObject = GetTrainGraphModel(); testObject.SetPropertiesFromDocumentOptions(testSource); Assert.AreEqual(testSource.FormattingStrings.Tooltip, testObject.TooltipFormattingString); }
public void TrainGraphModelClassSetPropertiesFromDocumentOptionsMethodSetsGraphEditStylePropertyToEqualGraphEditStylePropertyOfParameter() { DocumentOptions testSource = GetDocumentOptions(); TrainGraphModel testObject = GetTrainGraphModel(); testObject.SetPropertiesFromDocumentOptions(testSource); Assert.AreEqual(testSource.GraphEditStyle, testObject.GraphEditStyle); }
public void DocumentOptionsClassCopyToMethodOverwritesGraphEditStyleProperty() { DocumentOptions testObject = GetDocumentOptions(); DocumentOptions target = GetDocumentOptions(); testObject.CopyTo(target); Assert.AreEqual(testObject.GraphEditStyle, target.GraphEditStyle); }
public void TrainGraphModelClassSetPropertiesFromDocumentOptionsMethodSetsDisplayTrainLabelsPropertyToEqualDisplayTrainLabelsOnGraphsPropertyOfParameter() { DocumentOptions testSource = GetDocumentOptions(); TrainGraphModel testObject = GetTrainGraphModel(); testObject.SetPropertiesFromDocumentOptions(testSource); Assert.AreEqual(testSource.DisplayTrainLabelsOnGraphs, testObject.DisplayTrainLabels); }
/// <summary> /// Copy the values of relevant properties from a <see cref="DocumentOptions" /> instance. /// </summary> /// <param name="source">The object to copy the properties from.</param> public void SetPropertiesFromDocumentOptions(DocumentOptions source) { if (source == null) { return; } DisplayTrainLabels = source.DisplayTrainLabelsOnGraphs; GraphEditStyle = source.GraphEditStyle; TooltipFormattingString = source.FormattingStrings.Tooltip; }
public void DocumentOptionsModelExtensionsClass_ToDocumentOptionsMethod_ReturnsObjectWithClockTypePropertyEqualToTwentyFourHourClock_IfParameterHasClockTypeNamePropertyEqualToTwentyFourHourClock() { DocumentOptionsModel testParam = GetModel(); testParam.ClockTypeName = "TwentyFourHourClock"; DocumentOptions testOutput = testParam.ToDocumentOptions(); Assert.AreEqual(ClockType.TwentyFourHourClock, testOutput.ClockType); }
public void DocumentOptionsModelExtensionsClass_ToDocumentOptionsMethod_ReturnsObjectWithDisplayTrainLabelsOnGraphsPropertyEqualToTrue_IfParameterHasDisplayTrainLabelsOnGraphsPropertyEqualToNull() { DocumentOptionsModel testParam = GetModel(); testParam.DisplayTrainLabelsOnGraphs = null; DocumentOptions testOutput = testParam.ToDocumentOptions(); Assert.IsTrue(testOutput.DisplayTrainLabelsOnGraphs); }
public void DocumentOptionsModelExtensionsClass_ToDocumentOptionsMethod_ReturnsObjectWithGraphEditStylePropertyEqualToPreserveSectionTimes_IfParameterHasGraphEditStylePropertyEqualToNull() { DocumentOptionsModel testParam = GetModel(); testParam.GraphEditStyle = null; DocumentOptions testOutput = testParam.ToDocumentOptions(); Assert.AreEqual(GraphEditStyle.PreserveSectionTimes, testOutput.GraphEditStyle); }
public void DocumentOptionsModelExtensionsClass_ToDocumentOptionsMethod_ReturnsObjectWithGraphEditStylePropertyEqualToPreserveSectionTimes_IfParameterHasGraphEditStylePropertyThatIsNotAValidValue() { DocumentOptionsModel testParam = GetModel(); testParam.GraphEditStyle = _rnd.NextDefinitelyInvalidString(_validGraphEditStyles); DocumentOptions testOutput = testParam.ToDocumentOptions(); Assert.AreEqual(GraphEditStyle.PreserveSectionTimes, testOutput.GraphEditStyle); }
public void DocumentOptionsModelExtensionsClass_ToDocumentOptionsMethod_ReturnsObjectWithGraphEditStylePropertyEqualToFree_IfParameterHasGraphEditStylePropertyEqualToFree() { DocumentOptionsModel testParam = GetModel(); testParam.GraphEditStyle = "Free"; DocumentOptions testOutput = testParam.ToDocumentOptions(); Assert.AreEqual(GraphEditStyle.Free, testOutput.GraphEditStyle); }
public void DocumentOptionsModelExtensionsClass_ToDocumentOptionsMethod_ReturnsObjectWithClockTypePropertyEqualToTwelveHourClock_IfParameterHasClockTypeNamePropertyIsNotAValidEnumValue() { DocumentOptionsModel testParam = GetModel(); testParam.ClockTypeName = _rnd.NextDefinitelyInvalidString(_validClockTypes); DocumentOptions testOutput = testParam.ToDocumentOptions(); Assert.AreEqual(ClockType.TwelveHourClock, testOutput.ClockType); }
public async Task <IDocument> LoadDocument(DocumentOptions options) { var document = await _next.LoadDocument(options); _fileSystem.CreateDirectory(options.DirectoryPath); await _fileSystem.CreateFile(options.FilePath, new FileContent(options.Url, options.FilePath, document.Source.Text)); return(document); }
public void DocumentOptionsModelExtensionsClassToDocumentOptionsMethodReturnsDocumentOptionsObjectWithCorrectClockTypePropertyIfArgumentClockTypeNamePropertyEqualsTwentyFourHourClock() { DocumentOptionsModel testObject = new DocumentOptionsModel { ClockTypeName = "TwentyFourHourClock" }; DocumentOptions resultObject = testObject.ToDocumentOptions(); Assert.AreEqual(ClockType.TwentyFourHourClock, resultObject.ClockType); }
public void DocumentOptionsModelExtensionsClassToDocumentOptionsMethodReturnsDocumentOptionsObjectWithCorrectGraphEditStylePropertyIfArgumentGraphEditStylePropertyEqualsFree() { DocumentOptionsModel testObject = new DocumentOptionsModel { GraphEditStyle = "Free" }; DocumentOptions resultObject = testObject.ToDocumentOptions(); Assert.AreEqual(GraphEditStyle.Free, resultObject.GraphEditStyle); }
public void DocumentOptionsModelExtensionsClassToDocumentOptionsMethodReturnsDocumentOptionsObjectWithGraphEditStylePropertyEqualToPreserveSectionTimesIfArgumentGraphEditStylePropertyIsNull() { DocumentOptionsModel testObject = new DocumentOptionsModel { GraphEditStyle = null }; DocumentOptions resultObject = testObject.ToDocumentOptions(); Assert.AreEqual(GraphEditStyle.PreserveSectionTimes, resultObject.GraphEditStyle); }
public void DocumentOptionsExtensionsClass_ToDocumentOptionsModelMethod_SetsGraphEditStylePropertyToCorrectValue_IfArgumentGraphEditStylePropertyEqualsPreserveSectionTimes() { DocumentOptions testObject = new DocumentOptions { GraphEditStyle = GraphEditStyle.PreserveSectionTimes }; DocumentOptionsModel testOutput = testObject.ToDocumentOptionsModel(); Assert.AreEqual("PreserveSectionTimes", testOutput.GraphEditStyle); }
private void _documentFormatSelector_SelectedFormatChanged(object sender, EventArgs e) { DocumentOptions options = _ocrEngine.DocumentWriterInstance.GetOptions(_documentFormatSelector.SelectedFormat); _documentFormatSelector.TotalPages = 1; switch (_documentFormatSelector.SelectedFormat) { case DocumentFormat.Xps: _documentFormatSelector.FormatHasOptions = false; break; case DocumentFormat.Doc: _documentFormatSelector.FormatHasOptions = true; break; case DocumentFormat.Docx: _documentFormatSelector.FormatHasOptions = true; break; case DocumentFormat.Rtf: _documentFormatSelector.FormatHasOptions = true; break; case DocumentFormat.Xls: _documentFormatSelector.FormatHasOptions = false; break; #if LEADTOOLS_V19_OR_LATER case DocumentFormat.AltoXml: _documentFormatSelector.FormatHasOptions = true; break; case DocumentFormat.Pub: _documentFormatSelector.FormatHasOptions = false; break; case DocumentFormat.Mob: _documentFormatSelector.FormatHasOptions = false; break; case DocumentFormat.Svg: _documentFormatSelector.FormatHasOptions = false; break; #endif // #if LEADTOOLS_V19_OR_LATER default: _documentFormatSelector.FormatHasOptions = true; break; } if (options != null) { _ocrEngine.DocumentWriterInstance.SetOptions(_documentFormatSelector.SelectedFormat, options); } }
public async Task <IDocument> LoadDocument(DocumentOptions options) { var document = await _next.LoadDocument(options); if (!document.IsSuccessStatusCode()) { throw new HttpRequestException($"Request for url = '{document.Url}' returned status code = '{document.StatusCode}'"); } return(document); }
// public HDoc(Uri Url) // { // var Result = HTTPService.Get(Url.AbsoluteUri); // Children = _MatchTag(Result); // } public HDoc(DocumentOptions Options) { if (Options == DocumentOptions.BasicHTML) { var HTML = new HTag("html", new HTag("head", new HTag("meta", new HProp("charset", "utf-8")), new HTag("title", "Example")), new HTag("body")); Children.Add(HTML); } }
public void DocumentOptionsClassFormattingStringsPropertyReturnsCorrectValuesIfClockTypeIsTwentyFourHourClock() { DocumentOptions testObject = GetDocumentOptions(ClockType.TwentyFourHourClock); TimeDisplayFormattingStrings testOutput = testObject.FormattingStrings; Assert.AreEqual("HH{0}mmf", testOutput.Complete); Assert.AreEqual("HH mmf", testOutput.TimeWithoutFootnotes); Assert.AreEqual("HH", testOutput.Hours); Assert.AreEqual("mmf", testOutput.Minutes); Assert.AreEqual("HH:mmf", testOutput.Tooltip); }