当前位置: 首页>>代码示例>>C#>>正文


C# Sequence.CopyTo方法代码示例

本文整理汇总了C#中Sequence.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.CopyTo方法的具体用法?C# Sequence.CopyTo怎么用?C# Sequence.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequence的用法示例。


在下文中一共展示了Sequence.CopyTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSequenceCopyTo

 public void TestSequenceCopyTo()
 {
     Sequence seq = new Sequence(Alphabets.DNA, "ATCG");
     byte[] array = new byte[2];
     seq.CopyTo(array, 1, 2);
     string expectedValue = "TC";
     StringBuilder b = new StringBuilder();
     b.Append((char)array[0]);
     b.Append((char)array[1]);
     string actualValue = b.ToString();
     Assert.AreEqual(expectedValue, actualValue);
 }
开发者ID:cpatmoore,项目名称:bio,代码行数:12,代码来源:TestSequencesCopyToForBio.cs

示例2: ValidateCopyTo

        public void ValidateCopyTo()
        {
            // Get input and expected values from xml
            string expectedSequence = this.utilityObj.xmlUtil.GetTextValue(Constants.RnaDerivedSequenceNode,
                Constants.ExpectedSequence);
            string alphabetName = this.utilityObj.xmlUtil.GetTextValue(Constants.RnaDerivedSequenceNode,
                Constants.AlphabetNameNode);
            IAlphabet alphabet = Utility.GetAlphabet(alphabetName);

            // Create a Sequence object.
            ISequence iseqObj =
                new Sequence(alphabet, expectedSequence);
            Sequence seqObj = new Sequence(iseqObj);
            byte[] array = new byte[expectedSequence.Length];
            seqObj.CopyTo(array, 0, expectedSequence.Length);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < expectedSequence.Length; i++)
            {
                builder.Append((char)array[i]);
            }
            string actualValue = builder.ToString();
            Assert.AreEqual(expectedSequence, actualValue);

            //check with a part of the expected seq only
            seqObj.CopyTo(array, 0, 5);
            builder = new StringBuilder();
            for (int i = 0; i < 5; i++)
            {
                builder.Append((char)array[i]);
            }
            actualValue = builder.ToString();
            Assert.AreEqual(expectedSequence.Substring(0, 5), actualValue);
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:33,代码来源:SequenceBvtTestCases.cs

示例3: InvalidateCopyTo

        public void InvalidateCopyTo()
        {
            // Get input and expected values from xml
            string expectedSequence = this.utilityObj.xmlUtil.GetTextValue(Constants.RnaDerivedSequenceNode,
                                                                      Constants.ExpectedSequence);
            string alphabetName = this.utilityObj.xmlUtil.GetTextValue(Constants.RnaDerivedSequenceNode,
                                                                  Constants.AlphabetNameNode);
            IAlphabet alphabet = Utility.GetAlphabet(alphabetName);

            // Create a Sequence object.
            ISequence iseqObj =
                new Sequence(alphabet, expectedSequence);
            var seqObj = new Sequence(iseqObj);
            //check with null array
            byte[] array = null;
            try
            {
                seqObj.CopyTo(array, 10, 20);
                Assert.Fail();
            }
            catch (ArgumentNullException anex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentNullException : " + anex.Message);
            }

            //check with more than available length
            array = new byte[expectedSequence.Length];
            try
            {
                seqObj.CopyTo(array, 0, expectedSequence.Length + 100);
                Assert.Fail();
            }
            catch (ArgumentException aex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentException : " + aex.Message);
            }

            //check with negative start
            array = new byte[expectedSequence.Length];
            try
            {
                seqObj.CopyTo(array, -5, expectedSequence.Length);
                Assert.Fail();
            }
            catch (ArgumentException aex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentException : " + aex.Message);
            }

            //check with negative count
            array = new byte[expectedSequence.Length];
            try
            {
                seqObj.CopyTo(array, 0, -5);
                Assert.Fail();
            }
            catch (ArgumentException aex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentException : " + aex.Message);
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:61,代码来源:SequenceP2TestCases.cs


注:本文中的Sequence.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。