public void BillingCanBeAddedToBilling()
        {
            var sb = new SendGridPermissionsBuilder();

            sb.Include("billing.update");
            sb.AddPermissionsFor(SendGridPermission.Billing, ScopeOptions.ReadOnly);
            sb.Include("billing.create");
            var scopes = sb.Build().ToArray();;

            Assert.Equal(3, scopes.Length);
            Assert.Contains("billing.update", scopes);
            Assert.Contains("billing.read", scopes);
            Assert.Contains("billing.create", scopes);
        }
        public void BillingPermissionIsMutuallyExclusiveWhenOtherPermissionsAreIncludeddToBuilderAlreadyContainingBilling()
        {
            var sb = new SendGridPermissionsBuilder();

            sb.AddPermissionsFor(SendGridPermission.Billing);
            Assert.Throws <InvalidOperationException>(() => sb.Include("alerts.read"));
        }
        public void BillingPermissionIsMutuallyExclusiveWhenIncludedAndBuilderAlreadyContainsOtherPermissions()
        {
            var sb = new SendGridPermissionsBuilder();

            sb.AddPermissionsFor(SendGridPermission.Alerts);
            Assert.Throws <InvalidOperationException>(() => sb.Include("billing.create"));
        }
        public void CanIncludeAdditionalScopes()
        {
            var sb = new SendGridPermissionsBuilder();

            sb.Include("mail.send", "mail.batch.create");
            var scopes = sb.Build().ToArray();

            Assert.Contains("mail.send", scopes);
            Assert.Contains("mail.batch.create", scopes);
        }
        public void CanIncludeAdditionalScopesList()
        {
            var sb = new SendGridPermissionsBuilder();

            sb.Include(new[] { "alerts.create", "alerts.delete", "mail.send" });
            var scopes = sb.Build().ToArray();

            Assert.Contains("alerts.create", scopes);
            Assert.Contains("alerts.delete", scopes);
            Assert.Contains("mail.send", scopes);
        }
        public void IncludeThrowsIfAnyScopeIsInvalid()
        {
            var sb = new SendGridPermissionsBuilder();

            Assert.Throws <InvalidOperationException>(() => sb.Include(new [] { "alert.create", "bad.scope" }));
        }