本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.SequenceEqual方法的典型用法代码示例。如果您正苦于以下问题:C# List.SequenceEqual方法的具体用法?C# List.SequenceEqual怎么用?C# List.SequenceEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.SequenceEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEqualityBuilder
public void TestEqualityBuilder()
{
IEnumerable<Tester> a = new List<Tester>
{
new Tester(1, 2),
new Tester(3, 4),
new Tester(4, 10),
new Tester(10, 12),
new Tester(14, 432)
};
IEnumerable<Tester> b = new List<Tester>
{
new Tester(1, 2),
new Tester(3, 4),
new Tester(4, 10),
new Tester(10, 12),
new Tester(14, 432)
};
// Demonstrate that standard method returns false as references are different
Assert.IsFalse(a.SequenceEqual(b));
// Demonstrate the using an equality builder allows deeper comparison
Assert.IsTrue(a.SequenceEqual(b, new EqualityBuilder<Tester>((x, y) => x.A == y.A && x.B == y.B)));
}
示例2: GenerateFibonacciNumbersListTest
public void GenerateFibonacciNumbersListTest()
{
List<int> fibonacciNumbers = new List<int>();
fibonacciNumbers = FluentMath.Get().FibonacciNumbers.ToValue(89);
Assert.IsTrue(fibonacciNumbers.SequenceEqual(new List<int>() { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }));
fibonacciNumbers = FluentMath.Get().FibonacciNumbers.ToValue(13);
Assert.IsTrue(fibonacciNumbers.SequenceEqual(new List<int>() { 0, 1, 1, 2, 3, 5, 8, 13 }));
}
示例3: TestAdd
public void TestAdd()
{
var cpu = new CPU();
//Set initial values in register file
cpu.RegWrite(2, 10);
cpu.RegWrite(3, 255);
const string instr = "add $1, $2, $3";
cpu.AddInstruction(new Add(instr, 0, 1, 2, 3));
var expectedRecords = new List<ExecutionRecordList>();
int clockCycle = 0;
cpu.RunClock();
expectedRecords.Add(new ExecutionRecordList());
expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Fetch, instr, 0, null));
clockCycle++;
Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));
cpu.RunClock();
expectedRecords.Add(new ExecutionRecordList());
expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Decode, "Add: rd = $1, rs = $2, rt = $3", 0, null));
clockCycle++;
Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));
cpu.RunClock();
expectedRecords.Add(new ExecutionRecordList());
expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Execute, "Add 10 + 255 = 265", 0, null));
clockCycle++;
Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));
cpu.RunClock();
expectedRecords.Add(new ExecutionRecordList());
expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Memory, "None", 0, null));
clockCycle++;
Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));
cpu.RunClock();
expectedRecords.Add(new ExecutionRecordList());
expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Writeback, "Register $1 <= 265", 0, null));
clockCycle++;
Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));
//Test value inside register file
Assert.AreEqual(265, cpu.RegRead(1));
Assert.AreEqual(clockCycle, cpu.ClockCycle);
}
示例4: CategorySortComparison
public void CategorySortComparison()
{
var l = new List<Category>
{
new Category("Hello"),
new Category("Hello", "GoodBye"),
new Category("Hello", "A"),
new Category("Hello", "B"),
new Category("A"),
new Category("Z")
};
var lSorted = new List<Category>
{
new Category("A"),
new Category("Hello"),
new Category("Hello", "A"),
new Category("Hello", "B"),
new Category("Hello", "GoodBye"),
new Category("Z")
};
Assert.IsFalse(l.SequenceEqual(lSorted));
l.Sort();
Assert.IsTrue(l.SequenceEqual(lSorted));
}
示例5: CalculatedRecurrenceSetPagingWorks
public void CalculatedRecurrenceSetPagingWorks()
{
#region Arrange
var validStartDateTime = new DateTime(2014, 1, 31);
const int validMonthsBetweenOccurrences = 2;
DateTime validEndDateTime = validStartDateTime.AddMonths(9);
var validDayOfWeekMonthlyRecurrence = new DayOfWeekMonthlyRecurrence(validStartDateTime,
validMonthsBetweenOccurrences, validEndDateTime);
var expectedRecurrenceSet = new List<DateTime>
{
new DateTime(2014, 3, 28), // 3/28/2014 (March)
new DateTime(2014, 5, 30), // 5/30/2014 (May)
};
#endregion
#region Act
const int validSkip = 1;
const int validTake = 2;
IEnumerable<DateTime> recurrenceSet = validDayOfWeekMonthlyRecurrence.CalculateRecurrenceSet(validSkip,
validTake);
#endregion
#region Assert
Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet));
#endregion
}
示例6: CanFindAllIndexes
public void CanFindAllIndexes()
{
var expected = new List<int> { 1, 4, 5 };
var actual = this.array.FindAllIndexes(0, new int[0], 1);
Assert.IsTrue(expected.SequenceEqual(actual));
}
示例7: TestAdjacent
public void TestAdjacent()
{
IMatrix<string> matrix = new Matrix<string>(3, 3);
List<string> items = new List<string>(9);
for (int i = 0; i < items.Capacity; i++)
{
items.Add(string.Format("{0}", i));
}
var index = 0;
for (int y = 0; y < matrix.Rows; y++)
{
int x;
for (x = 0; x < matrix.Columns; x++)
{
matrix[x, y] = items[index++];
}
}
var middleCell = matrix[1, 1];
int middleIndex = matrix.IndexOf(middleCell);
items.RemoveAt(middleIndex);
var adjacentCells = matrix.GetAdjacentCells(middleCell);
Assert.IsTrue(items.SequenceEqual(adjacentCells));
}
示例8: CanCalculateRecurrenceSet
public void CanCalculateRecurrenceSet()
{
#region Arrange
var validStartDateTime = new DateTime(2014, 2, 18);
const int validDaysBetweenOccurrences = 3;
var validEndDateTime = validStartDateTime.AddDays(validDaysBetweenOccurrences*3);
var validDailyRecurrence = new DailyRecurrence(validStartDateTime, validDaysBetweenOccurrences,
validEndDateTime);
#endregion
#region Act
var recurrenceSet = validDailyRecurrence.CalculateRecurrenceSet();
#endregion
#region Assert
var expectedRecurrenceSet = new List<DateTime>
{
validStartDateTime,
validStartDateTime.AddDays(validDaysBetweenOccurrences*1),
validStartDateTime.AddDays(validDaysBetweenOccurrences*2),
validStartDateTime.AddDays(validDaysBetweenOccurrences*3)
};
Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet));
#endregion
}
示例9: GetAllWithFullNameTest
public void GetAllWithFullNameTest()
{
var ds = new List<string> { "DARTFORD", "LIVERPOOL", "PADDINGTON" };
var expressions = new List<string>{ "LIVERPOOL" };
var result = new DictionaryStationRepository(ds).GetAllThatStartWith("LIVERPOOL");
Assert.IsTrue(expressions.SequenceEqual(result));
}
示例10: GetAllWithMissingNameTest
public void GetAllWithMissingNameTest()
{
var ds = new List<string> { "EUSTON", "LONDON BRIDGE", "VICTORIA" };
var expressions = new List<string>(0);
var result = new DictionaryStationRepository(ds).GetAllThatStartWith("KINGS CROSS");
Assert.IsTrue(expressions.SequenceEqual(result));
}
示例11: ReturnFirst10FibonacciNumberWhenInputIs10
public void ReturnFirst10FibonacciNumberWhenInputIs10()
{
var expectedResult = new List<ulong> { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
var result = Fibonacci.GetNumbers(10);
Assert.IsTrue(expectedResult.SequenceEqual(result.Numbers),
"Expected first 10 Fibonacci numbers; got something else");
}
示例12: SerializeDeserializeList1
public void SerializeDeserializeList1()
{
var l = new List<string>();
var l2 = l.Serialize().Deserialize<List<string>>();
Assert.IsTrue(l.SequenceEqual(l2));
Assert.AreNotSame(l, l2);
}
示例13: GetAllWithPartialNameTest
public void GetAllWithPartialNameTest()
{
var ds = new List<string> { "DARTFORD", "DARTMOUTH", "TOWER HILL", "DERBY" };
var expressions = new List<string> { "DARTFORD", "DARTMOUTH" };
var result = new DictionaryStationRepository(ds).GetAllThatStartWith("DART");
Assert.IsTrue(expressions.SequenceEqual(result));
}
示例14: TestMergeKeepDuplicates
public void TestMergeKeepDuplicates()
{
var arg = new List<List<int>> { new List<int> { 1, 3, 5 }, new List<int> { -1, 1, 2, 4 }, new List<int> { 6, 7 } };
var expected = new List<int> { -1, 1, 1, 2, 3, 4, 5, 6, 7 };
var res = arg.Merge(false).ToList();
Assert.IsTrue(expected.SequenceEqual(res), "Merge of [{0}] with duplicates gives {1} instead of {2}", string.Join(", ", arg.Select(IntsToString)), IntsToString(res), IntsToString(expected));
}
示例15: CanCalculateRecurrenceSet
public void CanCalculateRecurrenceSet()
{
#region Arrange
var validStartDateTime = new DateTime(2014, 1, 31);
const int validMonthsBetweenOccurrences = 2;
DateTime validEndDateTime = validStartDateTime.AddMonths(9);
var validDayOfWeekMonthlyRecurrence = new DayOfWeekMonthlyRecurrence(validStartDateTime,
validMonthsBetweenOccurrences, validEndDateTime);
var expectedRecurrenceSet = new List<DateTime>
{
new DateTime(2014, 1, 31), // 1/31/2014 (January)
new DateTime(2014, 3, 28), // 3/28/2014 (March)
new DateTime(2014, 5, 30), // 5/30/2014 (May)
new DateTime(2014, 7, 25), // 7/25/2014 (July)
new DateTime(2014, 9, 26) // 9/26/2014 (September)
};
#endregion
#region Act
IEnumerable<DateTime> recurrenceSet = validDayOfWeekMonthlyRecurrence.CalculateRecurrenceSet();
#endregion
#region Assert
Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet));
#endregion
}