mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 08:55:28 +08:00 
			
		
		
		
	Removed unused usings, removed empty spaces, removed tons os warnings (#903)
This commit is contained in:
		@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Security.Claims;
 | 
			
		||||
    using Ocelot.Infrastructure.Claims.Parser;
 | 
			
		||||
    using Responses;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Security.Claims;
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
@@ -119,6 +119,6 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        {
 | 
			
		||||
            _result.Data.ShouldBe(expected.Data);
 | 
			
		||||
            _result.IsError.ShouldBe(expected.IsError);
 | 
			
		||||
        } 
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,12 +17,12 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        public HttpDataRepositoryTests()
 | 
			
		||||
        {
 | 
			
		||||
            _httpContext = new DefaultHttpContext();
 | 
			
		||||
            _httpContextAccessor = new HttpContextAccessor{HttpContext = _httpContext};
 | 
			
		||||
            _httpContextAccessor = new HttpContextAccessor { HttpContext = _httpContext };
 | 
			
		||||
            _httpDataRepository = new HttpDataRepository(_httpContextAccessor);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*
 | 
			
		||||
        TODO - Additional tests -> Type mistmatch aka Add string, request int 
 | 
			
		||||
        TODO - Additional tests -> Type mistmatch aka Add string, request int
 | 
			
		||||
        TODO - Additional tests -> HttpContent null. This should never happen
 | 
			
		||||
        */
 | 
			
		||||
 | 
			
		||||
@@ -72,9 +72,9 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        private void ThenTheResultIsAnErrorReposnse<T>(object resultValue)
 | 
			
		||||
        {
 | 
			
		||||
            _result.ShouldBeOfType<ErrorResponse<T>>();
 | 
			
		||||
            ((ErrorResponse<T>) _result).Data.ShouldBeNull();
 | 
			
		||||
            ((ErrorResponse<T>)_result).Data.ShouldBeNull();
 | 
			
		||||
            ((ErrorResponse<T>)_result).IsError.ShouldBe(true);
 | 
			
		||||
            ((ErrorResponse<T>) _result).Errors.ShouldHaveSingleItem()
 | 
			
		||||
            ((ErrorResponse<T>)_result).Errors.ShouldHaveSingleItem()
 | 
			
		||||
                .ShouldBeOfType<CannotFindDataError>()
 | 
			
		||||
                .Message.ShouldStartWith("Unable to find data for key: ");
 | 
			
		||||
        }
 | 
			
		||||
@@ -85,4 +85,4 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
            ((OkResponse<T>)_result).Data.ShouldBe(resultValue);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Ocelot.Infrastructure;
 | 
			
		||||
using Shouldly;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
@@ -18,7 +18,8 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        public async Task should_publish_with_delay()
 | 
			
		||||
        {
 | 
			
		||||
            var called = false;
 | 
			
		||||
            _bus.Subscribe(x => {
 | 
			
		||||
            _bus.Subscribe(x =>
 | 
			
		||||
            {
 | 
			
		||||
                called = true;
 | 
			
		||||
            });
 | 
			
		||||
            _bus.Publish(new object(), 1);
 | 
			
		||||
@@ -30,7 +31,8 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        public void should_not_be_publish_yet_as_no_delay_in_caller()
 | 
			
		||||
        {
 | 
			
		||||
            var called = false;
 | 
			
		||||
            _bus.Subscribe(x => {
 | 
			
		||||
            _bus.Subscribe(x =>
 | 
			
		||||
            {
 | 
			
		||||
                called = true;
 | 
			
		||||
            });
 | 
			
		||||
            _bus.Publish(new object(), 1);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,6 @@
 | 
			
		||||
namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
{
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Net;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Infrastructure;
 | 
			
		||||
    using Ocelot.Infrastructure.RequestData;
 | 
			
		||||
@@ -11,6 +8,9 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
    using Ocelot.Request.Middleware;
 | 
			
		||||
    using Ocelot.Responses;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Net;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
    public class PlaceholdersTests
 | 
			
		||||
@@ -40,7 +40,7 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_return_remote_ip_address()
 | 
			
		||||
        {
 | 
			
		||||
            var httpContext = new DefaultHttpContext(){Connection = { RemoteIpAddress = IPAddress.Any}};
 | 
			
		||||
            var httpContext = new DefaultHttpContext() { Connection = { RemoteIpAddress = IPAddress.Any } };
 | 
			
		||||
            _accessor.Setup(x => x.HttpContext).Returns(httpContext);
 | 
			
		||||
            var result = _placeholders.Get("{RemoteIpAddress}");
 | 
			
		||||
            result.Data.ShouldBe(httpContext.Connection.RemoteIpAddress.ToString());
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,13 @@
 | 
			
		||||
using Xunit;
 | 
			
		||||
using Shouldly;
 | 
			
		||||
using Ocelot.Authorisation;
 | 
			
		||||
using Ocelot.Infrastructure.Claims.Parser;
 | 
			
		||||
using Moq;
 | 
			
		||||
using Ocelot.Authorisation;
 | 
			
		||||
using Ocelot.Errors;
 | 
			
		||||
using Ocelot.Infrastructure.Claims.Parser;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using Shouldly;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using TestStack.BDDfy;
 | 
			
		||||
using Ocelot.Errors;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
{
 | 
			
		||||
@@ -51,7 +51,7 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
            var fakeError = new FakeError();
 | 
			
		||||
            this.Given(_ => GivenTheFollowing(new ClaimsPrincipal()))
 | 
			
		||||
            .And(_ => GivenTheParserReturns(new ErrorResponse<List<string>>(fakeError)))
 | 
			
		||||
            .And(_ => GivenTheFollowing(new List<string>(){"doesntmatter"}))
 | 
			
		||||
            .And(_ => GivenTheFollowing(new List<string>() { "doesntmatter" }))
 | 
			
		||||
            .When(_ => WhenIAuthorise())
 | 
			
		||||
            .Then(_ => ThenTheFollowingIsReturned(new ErrorResponse<bool>(fakeError)))
 | 
			
		||||
            .BDDfy();
 | 
			
		||||
@@ -61,7 +61,7 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        public void should_match_scopes_and_return_ok_result()
 | 
			
		||||
        {
 | 
			
		||||
            var claimsPrincipal = new ClaimsPrincipal();
 | 
			
		||||
            var allowedScopes = new List<string>(){"someScope"};
 | 
			
		||||
            var allowedScopes = new List<string>() { "someScope" };
 | 
			
		||||
 | 
			
		||||
            this.Given(_ => GivenTheFollowing(claimsPrincipal))
 | 
			
		||||
            .And(_ => GivenTheParserReturns(new OkResponse<List<string>>(allowedScopes)))
 | 
			
		||||
@@ -76,8 +76,8 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
        {
 | 
			
		||||
            var fakeError = new FakeError();
 | 
			
		||||
            var claimsPrincipal = new ClaimsPrincipal();
 | 
			
		||||
            var allowedScopes = new List<string>(){"someScope"};
 | 
			
		||||
            var userScopes = new List<string>(){"anotherScope"};
 | 
			
		||||
            var allowedScopes = new List<string>() { "someScope" };
 | 
			
		||||
            var userScopes = new List<string>() { "anotherScope" };
 | 
			
		||||
 | 
			
		||||
            this.Given(_ => GivenTheFollowing(claimsPrincipal))
 | 
			
		||||
            .And(_ => GivenTheParserReturns(new OkResponse<List<string>>(userScopes)))
 | 
			
		||||
@@ -112,12 +112,12 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
            _result.Data.ShouldBe(expected.Data);
 | 
			
		||||
            _result.IsError.ShouldBe(expected.IsError);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class FakeError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public FakeError() : base("fake error", OcelotErrorCode.CannotAddDataError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
      public class FakeError : Error
 | 
			
		||||
        {
 | 
			
		||||
            public FakeError() : base("fake error", OcelotErrorCode.CannotAddDataError)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using Xunit;
 | 
			
		||||
using Ocelot.Infrastructure.Extensions;
 | 
			
		||||
using Ocelot.Infrastructure.Extensions;
 | 
			
		||||
using Shouldly;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Infrastructure
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user