示例#1
0
        public void BuildAuthString()
        {
            // ARRANGE
            string expected          = "Bearer " + FactoryUser.ApiOAuthToken.AccessToken;
            IInternalDracoonClient c = FactoryClients.InternalDracoonClientMock();
            IOAuth oa = new OAuthClient(c, new DracoonAuth("id1", "secret1", "code1"));

            Mock.Arrange(() => c.Builder.PostOAuthToken(Arg.AnyString, Arg.AnyString, Arg.AnyString, Arg.AnyString)).Returns(FactoryRestSharp.PostOAuthTokenMock("id1", "secret1", "grant", "code1")).Occurs(1);
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiOAuthToken>(Arg.IsAny <IRestRequest>(), RequestType.PostOAuthToken, 0)).Returns(FactoryUser.ApiOAuthToken).Occurs(1);

            // ACT
            string actual = oa.BuildAuthString();

            // ASSERT
            Assert.Equal(expected, actual);
            Assert.Equal(DracoonAuth.Mode.ACCESS_REFRESH_TOKEN, oa.Auth.UsedMode);
            Mock.Assert(c.Builder);
            Mock.Assert(c.Executor);
        }