public void GetControlDefinition_CreateGetRequest_IsCalled_On_RequestFactory()
        {
            // Arrange
            var machineNameProvider = new Mock<IMachineNameProvider>();

            var serviceConfiguration = new AgentControlDefinitionServiceConfiguration { Hostaddress = "127.0.0.0:8181", Hostname = "localhost", ResourcePath = "/api/AgentControlDefinition" };
            var response = new Mock<IRestResponse<AgentControlDefinition>>();
            var restClient = new Mock<IRestClient>();
            restClient.Setup(c => c.Execute<AgentControlDefinition>(It.IsAny<IRestRequest>())).Returns(response.Object);
            var request = new Mock<IRestRequest>();

            var configurationServiceUrlProvider = new Mock<IAgentControlDefinitionServiceUrlProvider>();
            configurationServiceUrlProvider.Setup(c => c.GetServiceConfiguration()).Returns(serviceConfiguration);

            var restClientFactory = new Mock<IRESTClientFactory>();
            restClientFactory.Setup(r => r.GetRESTClient(It.IsAny<string>())).Returns(restClient.Object);

            var requestFactory = new Mock<IRESTRequestFactory>();
            requestFactory.Setup(f => f.CreateGetRequest(It.IsAny<string>(), It.IsAny<string>())).Returns(request.Object);

            var agentControlDefinitionAccessor = new AgentControlDefinitionAccessor(
                configurationServiceUrlProvider.Object, machineNameProvider.Object, restClientFactory.Object, requestFactory.Object);

            // Act
            agentControlDefinitionAccessor.GetControlDefinition();

            // Assert
            requestFactory.Verify(c => c.CreateGetRequest(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
        }
        public void GetControlDefinition_ResponseData_IsReturned()
        {
            // Arrange
            var serviceConfiguration = new AgentControlDefinitionServiceConfiguration { Hostaddress = "127.0.0.0:8181", Hostname = "localhost", ResourcePath = "/api/AgentControlDefinition" };

            var machineNameProvider = new Mock<IMachineNameProvider>();

            var responseData = new AgentControlDefinition
                {
                    AgentIsEnabled = true,
                    Hostaddress = "127.0.0.1",
                    Hostname = "www.example.com",
                    CheckIntervalInSeconds = 1,
                    SystemInformationSenderPath = Guid.NewGuid().ToString()
                };

            var response = new Mock<IRestResponse<AgentControlDefinition>>();
            response.Setup(r => r.Data).Returns(responseData);

            var restClient = new Mock<IRestClient>();
            restClient.Setup(c => c.Execute<AgentControlDefinition>(It.IsAny<IRestRequest>())).Returns(response.Object);
            var request = new Mock<IRestRequest>();

            var configurationServiceUrlProvider = new Mock<IAgentControlDefinitionServiceUrlProvider>();
            configurationServiceUrlProvider.Setup(c => c.GetServiceConfiguration()).Returns(serviceConfiguration);

            var restClientFactory = new Mock<IRESTClientFactory>();
            restClientFactory.Setup(r => r.GetRESTClient(It.IsAny<string>())).Returns(restClient.Object);

            var requestFactory = new Mock<IRESTRequestFactory>();
            requestFactory.Setup(f => f.CreateGetRequest(It.IsAny<string>(), It.IsAny<string>())).Returns(request.Object);

            var agentControlDefinitionAccessor = new AgentControlDefinitionAccessor(
                configurationServiceUrlProvider.Object, machineNameProvider.Object, restClientFactory.Object, requestFactory.Object);

            // Act
            var result = agentControlDefinitionAccessor.GetControlDefinition();

            // Assert
            Assert.AreEqual(responseData, result);
        }