Пример #1
0
        public static Testing.Commons.ServiceStack.v3.HostTesterBase FullThrottle(this Testing.Commons.ServiceStack.v3.HostTesterBase tester)
        {
            var throttler = Substitute.For <IRequestThrottler>();

            tester.Replacing(throttler);
            return(tester);
        }
Пример #2
0
        public static Testing.Commons.ServiceStack.v3.HostTesterBase DisableEnforcer(this Testing.Commons.ServiceStack.v3.HostTesterBase tester)
        {
            var enforcer = Substitute.For <IHttpsEnforcer>();

            tester.Replacing(enforcer);
            return(tester);
        }
Пример #3
0
        public static HttpResponse Get(this Testing.Commons.ServiceStack.v3.HostTesterBase tester, NameValueCollection query)
        {
            var client = new HttpClient(tester.BaseUrl.ToString());

            string qs = string.Concat("?",
                                      string.Join("&", query.AllKeys.Select(k => k + "=" + query[k])));
            HttpResponse response = client.Get(AServiceUrl + qs);

            return(response);
        }
Пример #4
0
        public static HttpResponse Get(this Testing.Commons.ServiceStack.v3.HostTesterBase tester, Action <HttpClient> setup = null)
        {
            var client = new HttpClient(tester.BaseUrl.ToString());

            if (setup != null)
            {
                setup(client);
            }
            HttpResponse response = client.Get(AServiceUrl);

            return(response);
        }
Пример #5
0
        public static void Throttle(this Testing.Commons.ServiceStack.v3.HostTesterBase tester, ushort numberOfRequests, TimeSpan period)
        {
            var configuration = new ThrottlingConfiguration
            {
                NumberOfRequests = numberOfRequests,
                Period           = period
            };

            var manager = Substitute.For <IResourceManager>();

            manager.Get(ThrottlingConfiguration.Key, Arg.Any <ThrottlingConfiguration>())
            .Returns(configuration);
            tester.Replacing(manager);
        }
Пример #6
0
        public static IRequestCountRepository SetupThrottling(this Testing.Commons.ServiceStack.v3.HostTesterBase tester, ushort numberOfRequests, TimeSpan period, RequestCount count = null)
        {
            var configuration = new ThrottlingConfiguration
            {
                NumberOfRequests = numberOfRequests,
                Period           = period
            };

            var manager = Substitute.For <IResourceManager>();

            manager.Get(ThrottlingConfiguration.Key, Arg.Any <ThrottlingConfiguration>())
            .Returns(configuration);
            tester.Replacing(manager);

            var repository = Substitute.For <IRequestCountRepository>();

            if (count != null)
            {
                repository.Get(Arg.Any <ApiKey>()).Returns(count);
            }
            tester.Replacing(repository);
            return(repository);
        }
Пример #7
0
        public static HttpResponse Get(this Testing.Commons.ServiceStack.v3.HostTesterBase tester, HttpClient client)
        {
            HttpResponse response = client.Get(AServiceUrl);

            return(response);
        }
Пример #8
0
        public static Testing.Commons.ServiceStack.v3.HostTesterBase DisableAuthentication(this Testing.Commons.ServiceStack.v3.HostTesterBase tester)
        {
            var authenticator = Substitute.For <IApiAuthenticator>();

            tester.Replacing(authenticator);
            return(tester);
        }