Exemplo n.º 1
0
        /// <summary>
        /// Invalidate Sparse sequence Count
        /// </summary>
        /// <param name="sparseSeq">Sparse Sequence</param>
        private static void ValidateSparseSequenceCount(SparseSequence sparseSeq)
        {
            Assert.AreEqual(sparseSeq.Count, 0);
            sparseSeq.Count = 5;

            Assert.IsNull(sparseSeq[0]);
            Assert.IsNull(sparseSeq[1]);
            Assert.IsNull(sparseSeq[2]);
            Assert.IsNull(sparseSeq[3]);
            Assert.IsNull(sparseSeq[4]);

            sparseSeq[2] = Alphabets.DNA.G;
            Assert.AreEqual(sparseSeq.Count, 5);
            Assert.IsNull(sparseSeq[0]);
            Assert.IsNull(sparseSeq[1]);
            Assert.AreSame(sparseSeq[2], Alphabets.DNA.G);
            Assert.IsNull(sparseSeq[3]);
            Assert.IsNull(sparseSeq[4]);

            sparseSeq.Insert(2, 'A');
            Assert.AreEqual(sparseSeq.Count, 6);
            Assert.IsNull(sparseSeq[0]);
            Assert.IsNull(sparseSeq[1]);
            Assert.AreSame(sparseSeq[2], Alphabets.DNA.A);
            Assert.AreSame(sparseSeq[3], Alphabets.DNA.G);
            Assert.IsNull(sparseSeq[4]);
            Assert.IsNull(sparseSeq[5]);

            sparseSeq.Insert(4, Alphabets.DNA.C);
            Assert.AreEqual(sparseSeq.Count, 7);
            Assert.IsNull(sparseSeq[0]);
            Assert.IsNull(sparseSeq[1]);
            Assert.AreSame(sparseSeq[2], Alphabets.DNA.A);
            Assert.AreSame(sparseSeq[3], Alphabets.DNA.G);
            Assert.AreSame(sparseSeq[4], Alphabets.DNA.C);
            Assert.IsNull(sparseSeq[5]);
            Assert.IsNull(sparseSeq[6]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invalidate Sparse sequence Insert(SeqItem)
        /// </summary>
        /// <param name="sparseSeq">Sparse Sequence</param>
        private static void ValidateSparseSequenceInsertSeqItem(SparseSequence sparseSeq)
        {
            sparseSeq.Insert(0, Alphabets.DNA.G);
            Assert.AreEqual(sparseSeq.Count, 3);

            sparseSeq.Insert(sparseSeq.Count, Alphabets.DNA.G);
            Assert.AreEqual(sparseSeq.Count, 4);

            try
            {
                sparseSeq.Insert(-1, Alphabets.DNA.A);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                Assert.AreEqual(sparseSeq.Count, 4);
            }

            try
            {
                sparseSeq.Insert(sparseSeq.Count + 1, Alphabets.DNA.A);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                Assert.AreEqual(sparseSeq.Count, 4);
            }

            try
            {
                sparseSeq.Insert(0, Alphabets.RNA.U);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                Assert.AreEqual(sparseSeq.Count, 4);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invalidate ReadOnly Sparse sequence
        /// </summary>
        /// <param name="sparseSeq">Sparse Sequence</param>
        private static void InvalidateReadOnlySparseSequence(SparseSequence sparseSeq)
        {
            try
            {
                sparseSeq.Add(Alphabets.DNA.A);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.Clear();
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.Insert(0, 'C');
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.Insert(0, Alphabets.DNA.A);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.InsertRange(0, "CGA");
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.Remove(Alphabets.DNA.A);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.RemoveAt(0);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.RemoveRange(0, 2);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
            }

            try
            {
                sparseSeq.Replace(0, 'C');
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
                Assert.AreSame(sparseSeq[0], Alphabets.DNA.A);
            }

            try
            {
                sparseSeq.Replace(0, Alphabets.DNA.C);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
                Assert.AreSame(sparseSeq[0], Alphabets.DNA.A);
            }

            try
            {
                sparseSeq.ReplaceRange(0, "G");
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
                Assert.AreEqual(sparseSeq.Count, 1);
                Assert.AreSame(sparseSeq[0], Alphabets.DNA.A);
            }
        }