public void Create_ReturnsExpectedResult()
        {
            var expectedResult = new AlertPolicy();

            _client.Setup(x => x.PostAsync<AlertPolicy>(It.IsAny<string>(), It.IsAny<object>(), It.IsAny<CancellationToken>()))
                   .Returns(Task.FromResult(expectedResult));

            var actualResult = _testObject.Create(new AlertPolicyDefniition(), CancellationToken.None).Result;

            Assert.AreSame(expectedResult, actualResult);
        }
 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_Get_My_Policy()
 {
     _policyResult = ServiceFactory.CreateAlertPolicyService().Get(CurrentUser.AlertPolicies.First().Key, CancellationToken.None).Result;
 }
        private void When_I_Create_A_New_Policy()
        {
            _policyDefinition = BuildPolicyDefinition();

            _policyResult = ServiceFactory.CreateAlertPolicyService().Create(_policyDefinition, CancellationToken.None).Result;
        }
 private static void AssertPoliciesEqual(AlertPolicy policy, MockAlertPolicy mock)
 {
     Assert.AreEqual(policy.Id, mock.id);
     Assert.AreEqual(policy.Name, mock.name);
     AssertMockActionsEqual(policy.Actions, mock.actions);
     AssertMockTriggersEqual(policy.Triggers, mock.triggers);
 }
        public void GetById_ReturnsExpectedResult()
        {
            var expectedResult = new AlertPolicy();

            _client.Setup(x => x.GetAsync<AlertPolicy>(It.IsAny<string>(), It.IsAny<CancellationToken>()))
                   .Returns(Task.FromResult(expectedResult));

            var actualResult = _testObject.Get(PolicyId, CancellationToken.None).Result;

            Assert.AreSame(expectedResult, actualResult);
        }