/// <summary> /// Validate Sequence Alignment Class General methods exception. /// </summary> /// <param name="nodeName">Node Name in the xml.</param> /// <param name="methodName">Name of the SequenceAlignment method to be validated</param> /// </summary> static void InValidateSequenceAlignmentGeneralMethods(string nodeName, SeqAlignmentMethods methodName) { // Read the xml file for getting both the files for aligning. string origSequence1 = Utility._xmlUtil.GetTextValue(nodeName, Constants.SequenceNode1); string origSequence2 = Utility._xmlUtil.GetTextValue(nodeName, Constants.SequenceNode2); IAlphabet alphabet = Utility.GetAlphabet(Utility._xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); string readOnlyException = Utility._xmlUtil.GetTextValue(nodeName, Constants.ReadOnlyExceptionNode); string expectedGetObjectDataException = Utility._xmlUtil.GetTextValue(nodeName, Constants.GetObjectDataNullErrorMessageNode); string actualError = null; StreamingContext context = new StreamingContext(StreamingContextStates.All); // Create two sequences ISequence aInput = new Sequence(alphabet, origSequence1); ISequence bInput = new Sequence(alphabet, origSequence2); // Add the sequences to the Sequence alignment object using AddSequence() method. IList <IPairwiseSequenceAlignment> sequenceAlignmentObj = new List <IPairwiseSequenceAlignment>(); PairwiseAlignedSequence alignSeq = new PairwiseAlignedSequence(); alignSeq.FirstSequence = aInput; alignSeq.SecondSequence = bInput; PairwiseSequenceAlignment seqAlignObj = new PairwiseSequenceAlignment(aInput, bInput);; seqAlignObj.Add(alignSeq); sequenceAlignmentObj.Add(seqAlignObj); // Set SequenceAlignment IsReadOnly prpoerty to true. seqAlignObj.IsReadOnly = true; IList <PairwiseAlignedSequence> newAlignedSequences = sequenceAlignmentObj[0].PairwiseAlignedSequences; switch (methodName) { case SeqAlignmentMethods.Add: try { seqAlignObj.Add(newAlignedSequences[0]); } catch (NotSupportedException ex) { actualError = ex.Message; } // Validate Error message Assert.AreEqual(readOnlyException, actualError); break; case SeqAlignmentMethods.Clear: try { seqAlignObj.Clear(); } catch (NotSupportedException ex) { actualError = ex.Message; } // Validate Error message Assert.AreEqual(readOnlyException, actualError); break; case SeqAlignmentMethods.Remove: try { seqAlignObj.Remove(newAlignedSequences[0]); } catch (NotSupportedException ex) { actualError = ex.Message; } // Validate Error message Assert.AreEqual(readOnlyException, actualError); break; case SeqAlignmentMethods.AddSequence: try { seqAlignObj.AddSequence(newAlignedSequences[0]); } catch (NotSupportedException ex) { actualError = ex.Message; } // Validate Error message Assert.AreEqual(readOnlyException, actualError); break; case SeqAlignmentMethods.GetObjectData: try { seqAlignObj.GetObjectData(null, context); } catch (ArgumentNullException ex) { actualError = ex.Message; } // Validate Error message Assert.AreEqual(expectedGetObjectDataException, actualError.Replace("\r", "").Replace("\n", "")); break; default: break; } ApplicationLog.WriteLine("SequenceAlignment P2 : Successfully validated the IsRead Property"); Console.WriteLine("SequenceAlignment P2 : Successfully validated the IsRead Property"); }
/// <summary> /// Validates Sequence Alignment Class General methods. /// </summary> /// <param name="nodeName">Node Name in the xml.</param> /// <param name="methodName">Name of the SequenceAlignment method to be validated</param> /// <param name="isSeqAlignDefCtr">Is sequence alignment Def Constructor</param> private void ValidateSequenceAlignmentGeneralMethods(string nodeName, SeqAlignmentMethods methodName, bool isSeqAlignDefCtr) { // Read the xml file for getting both the files for aligning. string origSequence1 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceNode1); string origSequence2 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceNode2); IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); string seqCount = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeqCountNode); string alignedSeqCountAfterAddSeq = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants .AlignedSeqCountAfterAddAlignedSeqNode); string arrayLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ArraySizeNode); var alignedSeqItems = new PairwiseAlignedSequence[int.Parse(arrayLength, null)]; const int Index = 0; // Create two sequences ISequence aInput = new Sequence(alphabet, origSequence1); ISequence bInput = new Sequence(alphabet, origSequence2); // Add the sequences to the Sequence alignment object using AddSequence() method. IList<IPairwiseSequenceAlignment> sequenceAlignmentObj = new List<IPairwiseSequenceAlignment>(); var alignSeq = new PairwiseAlignedSequence {FirstSequence = aInput, SecondSequence = bInput}; IPairwiseSequenceAlignment seqAlignObj = isSeqAlignDefCtr ? new PairwiseSequenceAlignment() : new PairwiseSequenceAlignment(aInput, bInput); seqAlignObj.Add(alignSeq); sequenceAlignmentObj.Add(seqAlignObj); IList<PairwiseAlignedSequence> newAlignedSequences = sequenceAlignmentObj[0].PairwiseAlignedSequences; switch (methodName) { case SeqAlignmentMethods.Add: seqAlignObj.Add(alignSeq); Assert.AreEqual(seqCount, seqAlignObj.PairwiseAlignedSequences.Count.ToString((IFormatProvider) null)); break; case SeqAlignmentMethods.Clear: seqAlignObj.Clear(); Assert.AreEqual(0, seqAlignObj.PairwiseAlignedSequences.Count); break; case SeqAlignmentMethods.Contains: Assert.IsTrue(seqAlignObj.Contains(newAlignedSequences[0])); break; case SeqAlignmentMethods.CopyTo: seqAlignObj.CopyTo(alignedSeqItems, Index); // Validate Copied array. Assert.AreEqual(alignedSeqItems[Index].FirstSequence, seqAlignObj.FirstSequence); Assert.AreEqual(alignedSeqItems[Index].SecondSequence, seqAlignObj.SecondSequence); break; case SeqAlignmentMethods.Remove: seqAlignObj.Remove(newAlignedSequences[0]); // Validate whether removed item is deleted from SequenceAlignment. Assert.AreEqual(0, newAlignedSequences.Count); break; case SeqAlignmentMethods.AddSequence: seqAlignObj.AddSequence(newAlignedSequences[0]); // Validate SeqAlignObj after adding aligned sequence. Assert.AreEqual(alignedSeqCountAfterAddSeq, seqAlignObj.Count.ToString((IFormatProvider) null)); break; case SeqAlignmentMethods.GetEnumerator: IEnumerator<PairwiseAlignedSequence> alignedSeqList = seqAlignObj.GetEnumerator(); // Aligned Sequence list after iterating through ailgnedSeq collection. Assert.IsNotNull(alignedSeqList); break; default: break; } ApplicationLog.WriteLine("SequenceAlignment P1 : Successfully validated the IsRead Property"); ApplicationLog.WriteLine("SequenceAlignment P1 : Successfully validated the Count Property"); ApplicationLog.WriteLine("SequenceAlignment P1 : Successfully validated the Sequences Property"); }