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


C# NameValueCollection.Create方法代码示例

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


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

示例1: ShouldSetDoubleProperty

        public void ShouldSetDoubleProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection["DoubleValue"] = "12.34";

            TestClass instance = collection.Create<TestClass>();

            Assert.AreEqual(12.34, instance.DoubleValue, "The Double property was not set.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:9,代码来源:NameValueCollectionExtentionsTester.cs

示例2: ShouldSetByteProperty

        public void ShouldSetByteProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection["ByteValue"] = "123";

            TestClass instance = collection.Create<TestClass>();

            Assert.AreEqual(123, instance.ByteValue, "The Byte property was not set.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:9,代码来源:NameValueCollectionExtentionsTester.cs

示例3: ShouldIgnoreNonGenericArrayProperty

        public void ShouldIgnoreNonGenericArrayProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("NonGenericArray", "Hello");
            collection.Add("NonGenericArray", "World");

            TestClass instance = collection.Create<TestClass>();

            Assert.IsNull(instance.NonGenericArray, "The Array should have been ignored.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:10,代码来源:NameValueCollectionExtentionsTester.cs

示例4: ShouldBuildUserEntity

        public void ShouldBuildUserEntity()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("testuserid", "123");
            collection.Add("username", "tparks");
            collection.Add("birthday", "7-04-1933");
            collection.Add("totalposts", null);
            collection.Add("posts", "This is my first post");
            collection.Add("posts", "I really like toast");

            TestUser instance = collection.Create<TestUser>();

            Assert.AreEqual(123, instance.TestUserId, "The user ID was wrong.");
            Assert.AreEqual("tparks", instance.UserName, "The user name was wrong.");
            Assert.AreEqual(new DateTime(1933, 07, 04), instance.Birthday, "The birthday was wrong.");
            Assert.IsNull(instance.TotalPosts, "The total post should be null.");
            var expectedPosts = new string[] { "This is my first post", "I really like toast" };
            CollectionAssert.AreEquivalent(expectedPosts, instance.Posts, "The posts were not set.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:19,代码来源:NameValueCollectionExtentionsTester.cs

示例5: ShouldSetStringSetProperty

        public void ShouldSetStringSetProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("StringSet", "Hello");
            collection.Add("StringSet", "World");

            TestClass instance = collection.Create<TestClass>();
            HashSet<string> expected = new HashSet<string>() { "Hello", "World" };

            Assert.IsTrue(expected.SetEquals(instance.StringSet), "The values were not set in a HashSet.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:11,代码来源:NameValueCollectionExtentionsTester.cs

示例6: ShouldSetStringProperty

        public void ShouldSetStringProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection["StringValue"] = "Test";

            TestClass instance = collection.Create<TestClass>();

            Assert.AreEqual("Test", instance.StringValue, "The String property was not set.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:9,代码来源:NameValueCollectionExtentionsTester.cs

示例7: ShouldSetStringListProperty

        public void ShouldSetStringListProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("StringList", "Hello");
            collection.Add("StringList", "World");

            TestClass instance = collection.Create<TestClass>();
            List<string> expected = new List<string>() { "Hello", "World" };

            CollectionAssert.AreEqual(expected, instance.StringList, "The values were not set in a List<string>.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:11,代码来源:NameValueCollectionExtentionsTester.cs

示例8: ShouldSetStringIListProperty

        public void ShouldSetStringIListProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("StringIList", "Hello");
            collection.Add("StringIList", "World");

            TestClass instance = collection.Create<TestClass>();
            string[] expected = new string[] { "Hello", "World" };

            Assert.IsInstanceOfType(instance.StringIList, typeof(List<string>), "The collection should be a List<string>.");
            CollectionAssert.AreEqual(expected, (List<string>)instance.StringIList, "The values were not set in an IList.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:12,代码来源:NameValueCollectionExtentionsTester.cs

示例9: ShouldSetStringArrayProperty

        public void ShouldSetStringArrayProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("StringArray", "Hello");
            collection.Add("StringArray", "World");

            TestClass instance = collection.Create<TestClass>();
            string[] expected = new string[] { "Hello", "World" };

            CollectionAssert.AreEqual(expected, instance.StringArray, "The values were not set in an string[].");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:11,代码来源:NameValueCollectionExtentionsTester.cs

示例10: ShouldSetNullableInt64Property

        public void ShouldSetNullableInt64Property()
        {
            NameValueCollection collection = new NameValueCollection();
            collection["NullableInt64Value"] = "123";

            TestClass instance = collection.Create<TestClass>();

            Assert.AreEqual(123, instance.NullableInt64Value, "The Int64 property was not set.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:9,代码来源:NameValueCollectionExtentionsTester.cs

示例11: ShouldSetNullableInt32SetProperty

        public void ShouldSetNullableInt32SetProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("NullableInt32Set", "123");
            collection.Add("NullableInt32Set", "345");

            TestClass instance = collection.Create<TestClass>();
            HashSet<int?> expected = new HashSet<int?>() { 123, 345 };

            Assert.IsTrue(expected.SetEquals(instance.NullableInt32Set), "The values were not set in a HashSet.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:11,代码来源:NameValueCollectionExtentionsTester.cs

示例12: ShouldSetNullableInt32ListProperty

        public void ShouldSetNullableInt32ListProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("NullableInt32List", "123");
            collection.Add("NullableInt32List", "345");

            TestClass instance = collection.Create<TestClass>();
            List<int?> expected = new List<int?>() { 123, 345 };

            CollectionAssert.AreEqual(expected, instance.NullableInt32List, "The values were not set in a List<int?>.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:11,代码来源:NameValueCollectionExtentionsTester.cs

示例13: ShouldSetNullableInt32IListProperty

        public void ShouldSetNullableInt32IListProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("NullableInt32IList", "123");
            collection.Add("NullableInt32IList", "345");

            TestClass instance = collection.Create<TestClass>();
            int?[] expected = new int?[] { 123, 345 };

            Assert.IsInstanceOfType(instance.NullableInt32IList, typeof(List<int?>), "The collection should be a List<int?>.");
            CollectionAssert.AreEqual(expected, (List<int?>)instance.NullableInt32IList, "The values were not set in an IList.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:12,代码来源:NameValueCollectionExtentionsTester.cs

示例14: ShouldSetNullableInt32ArrayProperty

        public void ShouldSetNullableInt32ArrayProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("NullableInt32Array", "123");
            collection.Add("NullableInt32Array", "345");

            TestClass instance = collection.Create<TestClass>();
            int?[] expected = new int?[] { 123, 345 };

            CollectionAssert.AreEqual(expected, instance.NullableInt32Array, "The values were not set in an int?[].");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:11,代码来源:NameValueCollectionExtentionsTester.cs

示例15: ShouldSetNullableDecimalProperty

        public void ShouldSetNullableDecimalProperty()
        {
            NameValueCollection collection = new NameValueCollection();
            collection["NullableDecimalValue"] = "12.34";

            TestClass instance = collection.Create<TestClass>();

            Assert.AreEqual(12.34m, instance.NullableDecimalValue, "The Decimal property was not set.");
        }
开发者ID:jehugaleahsa,项目名称:NRest,代码行数:9,代码来源:NameValueCollectionExtentionsTester.cs


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