本文整理汇总了C#中System.Linq.SequenceEqual方法的典型用法代码示例。如果您正苦于以下问题:C# System.Linq.SequenceEqual方法的具体用法?C# System.Linq.SequenceEqual怎么用?C# System.Linq.SequenceEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq
的用法示例。
在下文中一共展示了System.Linq.SequenceEqual方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Shuffle
public void Can_Shuffle()
{
var items = new[] {"Foo", "Bar", "Baz", "Boo", "Alexander", "Nyquist"};
var shuffled = items.Shuffle();
Assert.IsFalse(items.SequenceEqual(shuffled));
}
示例2: SequenceEqual_compares_items_using_provided_equality_function
public void SequenceEqual_compares_items_using_provided_equality_function()
{
var first = new[] { "a", "A" };
var second = new[] { "A", "a" };
Assert.True(first.SequenceEqual(second, (a, b) => a.Equals(b, StringComparison.OrdinalIgnoreCase)));
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:DynamicEqualityComparerLinqIntegrationTests.cs
示例3: Test
public static void Test(Assert assert)
{
assert.Expect(4);
// TEST
int[] numbersA = { 4, 1, 3 };
int[] numbersB = { 2, 3, 5 };
var concatNumbers = numbersA.Concat(numbersB);
assert.DeepEqual(concatNumbers, new[] { 4, 1, 3, 2, 3, 5 }, "Concat() numbers");
// TEST
var names = from p in Person.GetPersons()
select p.Name;
var cities = from p in Person.GetPersons()
select p.City;
var concatNames = names.Concat(cities).ToArray();
assert.DeepEqual(concatNames,
new[] { "Frank", "Zeppa", "John", "Billy", "Dora", "Ian", "Mary", "Nemo",
"Edmonton", "Tokyo", "Lisbon", "Paris", "Budapest", "Rome", "Dortmund", "Ocean"},
"Concat() two sequences");
// TEST
var a = new[] { "a", "b", "z" };
var b = new[] { "a", "b", "z" };
assert.Ok(a.SequenceEqual(b), "SequenceEqual() for equal sequences");
// TEST
var c = new[] { "a", "b", "z" };
var d = new[] { "a", "z", "b" };
assert.Ok(!c.SequenceEqual(d), "SequenceEqual() for not equal sequences");
}
示例4: TranslationsFlatToTranslations
public void TranslationsFlatToTranslations()
{
var arr = new[] {"Test1", "Test2"};
var data = JsonConvert.SerializeObject(arr);
var state = new WordState { TranslationsFlat=data};
Assert.IsTrue(arr.SequenceEqual(state.Translations));
}
示例5: ShouldApplyLimitUsingTop
public void ShouldApplyLimitUsingTop()
{
var sql = "select a,b,c from d where a = 1 order by c";
var expected = new[]{ "select top 5 a,b,c from d where a = 1 order by c"};
var pagedSql = new VistaDBQueryPager().ApplyLimit(sql, 5);
var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());
Assert.IsTrue(expected.SequenceEqual(modified));
}
示例6: ShouldCopeWithAliasedDefaultSortColumn
public void ShouldCopeWithAliasedDefaultSortColumn()
{
var sql = "select [a] as [foo],[b],[c] from [d] where [a] = 1";
var expected = new[]{
"with __data as (select [a] as [foo],[b],[c], row_number() over(order by [a]) as [_#_] from [d] where [a] = 1)"
+ " select [foo],[b],[c] from __data where [_#_] between 31 and 40"};
var pagedSql = new VistaDBQueryPager().ApplyPaging(sql, 30, 10);
var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());
Assert.IsTrue(expected.SequenceEqual(modified));
}
示例7: ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered
public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
{
var sql = "select a,b,c from d where a = 1";
var expected = new[]{
"with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
+ " select a,b,c from __data where [_#_] between 11 and 30"};
var pagedSql = new VistaDBQueryPager().ApplyPaging(sql, 10, 20);
var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());
Assert.IsTrue(expected.SequenceEqual(modified));
}
示例8: GetAllTypesTest
public void GetAllTypesTest (ModuleDefinition module)
{
var sequence = new [] {
module.GetType ("<Module>"),
module.GetType ("Foo"),
module.GetType ("Foo/Bar"),
module.GetType ("Foo/Gazonk"),
module.GetType ("Foo/Gazonk/Baz"),
module.GetType ("Pan"),
};
Assert.IsTrue (sequence.SequenceEqual (module.GetAllTypes ()));
}
示例9: ShouldReturnFilePath
public void ShouldReturnFilePath()
{
var root = Client.GetFolder(FolderID.Root).ID;
var parent = Client.CreateFolder(root, "TestGetFileParent").ID;
var name = "TestGetFile";
var file = Client.CreateFile(parent, name).ID;
var path = new[] { root, parent };
var filePath = Client.GetFilePath(file);
Assert.IsNotNull(filePath);
Assert.IsTrue(path.SequenceEqual(filePath.Folders.Select(folder => folder.ID)));
}
示例10: GetAllTypesTest
public void GetAllTypesTest()
{
TestCSharp ("Types.cs", module => {
var sequence = new [] {
module.GetType ("<Module>"),
module.GetType ("Foo"),
module.GetType ("Foo/Bar"),
module.GetType ("Foo/Gazonk"),
module.GetType ("Foo/Gazonk/Baz"),
module.GetType ("Pan"),
};
Assert.IsTrue (sequence.SequenceEqual (module.GetAllTypes ()));
});
}
示例11: CollectionExtensions_Creation_Snapshot
public void CollectionExtensions_Creation_Snapshot()
{
var expected = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var result = _target.Select(x => x).Snapshot();
var resultValue = result();
Assert.IsTrue(_target.SequenceEqual(resultValue));
for (int i = 0; i < _target.Length; i++)
_target[i] *= 2;
resultValue = result();
Assert.IsTrue(expected.SequenceEqual(resultValue));
}
示例12: GetOverridenCspPluginTypesConfig_NoMediaTypesOverride_KeepsMediaTypes
public void GetOverridenCspPluginTypesConfig_NoMediaTypesOverride_KeepsMediaTypes()
{
var expectedMediaTypes = new[] { "application/pdf" };
var directiveConfig = new CspPluginTypesDirectiveConfiguration { MediaTypes = expectedMediaTypes };
var directiveOverride = new CspPluginTypesOverride { InheritMediaTypes = true };
var newConfig = _overrideHelper.GetOverridenCspPluginTypesConfig(directiveOverride, directiveConfig);
Assert.IsTrue(expectedMediaTypes.SequenceEqual(newConfig.MediaTypes), "MediaTypes differed.");
}
示例13: GetOverridenCspDirectiveConfig_NoCustomSourcesOverride_KeepsCustomSources
public void GetOverridenCspDirectiveConfig_NoCustomSourcesOverride_KeepsCustomSources()
{
var expectedSources = new[] { "www.nwebsec.com" };
var directiveConfig = new CspDirectiveConfiguration { CustomSources = expectedSources };
var directiveOverride = new CspDirectiveOverride { InheritOtherSources = true };
var newConfig = _overrideHelper.GetOverridenCspDirectiveConfig(directiveOverride, directiveConfig);
Assert.IsTrue(expectedSources.SequenceEqual(newConfig.CustomSources), "CustomSources differed.");
}