public async Task ResumeTimerCall() { var http = new HttpClient(new ActionHandler(req => { Assert.Equal("Bearer", req.Headers.Authorization.Scheme); Assert.Equal("ABC123", req.Headers.Authorization.Parameter); Assert.Equal(HttpMethod.Post, req.Method); Assert.Equal($"{TimersClient.EuropeEndpoint}/v1/alerts/timers/ABC123/resume", req.RequestUri.ToString()); }, HttpStatusCode.NoContent)); var client = new TimersClient(TimersClient.EuropeEndpoint, "ABC123", http); await client.Resume("ABC123"); }
public async Task GetCall() { var http = new HttpClient(new ActionHandler(req => { Assert.Equal("Bearer", req.Headers.Authorization.Scheme); Assert.Equal("ABC123", req.Headers.Authorization.Parameter); Assert.Equal(HttpMethod.Get, req.Method); Assert.Equal($"{TimersClient.EuropeEndpoint}/v1/alerts/timers/ABC123", req.RequestUri.ToString()); }, new TimerResponse { Id = "ABC123", })); var client = new TimersClient(TimersClient.EuropeEndpoint, "ABC123", http); var response = await client.Get("ABC123"); Assert.Equal("ABC123", response.Id); }
public async Task ListCall() { var http = new HttpClient(new ActionHandler(req => { Assert.Equal("Bearer", req.Headers.Authorization.Scheme); Assert.Equal("ABC123", req.Headers.Authorization.Parameter); Assert.Equal(HttpMethod.Get, req.Method); Assert.Equal($"{TimersClient.EuropeEndpoint}/v1/alerts/timers/", req.RequestUri.ToString()); }, Utility.ExampleFileContent <ListTimerResponse>("ListTimer.json"))); var client = new TimersClient(TimersClient.EuropeEndpoint, "ABC123", http); var response = await client.List(); Assert.Equal(TimeSpan.FromMinutes(10), response.Timers.First().Duration); Assert.Equal(TimeSpan.FromMinutes(5), response.Timers.Skip(1).First().Duration); Assert.Equal(TimeSpan.FromMinutes(3).Add(TimeSpan.FromSeconds(3)), response.Timers.Skip(1).First().RemainingTimeWhenPaused); Assert.Equal(2, response.Timers.Length); Assert.Equal(2, response.TotalCount); Assert.Null(response.NextToken); }
public async Task CreateCall() { var http = new HttpClient(new ActionHandler(async req => { Assert.Equal("Bearer", req.Headers.Authorization.Scheme); Assert.Equal("ABC123", req.Headers.Authorization.Parameter); Assert.Equal(HttpMethod.Post, req.Method); Assert.Equal($"{TimersClient.EuropeEndpoint}/v1/alerts/timers/", req.RequestUri.ToString()); var rawBody = await req.Content.ReadAsStringAsync(); var bodyObject = JsonConvert.DeserializeObject <CreateTimerRequest>(rawBody); Assert.Equal(TimeSpan.FromHours(1), bodyObject.Duration); Assert.Equal(DisplayVisibility.Visible, bodyObject.CreationBehavior.DisplayExperience.Visibility); Assert.True(bodyObject.TriggeringBehavior.NotificationConfig.PlayAudible); Assert.IsType <NotifyOnlyOperation>(bodyObject.TriggeringBehavior.Operation); }, new TimerResponse { Id = "ABC123", })); var notifyOnly = new CreateTimerRequest(TimeSpan.FromHours(1), new NotifyOnlyOperation(), DisplayVisibility.Visible, true); var client = new TimersClient(TimersClient.EuropeEndpoint, "ABC123", http); await client.Create(notifyOnly); }