示例#1
0
        private void When_I_Update_My_Policy()
        {
            _policyDefinition = new AlertPolicyDefniition
            {
                Name    = "updated name",
                Actions = new List <AlertAction>
                {
                    new AlertAction
                    {
                        Action   = AlertActionType.Email,
                        Settings = new AlertActionSettings {
                            Recipients = new List <string> {
                                "*****@*****.**"
                            }
                        }
                    }
                },
                Triggers = new List <AlertTrigger>
                {
                    new AlertTrigger
                    {
                        Duration  = TimeSpan.FromSeconds(30),
                        Metric    = AlertTriggerMetric.Cpu,
                        Threshold = 5
                    }
                }
            };

            var existingId = CurrentUser.AlertPolicies.First().Key;

            _policyResult = ServiceFactory.CreateAlertPolicyService().Update(existingId, _policyDefinition, CancellationToken.None).Result;
        }
        public void Create_PerformsCorrectRequest()
        {
            var expectedUri   = String.Format("alertpolicies/{0}", AccountAlias);
            var expectedBody  = new AlertPolicyDefniition();
            var expectedToken = new CancellationTokenSource().Token;

            _client.Setup(x => x.PostAsync <AlertPolicy>(expectedUri, expectedBody, expectedToken))
            .Returns(Task.FromResult(new AlertPolicy()));

            _testObject.Create(expectedBody, expectedToken).Wait();

            _client.VerifyAll();
        }
示例#3
0
        public async Task <AlertPolicy> Update(string policyId, AlertPolicyDefniition definition, CancellationToken cancellationToken = new CancellationToken())
        {
            var requestUri = await GetUri(policyId, cancellationToken);

            return(await _httpClient.PutAsync <AlertPolicy>(requestUri, definition, cancellationToken));
        }
示例#4
0
        public async Task <AlertPolicy> Create(AlertPolicyDefniition definition, CancellationToken cancellationToken = new CancellationToken())
        {
            var requestUri = await GetUri(cancellationToken);

            return(await _httpClient.PostAsync <AlertPolicy>(requestUri, definition, cancellationToken));
        }
示例#5
0
        private void When_I_Create_A_New_Policy()
        {
            _policyDefinition = BuildPolicyDefinition();

            _policyResult = ServiceFactory.CreateAlertPolicyService().Create(_policyDefinition, CancellationToken.None).Result;
        }
示例#6
0
 public void Setup()
 {
     _policyDefinition       = null;
     _policyResult           = null;
     _policyCollectionResult = null;
 }