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


C# MockHeaders类代码示例

本文整理汇总了C#中MockHeaders的典型用法代码示例。如果您正苦于以下问题:C# MockHeaders类的具体用法?C# MockHeaders怎么用?C# MockHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: IsReadOnly_CallProperty_AlwaysFalse

        public void IsReadOnly_CallProperty_AlwaysFalse()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(string)));
            HttpHeaderValueCollection<string> collection = new HttpHeaderValueCollection<string>(knownHeader, headers);

            Assert.False(collection.IsReadOnly);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:HttpHeaderValueCollectionTest.cs

示例2: Add_CallWithNullValue_Throw

        public void Add_CallWithNullValue_Throw()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            Assert.Throws<ArgumentNullException>(() => { collection.Add(null); });
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:HttpHeaderValueCollectionTest.cs

示例3: TryAddWithoutValidation_UseInvalidHeader_False

        public void TryAddWithoutValidation_UseInvalidHeader_False()
        {
            MockHeaders headers = new MockHeaders();

            // Spaces are not allowed in header names. This test is used to validate private method
            // HttpHeaders.CheckHeaders(). Since that helper method is used in all other public methods, this
            // test is not repeated for other public methods.
            Assert.False(headers.TryAddWithoutValidation("invalid header", "value"));
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:9,代码来源:HttpHeadersTest.cs

示例4: TryAddWithoutValidation_AddSingleValue_ValueParsed

        public void TryAddWithoutValidation_AddSingleValue_ValueParsed()
        {
            MockHeaders headers = new MockHeaders();
            headers.TryAddWithoutValidation(knownHeader, rawPrefix);

            Assert.Equal(1, headers.Count());
            Assert.Equal(1, headers.First().Value.Count());
            Assert.Equal(parsedPrefix, headers.First().Value.First());

            Assert.Equal(1, headers.Parser.TryParseValueCallCount);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:11,代码来源:HttpHeadersTest.cs

示例5: Add_AddValues_AllValuesAdded

        public void Add_AddValues_AllValuesAdded()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers,
                specialValue);

            collection.Add(new Uri("http://www.example.org/1/"));
            collection.Add(new Uri("http://www.example.org/2/"));
            collection.Add(new Uri("http://www.example.org/3/"));

            Assert.Equal(3, collection.Count);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:HttpHeaderValueCollectionTest.cs

示例6: TryAddWithoutValidation_AddTwoSingleValues_BothValuesParsed

        public void TryAddWithoutValidation_AddTwoSingleValues_BothValuesParsed()
        {
            MockHeaders headers = new MockHeaders();
            headers.TryAddWithoutValidation(knownHeader, rawPrefix + "1");
            headers.TryAddWithoutValidation(knownHeader, rawPrefix + "2");

            Assert.Equal(0, headers.Parser.TryParseValueCallCount);

            Assert.Equal(1, headers.Count());
            Assert.Equal(2, headers.First().Value.Count());

            Assert.Equal(parsedPrefix + "1", headers.First().Value.ElementAt(0));
            Assert.Equal(parsedPrefix + "2", headers.First().Value.ElementAt(1));

            Assert.Equal(2, headers.Parser.TryParseValueCallCount);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:16,代码来源:HttpHeadersTest.cs

示例7: TryAddWithoutValidation_AddTwoValidValuesAsOneString_BothValuesParsed

        public void TryAddWithoutValidation_AddTwoValidValuesAsOneString_BothValuesParsed()
        {
            MockHeaders headers = new MockHeaders();
            headers.TryAddWithoutValidation(knownHeader, rawPrefix + "1," + rawPrefix + "2");

            Assert.Equal(0, headers.Parser.TryParseValueCallCount);

            Assert.Equal(1, headers.Count());
            Assert.Equal(2, headers.First().Value.Count());

            Assert.Equal(parsedPrefix + "1", headers.First().Value.ElementAt(0));
            Assert.Equal(parsedPrefix + "2", headers.First().Value.ElementAt(1));

            // The parser gets called for each value in the raw string. I.e. if we have 1 raw string containing two
            // values, the parser gets called twice.
            Assert.Equal(2, headers.Parser.TryParseValueCallCount);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:17,代码来源:HttpHeadersTest.cs

示例8: Count_AddMultipleValuesThenQueryCount_ReturnsValueCountWithSpecialValues

        public void Count_AddMultipleValuesThenQueryCount_ReturnsValueCountWithSpecialValues()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(string)));
            HttpHeaderValueCollection<string> collection = new HttpHeaderValueCollection<string>(knownHeader, headers,
                "special");

            Assert.Equal(0, collection.Count);

            collection.Add("value1");
            headers.Add(knownHeader, "special");
            Assert.Equal(2, collection.Count);

            headers.Add(knownHeader, "special");
            headers.Add(knownHeader, "value2");
            headers.Add(knownHeader, "special");
            Assert.Equal(5, collection.Count);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:17,代码来源:HttpHeaderValueCollectionTest.cs

示例9: CopyTo_CallWithStartIndexPlusElementCountGreaterArrayLength_Throw

        public void CopyTo_CallWithStartIndexPlusElementCountGreaterArrayLength_Throw()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            collection.Add(new Uri("http://www.example.org/1/"));
            collection.Add(new Uri("http://www.example.org/2/"));

            Uri[] array = new Uri[2];
            
            // startIndex + Count = 1 + 2 > array.Length
            Assert.Throws<ArgumentException>(() => { collection.CopyTo(array, 1); });
        }
