예제 #1
0
        public void Should_be_able_to_create_policies()
        {
            var policyName = "asamplepolicy";

            managementClient.CreatePolicy(new Policy
            {
                Name       = policyName,
                Pattern    = "averyuncommonpattern",
                Vhost      = "/",
                Definition = new PolicyDefinition
                {
                    HaMode     = HaMode.All,
                    HaSyncMode = HaSyncMode.Automatic
                }
            });
            Assert.AreEqual(1, managementClient.GetPolicies().Count(p => p.Name == policyName && p.Vhost == "/"));
        }
        public void Should_be_able_to_create_policies()
        {
            var policyName = "asamplepolicy";
            var haMode     = HaMode.All;
            var haSyncMode = HaSyncMode.Automatic;

            managementClient.CreatePolicy(new Policy
            {
                Name       = policyName,
                Pattern    = "averyuncommonpattern",
                Vhost      = vhostName,
                Definition = new PolicyDefinition
                {
                    HaMode     = haMode,
                    HaSyncMode = haSyncMode
                }
            });
            Assert.AreEqual(1, managementClient.GetPolicies().Count(
                                p => p.Name == policyName &&
                                p.Vhost == vhostName &&
                                p.ApplyTo == ApplyMode.All &&
                                p.Definition.HaMode == haMode &&
                                p.Definition.HaSyncMode == haSyncMode));
        }
        public async Task Should_be_able_to_create_policies()
        {
            const string     policyName = "asamplepolicy";
            const HaMode     haMode     = HaMode.All;
            const HaSyncMode haSyncMode = HaSyncMode.Automatic;
            await managementClient.CreatePolicy(new Policy
            {
                Name       = policyName,
                Pattern    = "averyuncommonpattern",
                Vhost      = vhostName,
                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.All &&
                             p.Definition.HaMode == haMode &&
                             p.Definition.HaSyncMode == haSyncMode));
        }