public async Task WhenCreatingActivityLogClientThenItIsCreatedSuccessfully()
        {
            IAnalysisServicesFactory factory = new AnalysisServicesFactory(this.tracerMock.Object, this.httpClientWrapperMock.Object, this.credentialsFactoryMock.Object, this.azureResourceManagerClientMock.Object);
            IActivityLogClient       client  = await factory.CreateActivityLogClientAsync(default(CancellationToken));

            Assert.IsNotNull(client);
            Assert.IsTrue(client is ActivityLogClient);
        }
        public async Task WhenCallingActivityLogClientWithMultiplePagesThenTheCorrectResponseIsReturned()
        {
            IAnalysisServicesFactory factory = new AnalysisServicesFactory(this.tracerMock.Object, this.httpClientWrapperMock.Object, this.credentialsFactoryMock.Object, this.azureResourceManagerClient, this.queryRunInfoProviderMock.Object);
            var resource = new ResourceIdentifier(ResourceType.Subscription, "subscriptionId", string.Empty, string.Empty);
            IActivityLogClient client = await factory.CreateActivityLogClientAsync(default(CancellationToken));

            string nextLink    = "https://management.azure.com/";
            Uri    nextLinkUri = new Uri(nextLink);

            JObject returnValue = new JObject
            {
                ["value"] = new JArray
                {
                    new JObject
                    {
                        ["subscriptionId"] = "subId"
                    }
                },
                ["nextLink"] = nextLink
            };

            JObject nextLinkReturnValue = new JObject
            {
                ["value"] = new JArray
                {
                    new JObject
                    {
                        ["subscriptionId"] = "subId2"
                    }
                }
            };

            Uri requestUri = new Uri("https://management.azure.com/subscriptions/subscriptionId/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2018-04-30 17:00:00Z' and eventTimestamp le '2018-04-30 23:00:00Z'");
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StringContent(returnValue.ToString())
            };

            HttpResponseMessage nextLinkResponse = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StringContent(nextLinkReturnValue.ToString())
            };

            this.httpClientWrapperMock.Setup(m => m.SendAsync(It.Is <HttpRequestMessage>(r => r.RequestUri == requestUri), It.IsAny <TimeSpan?>(), It.IsAny <CancellationToken>())).ReturnsAsync(response);
            this.httpClientWrapperMock.Setup(m => m.SendAsync(It.Is <HttpRequestMessage>(r => r.RequestUri == nextLinkUri), It.IsAny <TimeSpan?>(), It.IsAny <CancellationToken>())).ReturnsAsync(nextLinkResponse);
            await client.GetActivityLogAsync(resource, new DateTime(2018, 04, 30, 17, 0, 0, DateTimeKind.Utc), new DateTime(2018, 04, 30, 23, 0, 0), CancellationToken.None);

            this.httpClientWrapperMock.Verify(x => x.SendAsync(It.Is <HttpRequestMessage>(r => r.RequestUri == requestUri), It.IsAny <TimeSpan?>(), It.IsAny <CancellationToken>()), Times.Once);
            this.httpClientWrapperMock.Verify(x => x.SendAsync(It.Is <HttpRequestMessage>(r => r.RequestUri == nextLinkUri), It.IsAny <TimeSpan?>(), It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task WhenCallingActivityLogClientWithVmResourceTypeThenTheCorrectUriIsCreated()
        {
            IAnalysisServicesFactory factory = new AnalysisServicesFactory(this.tracerMock.Object, this.httpClientWrapperMock.Object, this.credentialsFactoryMock.Object, this.azureResourceManagerClient, this.queryRunInfoProviderMock.Object);
            var resource = new ResourceIdentifier(ResourceType.VirtualMachine, "subscriptionId", "resourceGroupName", "resourceName");
            IActivityLogClient client = await factory.CreateActivityLogClientAsync(default(CancellationToken));

            JObject returnValue = new JObject()
            {
                ["value"] = new JArray()
            };

            Uri requestUri = new Uri("https://management.azure.com/subscriptions/subscriptionId/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2018-04-30 17:00:00Z' and eventTimestamp le '2018-04-30 23:00:00Z' and resourceUri eq '/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/resourceName");
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StringContent(returnValue.ToString())
            };

            this.httpClientWrapperMock.Setup(m => m.SendAsync(It.Is <HttpRequestMessage>(r => r.RequestUri == requestUri), It.IsAny <TimeSpan?>(), It.IsAny <CancellationToken>())).ReturnsAsync(response);
            await client.GetActivityLogAsync(resource, new DateTime(2018, 04, 30, 17, 0, 0, DateTimeKind.Utc), new DateTime(2018, 04, 30, 23, 0, 0), CancellationToken.None);

            this.httpClientWrapperMock.Verify(x => x.SendAsync(It.Is <HttpRequestMessage>(r => r.RequestUri == requestUri), It.IsAny <TimeSpan?>(), It.IsAny <CancellationToken>()), Times.Once);
        }