开发者ID:dotnet,项目名称:corefx,代码行数:13,代码来源:HttpHeaderValueCollectionTest.cs

示例10: GetEnumerator_AddValuesAndSpecialValue_AllValuesReturned

        public void GetEnumerator_AddValuesAndSpecialValue_AllValuesReturned()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers,
                specialValue);

            collection.Add(new Uri("http://www.example.org/1/"));
            collection.Add(new Uri("http://www.example.org/2/"));
            collection.SetSpecialValue();
            collection.Add(new Uri("http://www.example.org/3/"));

            System.Collections.IEnumerable enumerable = collection;

            // The special value we added above, must be part of the collection returned by GetEnumerator().
            int i = 1;
            bool specialFound = false;
            foreach (var item in enumerable)
            {
                if (item.Equals(specialValue))
                {
                    specialFound = true;
                }
                else
                {
                    Assert.Equal(new Uri("http://www.example.org/" + i + "/"), item);
                    i++;
                }
            }

            Assert.True(specialFound);
            Assert.True(collection.IsSpecialValueSet, "Special value not set.");
        }
开发者ID:dotnet,项目名称:corefx,代码行数:32,代码来源:HttpHeaderValueCollectionTest.cs

示例11: IsSpecialValueSet_NoSpecialValueUsed_ReturnsFalse

        public void IsSpecialValueSet_NoSpecialValueUsed_ReturnsFalse()
        {
            // Create a new collection _without_ specifying a special value.
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers,
                null, null);

            Assert.False(collection.IsSpecialValueSet,
                "Special value is set even though collection doesn't define a special value.");
        }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:HttpHeaderValueCollectionTest.cs

示例12: GetEnumerator_NoValues_EmptyEnumerator

        public void GetEnumerator_NoValues_EmptyEnumerator()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            IEnumerator<Uri> enumerator = collection.GetEnumerator();

            Assert.False(enumerator.MoveNext(), "No items expected in enumerator.");
        }
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:HttpHeaderValueCollectionTest.cs

示例13: GetEnumerator_AddValuesAndGetEnumeratorFromInterface_AllValuesReturned

        public void GetEnumerator_AddValuesAndGetEnumeratorFromInterface_AllValuesReturned()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            collection.Add(new Uri("http://www.example.org/1/"));
            collection.Add(new Uri("http://www.example.org/2/"));
            collection.Add(new Uri("http://www.example.org/3/"));

            System.Collections.IEnumerable enumerable = collection;

            int i = 1;
            foreach (var item in enumerable)
            {
                Assert.Equal(new Uri("http://www.example.org/" + i + "/"), item);
                i++;
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:18,代码来源:HttpHeaderValueCollectionTest.cs

示例14: CopyTo_NoValues_DoesNotChangeArray

        public void CopyTo_NoValues_DoesNotChangeArray()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            Uri[] array = new Uri[4];
            collection.CopyTo(array, 0);

            for (int i = 0; i < array.Length; i++)
            {
                Assert.Null(array[i]);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:13,代码来源:HttpHeaderValueCollectionTest.cs

示例15: GetEnumerator_AddSingleValueAndGetEnumerator_AllValuesReturned

        public void GetEnumerator_AddSingleValueAndGetEnumerator_AllValuesReturned()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            collection.Add(new Uri("http://www.example.org/"));

            bool started = false;
            foreach (var item in collection)
            {
                Assert.False(started, "We have more than one element returned by the enumerator.");
                Assert.Equal(new Uri("http://www.example.org/"), item);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:14,代码来源:HttpHeaderValueCollectionTest.cs


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