当前位置: 首页>>代码示例>>C#>>正文


C# Guid.Should方法代码示例

本文整理汇总了C#中System.Guid.Should方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.Should方法的具体用法?C# Guid.Should怎么用?C# Guid.Should使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Guid的用法示例。


在下文中一共展示了Guid.Should方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_succeed_when_asserting_non_empty_guid_is_not_empty

        public void Should_succeed_when_asserting_non_empty_guid_is_not_empty()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var guid = new Guid("12345678-1234-1234-1234-123456789012");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => guid.Should().NotBeEmpty();

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:17,代码来源:GuidAssertionSpecs.cs

示例2: Should_fail_when_asserting_non_empty_guid_is_empty

        public void Should_fail_when_asserting_non_empty_guid_is_empty()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var guid = new Guid("12345678-1234-1234-1234-123456789012");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => guid.Should().BeEmpty("because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Expected empty Guid because we want to test the failure message, but found {12345678-1234-1234-1234-123456789012}.");
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:18,代码来源:GuidAssertionSpecs.cs

示例3: Should_fail_when_asserting_guid_equals_a_different_guid

        public void Should_fail_when_asserting_guid_equals_a_different_guid()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var guid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");
            var differentGuid = new Guid("55555555-ffff-eeee-dddd-444444444444");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => guid.Should().Be(differentGuid, "because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Expected Guid to be {55555555-ffff-eeee-dddd-444444444444} because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.");
        }
开发者ID:nbruce,项目名称:fluentassertions,代码行数:19,代码来源:GuidAssertionSpecs.cs

示例4: Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_with_a_value_to_be_null

        public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_with_a_value_to_be_null()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            Guid? nullableGuid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => nullableGuid.Should().NotHaveValue("because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage("Did not expect a value because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.");
        }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:18,代码来源:NullableGuidAssertionSpecs.cs

