public void CanConvert()
        {
            // Arrange
            const GmailScopes scopes        = GmailScopes.Readonly;
            string            readOnlyScope = GmailHelper.GetGmailScopesField("ReadOnlyScope");

            // Act
            string scopeString = scopes.ToScopeString();

            // Assert
            scopeString.ShouldBeEquivalentTo(readOnlyScope);
        }
Пример #2
0
        public static GmailProxy GetGmailProxy()
        {
            string privateKey   = GetPrivateKey();
            string tokenUri     = GetTokenUri();
            string clientEmail  = GetClientEmail();
            string emailAddress = GetEmailAddress();
            ServiceAccountCredential accountCredential = new ServiceAccountCredential
            {
                PrivateKey  = privateKey,
                TokenUri    = tokenUri,
                ClientEmail = clientEmail
            };

            //TODO: get GmailClient.ConvertToScopes using reflection in ReflectionHelper
            string scope = GmailHelper.GetGmailScopesField("ModifyScope");

            return(new GmailProxy(new AuthorizationDelegatingHandler(accountCredential, emailAddress, scope)));
        }
        public void WithMultipleScopes_ReturnsSpaceSeparatedString()
        {
            // Arrange
            const GmailScopes scopes = GmailScopes.Readonly | GmailScopes.Modify | GmailScopes.Labels | GmailScopes.Insert | GmailScopes.Send;
            // order shouldn't matter
            var scopeList = new List <string>
            {
                GmailHelper.GetGmailScopesField("LabelsScope"),
                GmailHelper.GetGmailScopesField("ReadOnlyScope"),
                GmailHelper.GetGmailScopesField("ModifyScope"),
                GmailHelper.GetGmailScopesField("SendScope"),
                GmailHelper.GetGmailScopesField("InsertScope"),
            };

            // Act
            string scopeString = scopes.ToScopeString();

            // Assert
            var parsedScopeList = scopeString.Split(' ').ToList();

            parsedScopeList.ShouldAllBeEquivalentTo(scopeList);
        }