public void GffFormatterValidateFormatString() { // Gets the expected sequence from the Xml string filePath = utilityObj.xmlUtil.GetTextValue(Constants.SimpleGffNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePath)); IList <ISequence> seqs = null; GffParser parserObj = new GffParser(filePath); seqs = parserObj.Parse().ToList(); ISequence originalSequence = (Sequence)seqs[0]; // Use the formatter to write the original sequences to a temp file ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Gff Formatter BVT: Creating the Temp file '{0}'.", Constants.GffTempFileName)); GffFormatter formatter = new GffFormatter(); formatter.ShouldWriteSequenceData = true; string formatString = formatter.FormatString(originalSequence); string expectedString = utilityObj.xmlUtil.GetTextValue( Constants.SimpleGffNodeName, Constants.FormatStringNode); expectedString = expectedString.Replace("current-date", DateTime.Today.ToString("yyyy-MM-dd", null)); expectedString = expectedString.Replace("\r", "").Replace("\n", "").Replace(" ", "").Replace("\t", "").ToUpper(CultureInfo.CurrentCulture); string modifedformatString = formatString.Replace("\r", "").Replace("\n", "").Replace(" ", "").Replace("\t", "").ToUpper(CultureInfo.CurrentCulture); Assert.AreEqual(modifedformatString, expectedString); Console.WriteLine(string.Format((IFormatProvider)null, "Gff Formatter BVT: The Gff Format String '{0}' are matching with FormatString() method and is as expected.", formatString)); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Gff Formatter BVT: The Gff Format String '{0}' are matching with FormatString() method and is as expected.", formatString)); // Passed all the tests, delete the tmp file. If we failed an Assert, // the tmp file will still be there in case we need it for debugging. File.Delete(Constants.GffTempFileName); ApplicationLog.WriteLine("Deleted the temp file created."); }
/// <summary> /// General method to invalidate Argument Null exceptions generated from different methods. /// </summary> /// <param name="nodeName">xml node name.</param> /// <param name="method">Gff Parse method parameters</param> void InvalidateGffWriteMethod(ArgumentNullExceptions method) { ISequence sequence = null; List <ISequence> collection = new List <ISequence>(); string sequenceData = null; GffFormatter gffFormatter = null; try { switch (method) { case ArgumentNullExceptions.writeWithEmptyFile: sequenceData = utilityObj.xmlUtil.GetTextValue( Constants.SimpleGffDnaNodeName, Constants.ExpectedSequenceNode); gffFormatter = new GffFormatter(); { gffFormatter.Format(new Sequence(DnaAlphabet.Instance, sequenceData)); } break; case ArgumentNullExceptions.writeWithEmptySequence: gffFormatter = new GffFormatter(); { gffFormatter.Format(sequence); } break; case ArgumentNullExceptions.FormatString: gffFormatter = new GffFormatter(); { gffFormatter.FormatString(sequence); } break; case ArgumentNullExceptions.writeCollectionWithEmptyFile: sequenceData = utilityObj.xmlUtil.GetTextValue( Constants.SimpleGffDnaNodeName, Constants.ExpectedSequenceNode); collection.Add(new Sequence(DnaAlphabet.Instance, sequenceData)); gffFormatter = new GffFormatter(); { gffFormatter.Format(collection); } break; case ArgumentNullExceptions.writeCollectionWithEmptySequence: gffFormatter = new GffFormatter(); { gffFormatter.Format(collection); } break; default: break; } Assert.Fail(); } catch (ArgumentNullException) { ApplicationLog.WriteLine("GFF P2 : Exception is validated successfully."); } catch (Exception) { ApplicationLog.WriteLine("GFF P2 : Exception is validated successfully."); } }