public void WhenStatusCodeIs403_And_ResponseBodyIsEmpty_Returns_NoPermission() {
			var exception = new FullD2LWebExceptionStub( HttpStatusCode.Forbidden, "" );

			var interpretation = m_userContext.InterpretResult( exception );

			Assert.AreEqual( RequestResult.RESULT_NO_PERMISSION, interpretation );
		}
		public void WhenStatusCodeIs403_And_CaseOfInvalidToken_DoesNotAffectResult() {
			var exception = new FullD2LWebExceptionStub( HttpStatusCode.Forbidden, "Invalid Token" );

			var interpretation = m_userContext.InterpretResult( exception );

			Assert.AreEqual( RequestResult.RESULT_INVALID_SIG, interpretation );
		}
		public void WhenStatusCodeIs403_And_ResponseBodyIs_Invalid_token_Returns_InvalidSig() {
			var exception = new FullD2LWebExceptionStub( HttpStatusCode.Forbidden, "Invalid token" );

			var interpretation = m_userContext.InterpretResult( exception );
			
			Assert.AreEqual( RequestResult.RESULT_INVALID_SIG, interpretation );
		}
        public void WhenStatusCodeIs403_And_ResponseBodyIsEmpty_Returns_NoPermission()
        {
            var exception = new FullD2LWebExceptionStub(HttpStatusCode.Forbidden, "");

            var interpretation = m_userContext.InterpretResult(exception);

            Assert.AreEqual(RequestResult.RESULT_NO_PERMISSION, interpretation);
        }
        public void WhenStatusCodeIs403_And_CaseOfInvalidToken_DoesNotAffectResult()
        {
            var exception = new FullD2LWebExceptionStub(HttpStatusCode.Forbidden, "Invalid Token");

            var interpretation = m_userContext.InterpretResult(exception);

            Assert.AreEqual(RequestResult.RESULT_INVALID_SIG, interpretation);
        }
        public void WhenStatusCodeIs403_And_ResponseBodyIs_Invalid_token_Returns_InvalidSig()
        {
            var exception = new FullD2LWebExceptionStub(HttpStatusCode.Forbidden, "Invalid token");

            var interpretation = m_userContext.InterpretResult(exception);

            Assert.AreEqual(RequestResult.RESULT_INVALID_SIG, interpretation);
        }
        public void UserContext_InterpretResult_Upon403_AndResponseTimestampIsInvalid_ServerSkewPropertyDoesNotChange()
        {
            var userContext = TestUtils.CreateTestUserContext();
            const long expectedSkew = 874000L;
            userContext.ServerSkewMillis = expectedSkew;
            var exception = new FullD2LWebExceptionStub(
                HttpStatusCode.Forbidden, "Timestamp out of range\r\n" );

            userContext.InterpretResult( exception );
            Assert.AreEqual( expectedSkew, userContext.ServerSkewMillis );
        }
        public void UserContext_InterpretResult_Upon403_AndResponseTimestampIsInvalid_ServerSkewPropertyDoesNotChange()
        {
            var        userContext  = TestUtils.CreateTestUserContext();
            const long expectedSkew = 874000L;

            userContext.ServerSkewMillis = expectedSkew;
            var exception = new FullD2LWebExceptionStub(
                HttpStatusCode.Forbidden, "Timestamp out of range\r\n");

            userContext.InterpretResult(exception);
            Assert.AreEqual(expectedSkew, userContext.ServerSkewMillis);
        }
        public void UserContext_InterpretResult_Upon403_ChangesServerSkewProperty_ByTimestampDifference()
        {
            const long clientTimeSeconds = 1319000000L;

            var timestampProvider = TestUtils.CreateTimestampProviderStub( clientTimeSeconds * 1000 );
            var appContext = TestUtils.CreateAppContextUnderTest( timestampProvider );

            var apiHost = TestUtils.CreateTestHost();
            var userContext = appContext.CreateAnonymousUserContext( apiHost );
            const long serverAheadBy = 907L;
            string responseBody = String.Format( "Timestamp out of range\r\n{0}",
                                                 clientTimeSeconds + serverAheadBy );
            var exception = new FullD2LWebExceptionStub( HttpStatusCode.Forbidden, responseBody );

            userContext.InterpretResult( exception );

            Assert.AreEqual( serverAheadBy * 1000, userContext.ServerSkewMillis );
        }
        public void UserContext_InterpretResult_Upon403_ChangesServerSkewProperty_ByTimestampDifference()
        {
            const long clientTimeSeconds = 1319000000L;

            var timestampProvider = TestUtils.CreateTimestampProviderStub(clientTimeSeconds * 1000);
            var appContext        = TestUtils.CreateAppContextUnderTest(timestampProvider);

            var        apiHost       = TestUtils.CreateTestHost();
            var        userContext   = appContext.CreateAnonymousUserContext(apiHost);
            const long serverAheadBy = 907L;
            string     responseBody  = String.Format("Timestamp out of range\r\n{0}",
                                                     clientTimeSeconds + serverAheadBy);
            var exception = new FullD2LWebExceptionStub(HttpStatusCode.Forbidden, responseBody);

            userContext.InterpretResult(exception);

            Assert.AreEqual(serverAheadBy * 1000, userContext.ServerSkewMillis);
        }