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();
        }
        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);
        }
        public async Task<AlertPolicy> Create(AlertPolicyDefniition definition, CancellationToken cancellationToken = new CancellationToken())
        {
            var requestUri = await GetUri(cancellationToken);

            return await _httpClient.PostAsync<AlertPolicy>(requestUri, definition, cancellationToken);
        }
 public void Setup()
 {
     _policyDefinition = null;
     _policyResult = null;
     _policyCollectionResult = null;
 }
        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;
        }
        private void When_I_Create_A_New_Policy()
        {
            _policyDefinition = BuildPolicyDefinition();

            _policyResult = ServiceFactory.CreateAlertPolicyService().Create(_policyDefinition, CancellationToken.None).Result;
        }