Пример #1
0
        public void GetAuthorizationDetectionMethod(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] AuthorizationComponent sut,
            int contextId,
            BasicAuthorizationDetectionMethod basicAuthorizationDetectionMethod)
        {
            // ARRANGE
            var json = JObject.FromObject(basicAuthorizationDetectionMethod);

            json.Add("methodType", "basic");
            httpClientMock.SetupApiCall(sut, CallType.View, "getAuthorizationDetectionMethod",
                                        new Parameters
            {
                { "contextId", contextId }
            })
            .Returns(json.ToString())
            .Verifiable();

            // ACT
            var result = sut.GetAuthorizationDetectionMethod(contextId);

            // ASSERT
            result.ShouldBeEquivalentTo(basicAuthorizationDetectionMethod);
            httpClientMock.Verify();
        }
Пример #2
0
        public void GetAuthorizationDetectionMethod_UnsupportedMethodType(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] AuthorizationComponent sut,
            int contextId)
        {
            // ARRANGE
            var json = new JObject(
                new JProperty("methodType", "alternative"));

            httpClientMock.SetupApiCall(sut, CallType.View, "getAuthorizationDetectionMethod",
                                        new Parameters
            {
                { "contextId", contextId }
            })
            .Returns(json.ToString())
            .Verifiable();

            // ACT
            Action act = () => sut.GetAuthorizationDetectionMethod(contextId);

            // ASSERT
            act.ShouldThrow <ZapException>().WithMessage(Resources.UnsupportedAuthorizationDetectionMethod);
            httpClientMock.Verify();
        }