本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# List.CopyTo方法的具体用法?C# List.CopyTo怎么用?C# List.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.CopyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo_NegativeIndexOfInsertingCollectionInArray_ExceptionThrown
public void CopyTo_NegativeIndexOfInsertingCollectionInArray_ExceptionThrown()
{
var list = new List<int>();
for (var i = 0; i < 5; i++)
list.Add(i);
var intArray = new int[10];
list.CopyTo(intArray, -2);
}
示例2: TestCopyTo_IEnumerable_DestinationSmaller_StopsPrematurely
public void TestCopyTo_IEnumerable_DestinationSmaller_StopsPrematurely()
{
IEnumerable<int> source = new List<int>() { 1, 2, 3, 4, 5, 6 };
var destination = TestHelper.Wrap(new List<int>() { 0, 0, 0 });
int index = source.CopyTo(destination);
Assert.AreEqual(destination.Count, index, "The wrong index was returned.");
var expected = new int[] { 1, 2, 3 };
Assert.IsTrue(expected.ToSublist().IsEqualTo(destination), "The items were not copied as expected.");
TestHelper.CheckHeaderAndFooter(destination);
}
示例3: CopyTo_CopyingInNullArray_ExceptionThrown
public void CopyTo_CopyingInNullArray_ExceptionThrown()
{
var list = new List<int>();
for (var i = 0; i < 5; i++)
list.Add(i);
int[] intArray = null;
list.CopyTo(destinationArray: intArray, indexForInsertingDestinationArray: 1);
}
示例4: CopyTo_ListIsNotPlacedInLengthOfArray_ExceptionThrown
public void CopyTo_ListIsNotPlacedInLengthOfArray_ExceptionThrown()
{
var list = new List<int>();
for (var i = 0; i < 5; i++)
list.Add(i);
var intArray = new int[10];
list.CopyTo(intArray, 8);
}
示例5: CopyTo_IndexOutsideAllowableRangeWhenCopyingInArray_ExceptionThrown
public void CopyTo_IndexOutsideAllowableRangeWhenCopyingInArray_ExceptionThrown()
{
var list = new List<int>();
for (var i = 0; i < 5; i++)
list.Add(i);
var intArray = new int[10];
list.CopyTo(intArray, 8);
}
示例6: CopyTo_ArrayIsProperlyChanged_AfterCopyingFromList
public void CopyTo_ArrayIsProperlyChanged_AfterCopyingFromList()
{
var list = new List<int>();
for (var i = 0; i < 5; i++)
list.Add(i);
var intArray = new int[10];
list.CopyTo(intArray, 2);
Assert.AreEqual(1, intArray[3]);
}
示例7: CopyTo_CorrectCopyingOfArray
public void CopyTo_CorrectCopyingOfArray()
{
var list = new List<int>();
for (var i = 0; i < 5; i++)
list.Add(i);
var intArray = new int[10];
list.CopyTo(intArray, 2);
Assert.AreEqual(1, intArray[3]);
}
示例8: IListExtensions_FisherYatesShuffleRandomizes
public void IListExtensions_FisherYatesShuffleRandomizes()
{
List<int> testInts = new List<int>(Enumerable.Range(0, 100));
int[] orderBeforeShuffle = new int[100];
for (int i = 0; i < 50; i++)
{
testInts.CopyTo(orderBeforeShuffle);
testInts.FisherYatesShuffle();
Assert.IsFalse(orderBeforeShuffle.SequenceEqual(testInts));
}
}
示例9: testListOfSymbolsClone
public void testListOfSymbolsClone()
{
List<Symbol> l = new List<Symbol>();
l.Add(new Symbol("A"));
l.Add(new Symbol("B"));
l.Add(new Symbol("C"));
Symbol[] copy = new Symbol[l.Count];
l.CopyTo(copy);
List<Symbol> l2 = copy.ToList<Symbol>();
l2.Remove(new Symbol("B"));
Assert.AreEqual(3, l.Count);
Assert.AreEqual(2, l2.Count);
}
示例10: TcpReceiveEndpointSingleByteDelimitersTest
public void TcpReceiveEndpointSingleByteDelimitersTest()
{
var options = new TcpReceieveOptions();
TcpReceiveEndpoint endpoint = new TcpReceiveEndpoint(new IPEndPoint(IPAddress.Any, 6789), options);
var host = new Mock<IApplicationHost>();
endpoint.Initialize(host.Object, options);
StateObject state = new StateObject(null);
List<byte> data = new List<byte>();
data.AddRange(new byte[] { TcpReceieveOptions.SOH });
data.AddRange(new byte[] { TcpReceieveOptions.STX, 0x41, 0x41, 0x41, 0x41, TcpReceieveOptions.ETX });
data.AddRange(new byte[] { TcpReceieveOptions.EOT });
data.CopyTo(state.Buffer, 0);
bool isEot = endpoint.ProcessIncomingStream(state.Buffer.Length, state);
Assert.IsTrue(isEot);
host.Verify(app => app.ProcessInPipeline(It.IsAny<TcpReceiveEndpoint>(), It.IsNotNull<byte[]>()), Times.Once);
host.Verify(app => app.ProcessInPipeline(It.IsAny<TcpReceiveEndpoint>(), It.Is<byte[]>(indata => indata.SequenceEqual(new byte[] { 0x41, 0x41, 0x41, 0x41 }))));
}
示例11: TestCopyTo_IEnumerable_NullDestination_Throws
public void TestCopyTo_IEnumerable_NullDestination_Throws()
{
IEnumerable<int> source = new List<int>();
IExpandableSublist<List<int>, int> destination = null;
source.CopyTo(destination);
}
示例12: TestCopyTo_NullDestination_Throws
public void TestCopyTo_NullDestination_Throws()
{
IExpandableSublist<List<int>, int> list = new List<int>().ToSublist();
IExpandableSublist<List<int>, int> destination = null;
list.CopyTo(destination);
}
示例13: TcpReceiveEndpointMultiByteDelimitersTest
public void TcpReceiveEndpointMultiByteDelimitersTest()
{
var options = new TcpReceieveOptions();
options.SohDelimiters = new byte[] { TcpReceieveOptions.SOH, 0x06 };
options.StxDelimiters = new byte[] { TcpReceieveOptions.STX, 0x06 };
options.EtxDelimiters = new byte[] { TcpReceieveOptions.ETX, 0x06 };
options.EotDelimiters = new byte[] { TcpReceieveOptions.EOT, 0x07 };
//BUG: If the end-delimiter of STX and EOT match it will not detect EOT
//options.EOTDelimiters = new byte[] {TcpReceiveEndpoint.EOT, 0x06};
TcpReceiveEndpoint endpoint = new TcpReceiveEndpoint(new IPEndPoint(IPAddress.Any, 6789), options);
var host = new Mock<IApplicationHost>();
endpoint.Initialize(host.Object, options);
StateObject state = new StateObject(null);
List<byte> data = new List<byte>();
data.AddRange(options.SohDelimiters);
data.AddRange(options.StxDelimiters);
data.AddRange(new byte[] { 0x41, 0x41, 0x41, 0x41 });
data.AddRange(options.EtxDelimiters);
data.AddRange(options.EotDelimiters);
data.CopyTo(state.Buffer, 0);
bool isEot = endpoint.ProcessIncomingStream(state.Buffer.Length, state);
Assert.IsTrue(isEot);
host.Verify(app => app.ProcessInPipeline(It.IsAny<TcpReceiveEndpoint>(), It.IsNotNull<byte[]>()), Times.Once);
host.Verify(app => app.ProcessInPipeline(It.IsAny<TcpReceiveEndpoint>(), It.Is<byte[]>(indata => indata.SequenceEqual(new byte[] { 0x41, 0x41, 0x41, 0x41 }))));
}
示例14: TcpReceiveEndpointMultiByteDelimitersSplittedBufferTest
public void TcpReceiveEndpointMultiByteDelimitersSplittedBufferTest()
{
var options = new TcpReceieveOptions();
options.SohDelimiters = new byte[] { TcpReceieveOptions.SOH, 0x06 };
options.StxDelimiters = new byte[] { TcpReceieveOptions.STX, 0x06 };
options.EtxDelimiters = new byte[] { TcpReceieveOptions.ETX, 0x06 };
options.EotDelimiters = new byte[] { TcpReceieveOptions.EOT, 0x07 };
TcpReceiveEndpoint endpoint = new TcpReceiveEndpoint(new IPEndPoint(IPAddress.Any, 6789), options);
var host = new Mock<IApplicationHost>();
endpoint.Initialize(host.Object, options);
StateObject state = new StateObject(null);
List<byte> data = new List<byte>();
data.AddRange(options.SohDelimiters);
data.AddRange(options.StxDelimiters);
data.AddRange(new byte[] { 0x41, 0x41, 0x41, 0x41 });
data.AddRange(options.EtxDelimiters);
data.AddRange(options.EotDelimiters);
bool isEot = false;
for (int i = 0; i < data.Count; i++)
{
state.State = StateObject.FrameState.FindSoh;
int noBytesInFirstBuffer = i;
data.CopyTo(0, state.Buffer, 0, noBytesInFirstBuffer);
isEot = endpoint.ProcessIncomingStream(noBytesInFirstBuffer, state);
Assert.IsFalse(isEot);
data.CopyTo(noBytesInFirstBuffer, state.Buffer, 0, data.Count - noBytesInFirstBuffer);
isEot = endpoint.ProcessIncomingStream(data.Count - noBytesInFirstBuffer, state);
Assert.IsTrue(isEot);
}
host.Verify(app => app.ProcessInPipeline(It.IsAny<TcpReceiveEndpoint>(), It.IsNotNull<byte[]>()), Times.AtLeast(3));
host.Verify(app => app.ProcessInPipeline(It.IsAny<TcpReceiveEndpoint>(), It.Is<byte[]>(indata => indata.SequenceEqual(new byte[] { 0x41, 0x41, 0x41, 0x41 }))));
}
示例15: LerPesosAbscissasETempos
private void LerPesosAbscissasETempos(string nomeDoArquivo, int nPassos, out double[] tempo, out List<double[]> pesosOuAbscissas)
{
List<double> tempos = new List<double>();
List<double[]> pesosOuAbscissasT = new List<double[]>();
pesosOuAbscissas = new List<double[]>();
var reader = new StreamReader(@"C:\Users\uqk2\Desktop\" + nomeDoArquivo + ".m");
reader.ReadLine();
reader.ReadLine();
reader.ReadLine();
reader.ReadLine();
while (!reader.EndOfStream)
{
var linha = reader.ReadLine();
if (linha != null && linha.Contains("%"))
{
List<double> listaPesosOuAbscissas = new List<double>();
for (int i = 0; i < nPassos; i++)
{
linha = reader.ReadLine();
if (linha.Contains("%")) linha = reader.ReadLine(); ;
int indiceIgual = linha.IndexOf("=");
if (linha.Contains("t"))
{
linha = linha.Trim();
int length = linha.Length - indiceIgual - 1;
linha = linha.Substring(indiceIgual + 1, length);
linha = linha.Replace(";", "");
tempos.Add(Convert.ToDouble(linha));
}
else if (linha.Contains("pN"))
{
linha = linha.Trim();
int length = linha.Length - indiceIgual - 1;
linha = linha.Substring(indiceIgual + 1, length);
linha = linha.Replace(";", "");
listaPesosOuAbscissas.Add(Convert.ToDouble(linha));
}
else if (linha.Contains("aN"))
{
linha = linha.Trim();
int length = linha.Length - indiceIgual - 1;
linha = linha.Substring(indiceIgual + 1, length);
linha = linha.Replace(";", "");
listaPesosOuAbscissas.Add(Convert.ToDouble(linha));
}
else
break;
}
if ((!linha.Contains("%")) && (listaPesosOuAbscissas.Count > 0))
{
double[] p = new double[listaPesosOuAbscissas.Count];
listaPesosOuAbscissas.CopyTo(p);
pesosOuAbscissasT.Add(p);
}
}
else if (linha != null && linha.Contains("hFig"))
break;
}
for (int j = 0; j < tempos.Count; j++)
{
double[] pp = new double[pesosOuAbscissasT.Count];
for (int i = 0; i < pesosOuAbscissasT.Count; i++)
{
pp[i] = pesosOuAbscissasT[i][j];
}
pesosOuAbscissas.Add(pp);
}
tempo = new double[tempos.Count];
tempos.CopyTo(tempo);
}