示例5: FullTestLikeZeroMqZyre

        public void FullTestLikeZeroMqZyre()
        {
            var node1Writer = new ConsoleLogger("node1");
            var node2Writer = new ConsoleLogger("node2");

            // Create two nodes
            using (var node1 = new Zyre("node1", false, node1Writer.ConsoleWrite))
            using (var node2 = new Zyre("node2", false, node2Writer.ConsoleWrite))
            {
                int major, minor, patch;
                node1.Version(out major, out minor, out patch);
                major.Should().Be(Zyre.ZyreVersionMajor);

                node1.Should().NotBeNull();
                node1.Name().Should().Be("node1");

                node1.SetHeader("X-HELLO", "World");

                // Start both nodes
                node1.Start();
                var uuid1 = node1.Uuid();
                uuid1.Should().NotBeEmpty();
                node1Writer.ConsoleWrite("After starting node1, Dump():");
                node1.Dump();

                node2.Should().NotBeNull();
                node2.Name().Should().Be("node2");

                node2.Start();
                var uuid2 = node2.Uuid();
                uuid1.Should().NotBe(uuid2);
                Console.WriteLine("After starting node2, Dump():");
                node2.Dump();

                //  Give time for them to interconnect. Our default is beacons every second
                Thread.Sleep(1100);
                Console.WriteLine("After Thread.Sleep(1100):");

                Console.WriteLine("node1 Joining Global");
                node1.Join("GLOBAL");
                Console.WriteLine("node2 Joining Global");
                node2.Join("GLOBAL");
                node1.Dump();
                node2.Dump();

                var node1Peers = node1.Peers();
                node1Peers.Count.Should().Be(1);

                Console.WriteLine("node1 Joining node1 group of one");
                node1.Join("node1 group of one");
                Console.WriteLine("node2 Joining node1 group of one");
                node2.Join("node2 group of one");

                // Give them time to join their groups
                Thread.Sleep(100);
                Console.WriteLine("After 2nd Thread.Sleep(100):");
                node1.Dump();
                node2.Dump();

                var peerGroups = node1.PeerGroups();
                peerGroups.Count.Should().Be(2);

                var node2Peers = node2.Peers();
                node2Peers.Count.Should().Be(1);
                var value = node2.PeerHeaderValue(uuid1, "X-HELLO");
                value.Should().Be("World");

                // One node shouts to GLOBAL
                Console.WriteLine("node1 Shouting to Global");
                node1.Shouts("GLOBAL", "Hello, World");

                // Second node should receive ENTER, JOIN, JOIN and SHOUT
                var msg = node2.Receive();
                msg.Should().NotBeNull();
                var command = msg.Pop().ConvertToString();
                command.Should().Be("ENTER");
                msg.FrameCount.Should().Be(4);
                var peerIdBytes = msg.Pop().Buffer;
                var peerId = new Guid(peerIdBytes);
                peerId.Should().Be(uuid1);
                var name = msg.Pop().ConvertToString();
                name.Should().Be("node1");

                var headersBuffer = msg.Pop().Buffer;
                var headers = Serialization.BinaryDeserialize<Dictionary<string, string>>(headersBuffer);
                var address = msg.Pop().ConvertToString();
                headers.Count.Should().Be(1);
                headers["X-HELLO"].Should().Be("World");
                address.Should().NotBeNullOrEmpty();

                msg = node2.Receive();
                msg.Should().NotBeNull();
                command = msg.Pop().ConvertToString();
                command.Should().Be("JOIN");
                msg.FrameCount.Should().Be(3);

                msg = node2.Receive();
                msg.Should().NotBeNull();
                command = msg.Pop().ConvertToString();
                command.Should().Be("JOIN");
//.........这里部分代码省略.........
开发者ID:NetMQ,项目名称:Zyre,代码行数:101,代码来源:ZreZyreTests.cs

示例6: Should_succeed_when_asserting_guid_equals_the_same_guid

        public void Should_succeed_when_asserting_guid_equals_the_same_guid()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var guid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");
            var sameGuid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => guid.Should().Be(sameGuid);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:18,代码来源:GuidAssertionSpecs.cs

示例7: Should_succeed_when_asserting_guid_does_not_equal_the_same_guid

        public void Should_succeed_when_asserting_guid_does_not_equal_the_same_guid()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var guid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");
            var sameGuid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => guid.Should().NotBe(sameGuid, "because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Did not expect Guid to be {11111111-aaaa-bbbb-cccc-999999999999} because we want to test the failure message.");
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:19,代码来源:GuidAssertionSpecs.cs

示例8: Should_succeed_when_asserting_guid_does_not_equal_a_different_guid

        public void Should_succeed_when_asserting_guid_does_not_equal_a_different_guid()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var guid = new Guid("11111111-aaaa-bbbb-cccc-999999999999");
            var differentGuid = new Guid("55555555-ffff-eeee-dddd-444444444444");

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () =>
                guid.Should().NotBe(differentGuid);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:19,代码来源:GuidAssertionSpecs.cs

示例9: AssertTestResult

        private static void AssertTestResult(XmlDocument xmlDocument, CasperJsTest test, string outcomeText, int numTest)
        {
            Guid testEntryGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[numTest].Attributes["testId"].Value, out testEntryGuid)
                .Should()
                .BeTrue();

            testEntryGuid.Should().Be(test.Id);

            Guid testExecutionIdGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[numTest].Attributes["executionId"].Value,
                          out testExecutionIdGuid)
                .Should()
                .BeTrue();
            testExecutionIdGuid.Should().Be(test.ExecutionId);

            xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[numTest].Attributes["testName"].Value.Should().Be(test.Name);
            xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[numTest].Attributes["duration"].Value.Should()
                                                                                        .Be("00:00:00.4590000");
            xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[numTest].Attributes["outcome"].Value.Should().Be(outcomeText);

            Guid testTypeIdGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[numTest].Attributes["testType"].Value, out testTypeIdGuid)
                .Should()
                .BeTrue();

            Guid testListIdGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[3].ChildNodes[0].Attributes["testListId"].Value,
                          out testListIdGuid)
                .Should()
                .BeTrue();
        }
开发者ID:vgaltes,项目名称:CasperJSCustomBuildActivity,代码行数:32,代码来源:CasperJsTrxCreatorTests.cs

示例10: ShouldCreateTwoTestEntryNodeIfThereIsTwoPassedTests

        public void ShouldCreateTwoTestEntryNodeIfThereIsTwoPassedTests()
        {
            var results = new CasperJsTestsResults();
            results.PassedTests.Add(new CasperJsTest { Name = "test name 1" });
            results.PassedTests.Add(new CasperJsTest { Name = "test name 2" });
            string trx = CasperJsTrxCreator.Create(results);

            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(trx);

            Guid testDefinitionGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["id"].Value, out testDefinitionGuid);

            Guid testEntryGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[2].ChildNodes[0].Attributes["testId"].Value, out testEntryGuid)
                .Should()
                .BeTrue();

            testDefinitionGuid.Should().Be(testEntryGuid);

            Guid testExecutionIdGuid = new Guid();
            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[2].ChildNodes[1].Attributes["executionId"].Value, out testExecutionIdGuid)
                .Should()
                .BeTrue();

            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[1].ChildNodes[1].Attributes["id"].Value, out testDefinitionGuid);

            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[2].ChildNodes[1].Attributes["testId"].Value, out testEntryGuid)
                .Should()
                .BeTrue();

            testDefinitionGuid.Should().Be(testEntryGuid);

            Guid.TryParse(xmlDocument.ChildNodes[1].ChildNodes[2].ChildNodes[1].Attributes["executionId"].Value, out testExecutionIdGuid)
                .Should()
                .BeTrue();
        }
开发者ID:vgaltes,项目名称:CasperJSCustomBuildActivity,代码行数:37,代码来源:CasperJsTrxCreatorTests.cs


注:本文中的System.Guid.Should方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。