public void TestWiggleFormatter() { string filepathTmp = Path.GetTempFileName(); using (WiggleFormatter formatter = new WiggleFormatter(filepathTmp)) { formatter.Write(CreateDummyAnnotation()); } WiggleParser parser = new WiggleParser(); VerifyDummyAnnotation(parser.Parse(filepathTmp)); }
public void TestWiggleFormatter() { string filepathTmp = Path.GetTempFileName(); WiggleFormatter formatter = new WiggleFormatter(); using (formatter.Open(filepathTmp)) { formatter.Format(CreateDummyAnnotation()); } WiggleParser parser = new WiggleParser(); VerifyDummyAnnotation(parser.Parse(filepathTmp).First()); }
/// <summary> /// Validate Wiggle Formatter for fixed and variable steps. /// </summary> /// <param name="nodeName">Nodename</param> /// <param name="formatType">Write using a stream/File Name.</param> private void ValidateWiggleFormatter(string nodeName, FormatType formatType) { // Gets the filepath. String filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePath)); WiggleAnnotation annotation = null, annotationNew = null; string[] expectedValues = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedValuesNode).Split(','); string[] expectedPoints = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedKeysNode).Split(','); //Parse the file. WiggleParser parser = new WiggleParser(); annotation = parser.ParseOne(filePath); WiggleFormatter formatter = null; //Write to a new file. switch (formatType) { case FormatType.Stream: using (var writer = File.Create(Constants.WiggleTempFileName)) { formatter = new WiggleFormatter(); formatter.Format(writer, annotation); formatter.Close(); } break; default: formatter = new WiggleFormatter(); formatter.Format(annotation, Constants.WiggleTempFileName); formatter.Close(); break; } //Read the new file and then compare the annotations. WiggleParser parserNew = new WiggleParser(); annotationNew = parserNew.ParseOne(Constants.WiggleTempFileName); int index = 0; //Validate keys and values of the parsed file. foreach (KeyValuePair<long, float> keyvaluePair in annotationNew) { Assert.AreEqual(long.Parse(expectedPoints[index], CultureInfo.InvariantCulture), keyvaluePair.Key); Assert.AreEqual(float.Parse(expectedValues[index], CultureInfo.InvariantCulture), keyvaluePair.Value); index++; } File.Delete(Constants.WiggleTempFileName); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Wiggle Formatter BVT: Successfully validated the written file")); }
/// <summary> /// Validate Exceptions from Wiggle Parser and Formatter for General test cases. /// </summary> /// <param name="exceptionType"></param> public void ValidateArgumentNullException(ExceptionType exceptionType) { // Gets the filepath. String filePath = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePath)); WiggleAnnotation annotation =null; try { switch (exceptionType) { case ExceptionType.NullFormatter: WiggleFormatter formatter = new WiggleFormatter(); formatter.Format(null, annotation); break; case ExceptionType.NullParser: WiggleParser parser = new WiggleParser(); string valueForParse = null; parser.ParseOne(valueForParse); break; case ExceptionType.NullAnnotationWithData: annotation = new WiggleAnnotation(null, Constants.StringByteArray); break; case ExceptionType.NullAnnotationWithChromosomeName: float[] data = new float[2] { 1.0F, 2.0F }; annotation = new WiggleAnnotation(data, null,0,0); break; } } catch (ArgumentNullException exception) { ApplicationLog.WriteLine( "Wiggle P2 test cases : Successfully validated the exception:", exception.Message); } }
public void ValidateWiggleFormatterPublicProperties() { //Get the expected values from configuration file. string expectedDescription = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.FormatterDescriptionNode); string expectedName = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.NameNode); string expectedFileType = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.FileTypesNode); WiggleFormatter formatter = new WiggleFormatter(); Assert.AreEqual(expectedDescription, formatter.Description); Assert.AreEqual(expectedName, formatter.Name); Assert.AreEqual(expectedFileType, formatter.SupportedFileTypes); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Wiggle Formatter BVT: Validation of all public properties is successful")); }