Beispiel #1
0
        public async Task Should_be_able_to_create_exchanges_only_policies()
        {
            const string     policyName = "asamplepolicy-exchange-only";
            const HaMode     haMode     = HaMode.All;
            const HaSyncMode haSyncMode = HaSyncMode.Automatic;
            await managementClient.CreatePolicyAsync(new Policy
            {
                Name       = policyName,
                Pattern    = "averyuncommonpattern",
                Vhost      = vhostName,
                ApplyTo    = ApplyMode.Exchanges,
                Definition = new PolicyDefinition
                {
                    HaMode     = haMode,
                    HaSyncMode = haSyncMode
                }
            }).ConfigureAwait(false);

            Assert.Equal(1, (await managementClient.GetPoliciesAsync().ConfigureAwait(false)).Count(
                             p => p.Name == policyName &&
                             p.Vhost == vhostName &&
                             p.ApplyTo == ApplyMode.Exchanges &&
                             p.Definition.HaMode == haMode &&
                             p.Definition.HaSyncMode == haSyncMode));
        }
Beispiel #2
0
        public async Task Should_be_able_to_create_all_the_defitions_in_a_policy()
        {
            const string     policyName           = "a-sample-all-definitions-in-a-policy";
            const int        priority             = 999;
            const HaMode     haMode               = HaMode.All;
            const HaSyncMode haSyncMode           = HaSyncMode.Automatic;
            const string     alternateExchange    = "a-sample-alternate-exchange";
            const string     deadLetterExchange   = "a-sample-dead-letter-exchange";
            const string     deadLetterRoutingKey = "a-sample-dead-letter-exchange-key";
            const uint       messageTtl           = 5000;
            const uint       expires              = 10000;
            const uint       maxLength            = 500;
            await managementClient.CreatePolicyAsync(new Policy
            {
                Name       = policyName,
                Pattern    = "averyuncommonpattern",
                Vhost      = vhostName,
                Definition = new PolicyDefinition
                {
                    HaMode               = haMode,
                    HaSyncMode           = haSyncMode,
                    AlternateExchange    = alternateExchange,
                    DeadLetterExchange   = deadLetterExchange,
                    DeadLetterRoutingKey = deadLetterRoutingKey,
                    MessageTtl           = messageTtl,
                    Expires              = expires,
                    MaxLength            = maxLength
                },
                Priority = priority
            }).ConfigureAwait(false);

            Assert.Equal(1, (await managementClient.GetPoliciesAsync().ConfigureAwait(false)).Count(
                             p => p.Name == policyName &&
                             p.Vhost == vhostName &&
                             p.Priority == priority &&
                             p.Definition.HaMode == haMode &&
                             p.Definition.HaSyncMode == haSyncMode &&
                             p.Definition.AlternateExchange == alternateExchange &&
                             p.Definition.DeadLetterExchange == deadLetterExchange &&
                             p.Definition.DeadLetterRoutingKey == deadLetterRoutingKey &&
                             p.Definition.MessageTtl == messageTtl &&
                             p.Definition.Expires == expires &&
                             p.Definition.MaxLength == maxLength));
        }