public async Task PingBackAsync(PingBackRequest request)
        {
            var queryString = new Dictionary <string, string>
            {
                { "item_id", request.ItemId.ToString() },
                { "location_id", request.LocationId },
                { "play_datetime", request.PlayDateTime.ToString("O") },
                { "duration", request.Duration.TotalSeconds.ToString("F") },
            };

            var uriBuilder = new UriBuilder
            {
                Path  = Routes.PingBack,
                Query = queryString.Serialize()
            };


            var response = await HttpClient.GetAsync <JToken>(uriBuilder.Uri.PathAndQuery)
                           .ConfigureAwait(false);

            if (response.IsSuccess)
            {
                return;
            }

            throw response.Exception;
        }
        public async Task ShouldPostPingBack()
        {
            //Arrange
            var pingBackRequest = new PingBackRequest
            {
                PlayDateTime = DateTime.UtcNow,
                Duration     = TimeSpan.FromHours(1),
                LocationId   = "SC_MH_1",
                ItemId       = 51798
            };
            var client = BuildClient();

            //Act
            await client.PingBackAsync(pingBackRequest);

            //Assert
            Assert.Pass();
        }
Пример #3
0
        public void ShouldThrowLayoutDriveException()
        {
            //Arrange
            var response = new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content = new StringContent(string.Empty)
            };
            var pingBackRequest = new PingBackRequest
            {
                ItemId       = 1523,
                LocationId   = "2",
                PlayDateTime = DateTime.UtcNow,
                Duration     = TimeSpan.FromHours(1)
            };
            var client = BuildClient(response);

            //Act
            //Assert
            Assert.CatchAsync <LayoutDriveException>(() => client.PingBackAsync(pingBackRequest));
        }
Пример #4
0
        public async Task ShouldPostPingBack()
        {
            //Arrange
            var response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(string.Empty)
            };
            var pingBackRequest = new PingBackRequest
            {
                ItemId       = 1523,
                LocationId   = "2",
                PlayDateTime = DateTime.UtcNow,
                Duration     = TimeSpan.FromHours(1)
            };
            var client = BuildClient(response);

            //Act
            await client.PingBackAsync(pingBackRequest);

            //Assert
            Assert.Pass();
        }