csharp/aspnet/AspNetKatana/tests/Microsoft.Owin.Host.SystemWeb.Tests/CallHeaders/AspNetRequestHeadersTests.cs

AspNetRequestHeadersTests.cs
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Linq;
using FakeN.Web;
using Microsoft.Owin.Host.SystemWeb.CallHeaders;
using Xunit;

namespace Microsoft.Owin.Host.SystemWeb.Tests.CallHeaders
{
    public clast AspNetRequestHeadersTests
    {
        [Fact]
        public void CreateEmptyRequestHeaders_Success()
        {
            var headers = new AspNetRequestHeaders(new FakeHttpRequest());

            astert.Equal(0, headers.Count);
            astert.Equal(0, headers.Count());
            foreach (var header in headers)
            {
                // Should be empty
                astert.True(false);
            }
        }

        [Fact]
        public void AddHeaders_Success()
        {
            var headers = new AspNetRequestHeaders(new FakeHttpRequest());

            headers.Add("content-length", new string[] { "a", "0" });
            astert.Equal(1, headers.Count);
            headers.Add("custom", new string[] { "ddfs", "adsfa" });
            astert.Equal(2, headers.Count);

            int count = 0;
            foreach (var header in headers)
            {
                count++;
            }
            astert.Equal(2, count);
        }
    }
}