本文整理汇总了C#中HashSet.Should方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.Should方法的具体用法?C# HashSet.Should怎么用?C# HashSet.Should使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet
的用法示例。
在下文中一共展示了HashSet.Should方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_getting_a_new_identifier_multiple_times_they_should_all_be_unique
public void When_getting_a_new_identifier_multiple_times_they_should_all_be_unique()
{
var generator = new BasicGuidGenerator();
var identifiers = new HashSet<Guid>();
for (int i = 0; i < 500; i++)
{
var newId = generator.GenerateNewId();
identifiers.Should().NotContain(newId);
identifiers.Add(newId);
}
}
示例2: ParityBetweenRequestsAndResponses
/**
* Request and Response class names should be one to one in *most* cases.
* e.g. ValidateRequest => ValidateResponse, and not ValidateQueryRequest => ValidateResponse
*/
//[U]
public void ParityBetweenRequestsAndResponses()
{
var types = Assembly.Load("Nest").GetTypes();
var requests = new HashSet<string>(types
.Where(t => t.IsClass && !t.IsAbstract && typeof(IRequest).IsAssignableFrom(t) && !(t.Name.EndsWith("Descriptor")))
.Select(t => t.Name.Split('`')[0].Replace("Request", ""))
);
var responses = types
.Where(t => t.IsClass && !t.IsAbstract && typeof(IResponse).IsAssignableFrom(t))
.Select(t => t.Name.Split('`')[0].Replace("Response", ""));
// Add any exceptions to the rule here
var exceptions = new string[] { "Cat" };
responses = responses.Where(r => !exceptions.Contains(r)).ToList();
foreach (var response in responses)
requests.Should().Contain(response);
}
示例3: PartialDelete
public void PartialDelete()
{
using (var tmp = new TempDirectory())
{
var dir = new LocalFileSystemDirectory(tmp);
Directory.CreateDirectory(Path.Combine(tmp, "dir1"));
Directory.CreateDirectory(Path.Combine(tmp, "dir1", "dir2"));
using (var f = File.CreateText(Path.Combine(tmp, "dir1", "file.delete")))
f.WriteLine("test");
using (var f = File.CreateText(Path.Combine(tmp, "dir1", "file.keep")))
f.WriteLine("test");
using (var f = File.CreateText(Path.Combine(tmp, "dir1", "dir2", "file.delete")))
f.WriteLine("test");
var paths = new HashSet<string>();
dir.Delete(p =>
{
paths.Add(p);
return false;
});
paths.Should().HaveCount(3);
paths.Should().Contain(Path.Combine("dir1", "file.delete"));
paths.Should().Contain(Path.Combine("dir1", "file.keep"));
paths.Should().Contain(Path.Combine("dir1", "dir2", "file.delete"));
Directory.Exists(tmp).Should().BeTrue();
Directory.Exists(Path.Combine(tmp, "dir1")).Should().BeTrue();
Directory.Exists(Path.Combine(tmp, "dir1", "dir2")).Should().BeTrue();
File.Exists(Path.Combine(tmp, "dir1", "file.delete")).Should().BeTrue();
File.Exists(Path.Combine(tmp, "dir1", "file.keep")).Should().BeTrue();
File.Exists(Path.Combine(tmp, "dir1", "dir2", "file.delete")).Should().BeTrue();
paths.Clear();
dir.Delete(p =>
{
paths.Add(p);
return !p.EndsWith(".keep", System.StringComparison.InvariantCulture);
});
paths.Should().HaveCount(4);
paths.Should().Contain(Path.Combine("dir1", "file.delete"));
paths.Should().Contain(Path.Combine("dir1", "file.keep"));
paths.Should().Contain(Path.Combine("dir1", "dir2"));
paths.Should().Contain(Path.Combine("dir1", "dir2", "file.delete"));
Directory.Exists(tmp).Should().BeTrue();
Directory.Exists(Path.Combine(tmp, "dir1")).Should().BeTrue();
Directory.Exists(Path.Combine(tmp, "dir1", "dir2")).Should().BeFalse();
File.Exists(Path.Combine(tmp, "dir1", "file.delete")).Should().BeFalse();
File.Exists(Path.Combine(tmp, "dir1", "file.keep")).Should().BeTrue();
File.Exists(Path.Combine(tmp, "dir1", "dir2", "file.delete")).Should().BeFalse();
paths.Clear();
dir.Delete(p =>
{
paths.Add(p);
return true;
});
paths.Should().HaveCount(3);
paths.Should().Contain(Path.Combine("dir1", "file.keep"));
paths.Should().Contain("dir1");
paths.Should().Contain("");
Directory.Exists(tmp).Should().BeFalse();
}
}
示例4: RemoteRouter_must_load_settings_from_config_for_local_router
public void RemoteRouter_must_load_settings_from_config_for_local_router()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(FromConfig.Instance.Props(EchoActorProps), "round");
var replies = CollectRouteePaths(probe, router, 10);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(5);
masterSystem.Stop(router);
}
示例5: RemoteRouter_must_load_settings_from_config_for_local_child_router_of_system_actor
public void RemoteRouter_must_load_settings_from_config_for_local_child_router_of_system_actor()
{
// we don't really support deployment configuration of system actors, but
// it's used for the pool of the SimpleDnsManager "/IO-DNS/inet-address"
var probe = CreateTestProbe(masterSystem);
var parent = ((ExtendedActorSystem)masterSystem).SystemActorOf(FromConfig.Instance.Props(Props.Create<Parent>()), "sys-parent");
parent.Tell(Tuple.Create(FromConfig.Instance.Props(EchoActorProps), "round"), probe);
var router = probe.ExpectMsg<IActorRef>();
var replies = CollectRouteePaths(probe, router, 10);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(6);
masterSystem.Stop(router);
}
示例6: RemoteRouter_must_let_remote_deployment_be_overridden_by_local_configuration
public void RemoteRouter_must_let_remote_deployment_be_overridden_by_local_configuration()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(
new RoundRobinPool(2)
.Props(EchoActorProps)
.WithDeploy(new Deploy(new RemoteScope(intendedRemoteAddress))), "local-blub");
router.Path.Address.ToString().Should().Be(string.Format("akka://{0}", masterSystem.Name));
var replies = CollectRouteePaths(probe, router, 5);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(2);
var parents = childred.Select(x => x.Parent).Distinct().ToList();
parents.Should().HaveCount(1);
parents.Head().Address.Should().Be(new Address("akka.tcp", sysName, "127.0.0.1", port));
childred.ForEach(x => x.Address.Should().Be(intendedRemoteAddress));
masterSystem.Stop(router);
}
示例7: RemoteRouter_must_let_remote_deployment_be_overridden_by_remote_configuration
public void RemoteRouter_must_let_remote_deployment_be_overridden_by_remote_configuration()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(
new RoundRobinPool(2)
.Props(EchoActorProps)
.WithDeploy(new Deploy(new RemoteScope(intendedRemoteAddress))), "remote-override");
router.Path.Address.Should().Be(intendedRemoteAddress);
var replies = CollectRouteePaths(probe, router, 5);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(4);
var parents = childred.Select(x => x.Parent).Distinct().ToList();
parents.Should().HaveCount(1);
parents.Head().Address.Should().Be(router.Path.Address);
childred.ForEach(x => x.Address.Should().Be(intendedRemoteAddress));
masterSystem.Stop(router);
}
示例8: RemoteRouter_must_deploy_remote_routers_based_on_configuration
public void RemoteRouter_must_deploy_remote_routers_based_on_configuration()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(FromConfig.Instance.Props(EchoActorProps), "remote-blub");
router.Path.Address.Should().Be(intendedRemoteAddress);
var replies = CollectRouteePaths(probe, router, 5);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(2);
var parents = childred.Select(x => x.Parent).Distinct().ToList();
parents.Should().HaveCount(1);
parents.Head().Should().Be(router.Path);
childred.ForEach(x => x.Address.Should().Be(intendedRemoteAddress));
masterSystem.Stop(router);
}
示例9: RemoteRouter_must_deploy_dynamic_resizable_number_of_children_on_remote_host_driven_by_configuration
public void RemoteRouter_must_deploy_dynamic_resizable_number_of_children_on_remote_host_driven_by_configuration()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(FromConfig.Instance.Props(EchoActorProps), "elastic-blub");
var replies = CollectRouteePaths(probe, router, 5);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(2);
childred.Select(x => x.Parent).Distinct().Should().HaveCount(1);
childred.ForEach(x => x.Address.Should().Be(intendedRemoteAddress));
masterSystem.Stop(router);
}
示例10: RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_programmatic_definition
public void RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_programmatic_definition()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(new RemoteRouterConfig(
new RoundRobinPool(2),
new[] { new Address("akka.tcp", sysName, "127.0.0.1", port) })
.Props(EchoActorProps), "blub2");
var replies = CollectRouteePaths(probe, router, 5);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(2);
childred.Select(x => x.Parent).Distinct().Should().HaveCount(1);
childred.ForEach(x => x.Address.Should().Be(intendedRemoteAddress));
masterSystem.Stop(router);
}
示例11: RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_configuration
public void RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_configuration()
{
var probe = CreateTestProbe(masterSystem);
var router = masterSystem.ActorOf(new RoundRobinPool(2).Props(EchoActorProps), "blub");
var replies = CollectRouteePaths(probe, router, 5);
var childred = new HashSet<ActorPath>(replies);
childred.Should().HaveCount(2);
childred.Select(x => x.Parent).Distinct().Should().HaveCount(1);
childred.ForEach(x => x.Address.Should().Be(intendedRemoteAddress));
masterSystem.Stop(router);
}
示例12: GetCommandLines_ManyTestsWithSuites_BreaksUpLongCommandLinesCorrectly
public void GetCommandLines_ManyTestsWithSuites_BreaksUpLongCommandLinesCorrectly()
{
List<string> allTests = new List<string>();
List<string> testsToExecute = new List<string>();
for (int i = 0; i < 1000; i++)
{
allTests.Add("MyTestSuite" + i + ".MyTest");
testsToExecute.Add("MyTestSuite" + i + ".MyTest");
allTests.Add("MyTestSuite" + i + ".MyTest2");
}
testsToExecute.Add("MyTestSuite1.MyTest2");
testsToExecute.Add("MyTestSuite5.MyTest2");
IEnumerable<Model.TestCase> allTestCases = allTests.Select(TestDataCreator.ToTestCase).ToList();
IEnumerable<Model.TestCase> testCases = testsToExecute.Select(TestDataCreator.ToTestCase).ToList();
List<CommandLineGenerator.Args> commands = new CommandLineGenerator(allTestCases, testCases, TestDataCreator.DummyExecutable.Length, "", "", TestEnvironment)
.GetCommandLines().ToList();
commands.Count.Should().Be(3);
int lengthOfLongestTestname = allTests.Max(s => s.Length);
int maxLength = CommandLineGenerator.MaxCommandLength - TestDataCreator.DummyExecutable.Length;
int minLength = CommandLineGenerator.MaxCommandLength - lengthOfLongestTestname - TestDataCreator.DummyExecutable.Length - 1;
string commandLine = commands[0].CommandLine;
commandLine.Length.Should().BeLessThan(maxLength);
commandLine.Length.Should().BeGreaterOrEqualTo(minLength);
commandLine.Should().StartWith([email protected]"--gtest_output=""xml:""{DefaultArgs} --gtest_filter=MyTestSuite1.*:MyTestSuite5.*:MyTestSuite0.MyTest:");
commandLine = commands[1].CommandLine;
commandLine.Length.Should().BeLessThan(maxLength);
commandLine.Length.Should().BeGreaterOrEqualTo(minLength);
commandLine.Should().NotStartWith(@"--gtest_output=""xml:"" --gtest_filter=MyTestSuite1.*:MyTestSuite5.*:");
commandLine.Should().StartWith([email protected]"--gtest_output=""xml:""{DefaultArgs} --gtest_filter=");
commandLine = commands[2].CommandLine;
commandLine.Length.Should().BeLessThan(maxLength);
commandLine.Should()
.NotStartWith([email protected]"--gtest_output=""xml:""{DefaultArgs} --gtest_filter=MyTestSuite1.*:MyTestSuite5.*:");
commandLine.Should().StartWith([email protected]"--gtest_output=""xml:""{DefaultArgs} --gtest_filter=");
HashSet<Model.TestCase> testsAsSet = new HashSet<Model.TestCase>(testCases);
HashSet<Model.TestCase> splittedTestsAsSet = new HashSet<Model.TestCase>(commands[0].TestCases.Union(commands[1].TestCases).Union(commands[2].TestCases));
splittedTestsAsSet.Should().BeEquivalentTo(testsAsSet);
}