本文整理汇总了C#中HashSet.SequenceEqual方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.SequenceEqual方法的具体用法?C# HashSet.SequenceEqual怎么用?C# HashSet.SequenceEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet
的用法示例。
在下文中一共展示了HashSet.SequenceEqual方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnAllZones
public void ReturnAllZones()
{
_client.Id = _noipClientId;
_client.Key = _noipClientKey;
Assert.IsTrue(_client.IsRegistered);
using (ShimsContext.Create())
{
ShimWebClient.AllInstances.DownloadStringString = (client, s) =>
@"
<?xml version=""1.0"" ?>
<noip_host_list email=""fakeEmail"" enhanced=""false"" webserver="""">
<domain name=""NoIPDDNS"" type=""plus"">
<host name=""Host1"" group="""" wildcard=""false"" ></host>
</domain>
</noip_host_list>
";
var results = _client.GetZones() as HashSet<Zone>;
var expectedResults = new HashSet<Zone>
{
new Zone("NoIPDDNS", ZoneType.Plus)
};
Assert.IsNotNull(results);
Assert.IsTrue(expectedResults.SequenceEqual(results));
}
}
示例2: DefaultComparerOfTypeIsUsedRegardlessOfCollection
public void DefaultComparerOfTypeIsUsedRegardlessOfCollection()
{
ICollection<string> set = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"abc",
};
Assert.IsTrue(set.Contains("ABC"));
Assert.AreEqual(1, set.Count);
Assert.IsFalse(set.SequenceEqual(new[] { "ABC" }));
}
示例3: AddingGroupUpdatesLastAcceddedOnLastModifiedOn
public void AddingGroupUpdatesLastAcceddedOnLastModifiedOn()
{
Smock.Run(ctx =>
{
// Assign
Init();
var expectedGroup = new HashSet<Group> { new Group(TestConstants.GROUP_NAME + "`") };
// Shim
var utcNow = DateTime.UtcNow.AddMonths(18);
ctx.Setup(() => DateTime.UtcNow).Returns(utcNow);
// Act
_group.Groups.Add(expectedGroup.First());
// Assert
Assert.IsTrue(expectedGroup.SequenceEqual(_group.Groups));
Assert.AreEqual(utcNow, _group.LastAccessedOn);
Assert.AreEqual(utcNow, _group.LastModifiedOn);
});
}
示例4: AddingEntryUpdatesLastAccessOnLastModifiedOn
public void AddingEntryUpdatesLastAccessOnLastModifiedOn()
{
Smock.Run(ctx =>
{
// Assign
Init();
var expectedEntry = new HashSet<Entry> { new Entry() };
// Shim
var utcNow = DateTime.UtcNow.AddMonths(18);
ctx.Setup(() => DateTime.UtcNow).Returns(utcNow);
// Act
_group.Entries.Add(expectedEntry.First());
// Assert
Assert.IsTrue(expectedEntry.SequenceEqual(_group.Entries));
Assert.AreEqual(utcNow, _group.LastAccessedOn);
Assert.AreEqual(utcNow, _group.LastModifiedOn);
});
}
示例5: ReturnAllZonesWithBadPasswordAndThrowException
public void ReturnAllZonesWithBadPasswordAndThrowException()
{
_client.Id = _noipClientId;
_client.Key = "BadPass";
Assert.IsTrue(_client.IsRegistered);
using (ShimsContext.Create())
{
ShimWebClient.AllInstances.DownloadStringString = (client, s) => @"bad password";
var results = _client.GetZones() as HashSet<Zone>;
var expectedResults = new HashSet<Zone>
{
new Zone("NoIPDDNS", ZoneType.Plus)
};
Assert.IsNotNull(results);
Assert.IsTrue(expectedResults.SequenceEqual(results));
}
}
示例6: TestIndirectRecursionLoop3
public void TestIndirectRecursionLoop3()
{
Grammar g = new Grammar(
"parser grammar t;\n" +
"s : a ;\n" +
"a : i b X ;\n" + // should see through i
"b : a B ;\n" +
"i : ;\n" +
"d : e ;\n" +
"e : d ;\n" );
DecisionProbe.verbose = true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.SetErrorListener( equeue );
var leftRecursive = g.GetLeftRecursiveRules();
var expectedRules = new HashSet<string>() { "a", "b", "d", "e" };
Assert.IsTrue( expectedRules.SequenceEqual( ruleNames( leftRecursive ) ) );
Assert.AreEqual(1, equeue.errors.Count);
Message msg = equeue.errors[0];
Assert.IsTrue(msg is LeftRecursionCyclesMessage, "expecting left recursion cycles; found " + msg.GetType().Name);
LeftRecursionCyclesMessage cyclesMsg = (LeftRecursionCyclesMessage)msg;
// cycle of [a, b]
ICollection result = cyclesMsg.cycles;
var expecting = new HashSet<string>() { "a", "b", "d", "e" };
Assert.IsTrue( expecting.SequenceEqual( ruleNames2( result ) ) );
}
示例7: TestIndirectRecursionLoop
public void TestIndirectRecursionLoop()
{
Grammar g = new Grammar(
"parser grammar t;\n" +
"s : a ;\n" +
"a : b X ;\n" +
"b : a B ;\n" );
DecisionProbe.verbose = true; // make sure we get all error info
ErrorQueue equeue = new ErrorQueue();
ErrorManager.SetErrorListener( equeue );
HashSet<Rule> leftRecursive = g.GetLeftRecursiveRules();
//Set expectedRules =
// new HashSet() {{add("a"); add("b");}};
var expectedRules = new HashSet<string>();
expectedRules.Add( "a" );
expectedRules.Add( "b" );
Assert.IsTrue( expectedRules.SequenceEqual( ruleNames( leftRecursive ) ) );
Assert.AreEqual(1, equeue.errors.Count);
Message msg = equeue.errors[0];
Assert.IsTrue(msg is LeftRecursionCyclesMessage, "expecting left recursion cycles; found " + msg.GetType().Name);
LeftRecursionCyclesMessage cyclesMsg = (LeftRecursionCyclesMessage)msg;
// cycle of [a, b]
ICollection result = cyclesMsg.cycles;
var expecting = new HashSet<string>(); //{{add("a"); add("b");}};
expecting.Add( "a" );
expecting.Add( "b" );
Assert.IsTrue( expecting.SequenceEqual( ruleNames2( result ) ) );
}
示例8: TestIndirectLeftRecursion
public void TestIndirectLeftRecursion()
{
Grammar g = new Grammar(
"parser grammar t;\n" +
"s : a ;\n" +
"a : b | A ;\n" +
"b : c ;\n" +
"c : a | C ;\n" );
var leftRecursive = g.GetLeftRecursiveRules();
//Set expectedRules = new HashSet() {{add("a"); add("b"); add("c");}};
var expectedRules = new HashSet<string>();
expectedRules.Add( "a" );
expectedRules.Add( "b" );
expectedRules.Add( "c" );
Assert.IsTrue( expectedRules.SequenceEqual( ruleNames( leftRecursive ) ) );
}
示例9: TestimmediateLeftRecursion
public void TestimmediateLeftRecursion()
{
Grammar g = new Grammar(
"parser grammar t;\n" +
"s : a ;\n" +
"a : a A | B;" );
var leftRecursive = g.GetLeftRecursiveRules();
//Set expectedRules = new HashSet() {{add("a");}};
var expectedRules = new HashSet<string>();
expectedRules.Add( "a" );
Assert.IsTrue( expectedRules.SequenceEqual( ruleNames( leftRecursive ) ) );
}
示例10: TestHoistedGatedSynPred2
public void TestHoistedGatedSynPred2()
{
Grammar g = new Grammar(
"parser grammar t;\n" +
"x : (X)=> (X|Y)\n" +
" | X\n" +
" ;\n");
string expecting =
".s0-X->.s1" + NewLine +
".s0-Y&&{synpred1_t}?->:s2=>1" + NewLine +
".s1-{synpred1_t}?->:s2=>1" + NewLine +
".s1-{true}?->:s3=>2" + NewLine;
int[] unreachableAlts = null;
int[] nonDetAlts = null;
string ambigInput = null;
int[] danglingAlts = null;
int numWarnings = 0;
checkDecision(g, 1, expecting, unreachableAlts,
nonDetAlts, ambigInput, danglingAlts, numWarnings);
HashSet<string> preds = g.synPredNamesUsedInDFA;
HashSet<string> expectedPreds = new HashSet<string>(); //{{add("synpred1_t");}};
expectedPreds.Add("synpred1_t");
Assert.IsTrue(expectedPreds.SequenceEqual(preds), "predicate names not recorded properly in grammar");
}
示例11: TestCycleInsideRuleDoesNotForceInfiniteRecursion
public void TestCycleInsideRuleDoesNotForceInfiniteRecursion()
{
Grammar g = new Grammar(
"parser grammar t;\n" +
"s : a ;\n" +
"a : (A|)+ B;\n" );
// before I added a visitedStates thing, it was possible to loop
// forever inside of a rule if there was an epsilon loop.
var leftRecursive = g.GetLeftRecursiveRules();
var expectedRules = new HashSet<Rule>();
Assert.IsTrue( expectedRules.SequenceEqual( leftRecursive ) );
}
示例12: RunTestsOfJUUTTestClassWithFailingTestMethod
public void RunTestsOfJUUTTestClassWithFailingTestMethod()
{
TestClassSession session = new TestClassSession(typeof(TestClassMockWithFailingTestMethod));
session.AddAll();
TestRunner runner = new SimpleTestRunner();
ClassReport classReport = runner.Run(session);
AssertThatTheMethodsAreCalledInTheCorrectOrderAfterRunningATestWithFailingTestMethod();
//Checking the returned test reports
ICollection<MethodReport> reports = classReport.MethodReports;
ICollection<MethodReport> expectedReports = new HashSet<MethodReport>();
expectedReports.Add(new MethodReport(typeof(TestClassMockWithFailingTestMethod).GetMethod("FailingTest"),
new NullReferenceException("Failing test method.")));
expectedReports.Add(new MethodReport(typeof(TestClassMockWithFailingTestMethod).GetMethod("WorkingTest")));
AssertEx.That(reports.Count, Is.EqualTo(2));
Assert.IsTrue(expectedReports.SequenceEqual(reports));
}
示例13: TestComplicated
public void TestComplicated()
{
AbstractJobProcessor jobProcessor = new SimpleJobProcessor();
var job = new Job();
var runTimes = new List<DateTime>();
jobProcessor.JobStarted += (object s, JobEventArgs a) => runTimes.Add(a.DateTime);
job.Settings = new ScheduleSettings();
job.Settings.StartDate = new DateTime(2014, 11, 20);
job.Settings.SetFrequency(ReccurPeriodTimeUnit.Weekly, 1);
job.Settings.ActiveWeekDays.Add(DayOfWeek.Monday);
job.Settings.ActiveWeekDays.Add(DayOfWeek.Wednesday);
job.Settings.DailyFrequency.PeriodTimeUnit = DailyFrequency.TimeUnit.Hour;
job.Settings.DailyFrequency.PeriodTimeUnitCount = 7;
job.Settings.DailyFrequency.EndingAt = new TimeSpan(hours: 20, minutes: 0, seconds: 0);
job.Settings.EndDate = new DateTime(2015, 5, 10);
job.Settings.HasEndDate = true;
var allDates = new HashSet<DateTime>();
for (var dt = new DateTime(2014, 10, 20).AddMinutes(-1);
dt < new DateTime(2015, 10, 2); dt = dt.AddMinutes(15))
{
jobProcessor.RunIfTime(job, dt);
if (dt < job.Settings.StartDate)
continue;
if (job.Settings.ActiveWeekDays.Contains(dt.DayOfWeek) && !allDates.Contains(dt.Date)
&& dt <= job.Settings.EndDate
&& dt.TimeOfDay <= job.Settings.DailyFrequency.EndingAt.Value)
{
allDates.Add(dt.Date);
}
}
var runDates = runTimes.Select(dt => dt.Date).Distinct().ToList();
Assert.IsTrue(allDates.SequenceEqual(runDates));
Assert.AreEqual(runDates.Count * 3, runTimes.Count);
}
示例14: ReturnHostForGivenZoneAndLocallyResolveIpAddress
public void ReturnHostForGivenZoneAndLocallyResolveIpAddress()
{
_client.Id = _noipClientId;
_client.Key = _noipClientKey;
Assert.IsTrue(_client.IsRegistered);
const string shimAddress = "127.0.0.1";
using (ShimsContext.Create())
{
ShimWebClient.AllInstances.DownloadStringString = (client, s) =>
@"
<?xml version=""1.0"" ?>
<noip_host_list email=""fakeEmail"" enhanced=""false"" webserver="""">
<domain name=""NoIPDDNS"" type=""plus"">
<host name=""Host1"" group="""" wildcard=""false"" ></host>
<host name=""Host2"" group="""" wildcard=""true"" ></host>
</domain>
</noip_host_list>
";
ShimDnsClient.AllInstances.ResolveStringRecordTypeRecordClass = (dnsClient, s, arg3, arg4) =>
{
switch (s)
{
case "Host1":
return new DnsMessage
{
IsEDnsEnabled = true,
IsRecursionAllowed = true,
IsRecursionDesired = true,
ReturnCode = ReturnCode.NoError,
AnswerRecords = new List<DnsRecordBase>
{
new ARecord("Host1", 60, IPAddress.Parse(shimAddress))
}
};
case "Host2":
return new DnsMessage
{
IsEDnsEnabled = true,
IsRecursionAllowed = true,
IsRecursionDesired = true,
ReturnCode = ReturnCode.NoError,
AnswerRecords = new List<DnsRecordBase>
{
new ARecord("Host1", 60, IPAddress.Parse(shimAddress))
}
};
default:
return null;
}
};
_client.Dns = new DnsResolver();
var zones = _client.GetZones();
var results = _client.GetHosts(zones.First());
var expectedResults = new HashSet<Host>
{
new Host("Host1") {Address = IPAddress.Parse(shimAddress)},
new Host("Host2") {Address = IPAddress.Parse(shimAddress), Wildcard = true}
};
Assert.IsNotNull(results);
Assert.IsTrue(expectedResults.SequenceEqual(results));
}
}