Ejemplo n.º 1
0
        public void TestBuildWithChildren()
        {
            BuildRequestData          data   = new BuildRequestData("TestFile", new Dictionary <string, string>(), "TestToolsVersion", new string[0], null);
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, data, "2.0");

            _cache.AddConfiguration(config);

            // Configure the builder to spawn build requests
            MockRequestBuilder builder = (MockRequestBuilder)_host.GetComponent(BuildComponentType.RequestBuilder);

            builder.NewRequests.Add(new FullyQualifiedBuildRequest[1] {
                new FullyQualifiedBuildRequest(config, new string[1] {
                    "requiredTarget1"
                }, true)
            });

            // Create the initial build request
            string[] targets = new string[3] {
                "target1", "target2", "target3"
            };
            BuildRequest request = CreateNewBuildRequest(1, targets);

            // Kick it off
            VerifyEngineStatus(BuildRequestEngineStatus.Uninitialized);
            _engine.InitializeForBuild(new NodeLoggingContext(_host.LoggingService, 0, false));
            _engine.SubmitBuildRequest(request);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Active);

            // Wait for the new requests to be spawned by the builder
            WaitForEvent(_newRequestEvent, "NewRequestEvent");
            Assert.Equal(1, _newRequest_Request.BuildRequests[0].ConfigurationId);
            Assert.Single(_newRequest_Request.BuildRequests[0].Targets);
            Assert.Equal("requiredTarget1", _newRequest_Request.BuildRequests[0].Targets[0]);

            // Wait for a moment, because the build request engine thread may not have gotten around
            // to going to the waiting state.
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Waiting);

            // Report a result to satisfy the build request
            BuildResult result = new BuildResult(_newRequest_Request.BuildRequests[0]);

            result.AddResultsForTarget("requiredTarget1", BuildResultUtilities.GetEmptySucceedingTargetResult());
            _engine.UnblockBuildRequest(new BuildRequestUnblocker(result));

            // Continue the request.
            _engine.UnblockBuildRequest(new BuildRequestUnblocker(request.GlobalRequestId));

            // Wait for the original request to complete
            WaitForEvent(_requestCompleteEvent, "RequestComplete");
            Assert.Equal(request, _requestComplete_Request);
            Assert.Equal(BuildResultCode.Success, _requestComplete_Result.OverallResult);

            VerifyEngineStatus(BuildRequestEngineStatus.Idle);
        }
        public void MockRequest_AfterBuild_WithoutRouting()
        {
            //Assign
            const string expectedValue        = "_controller_method_41";
            const string url                  = "http://example.com/controller/method/41";
            var          appEnvironmentConfig = GetEnvironmentConfig(MockFilesFormats.Json, new List <string> {
                nameof(MockRequestBuilderTests)
            }, nameof(MockRequest_AfterBuild_WithRouting));

            Routes.AddRoute("{controller}/method/{id}");
            const bool isRequestRouted = false;

            //Act
            var message            = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
            var mockrequestBuilder = new MockRequestBuilder(appEnvironmentConfig);
            var mockRequest        = mockrequestBuilder.MockRequest(message, isRequestRouted);

            //Assert
            Assert.AreEqual(expectedValue, mockRequest.FileName);
        }
Ejemplo n.º 3
0
        public void TestBuildWithNewConfiguration()
        {
            BuildRequestData          data   = new BuildRequestData(Path.GetFullPath("TestFile"), new Dictionary <string, string>(), "TestToolsVersion", new string[0], null);
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, data, "2.0");

            _cache.AddConfiguration(config);

            // Configure the builder to spawn build requests
            MockRequestBuilder        builder          = (MockRequestBuilder)_host.GetComponent(BuildComponentType.RequestBuilder);
            BuildRequestData          data2            = new BuildRequestData(Path.GetFullPath("OtherFile"), new Dictionary <string, string>(), "TestToolsVersion", new string[0], null);
            BuildRequestConfiguration unresolvedConfig = new BuildRequestConfiguration(data2, "2.0");

            builder.NewRequests.Add(new FullyQualifiedBuildRequest[1] {
                new FullyQualifiedBuildRequest(unresolvedConfig, new string[1] {
                    "requiredTarget1"
                }, true)
            });

            // Create the initial build request
            string[] targets = new string[3] {
                "target1", "target2", "target3"
            };
            BuildRequest request = CreateNewBuildRequest(1, targets);

            // Kick it off
            VerifyEngineStatus(BuildRequestEngineStatus.Uninitialized);
            _engine.InitializeForBuild(new NodeLoggingContext(_host.LoggingService, 0, false));
            _engine.SubmitBuildRequest(request);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Active);

            // Wait for the request to generate the child request with the unresolved configuration
            WaitForEvent(_newConfigurationEvent, "NewConfigurationEvent");
            Assert.Equal(Path.GetFullPath("OtherFile"), _newConfiguration_Config.ProjectFullPath);
            Assert.Equal("TestToolsVersion", _newConfiguration_Config.ToolsVersion);
            Assert.True(_newConfiguration_Config.WasGeneratedByNode);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Waiting);

            // Resolve the configuration
            BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(_newConfiguration_Config.ConfigurationId, 2, 0);

            _engine.ReportConfigurationResponse(response);

            // Now wait for the actual requests to be issued.
            WaitForEvent(_newRequestEvent, "NewRequestEvent");
            Assert.Equal(2, _newRequest_Request.BuildRequests[0].ConfigurationId);
            Assert.Equal(2, _newRequest_Request.BuildRequests[0].ConfigurationId);
            Assert.Single(_newRequest_Request.BuildRequests[0].Targets);
            Assert.Equal("requiredTarget1", _newRequest_Request.BuildRequests[0].Targets[0]);

            // Report a result to satisfy the build request
            BuildResult result = new BuildResult(_newRequest_Request.BuildRequests[0]);

            result.AddResultsForTarget("requiredTarget1", BuildResultUtilities.GetEmptySucceedingTargetResult());
            _engine.UnblockBuildRequest(new BuildRequestUnblocker(result));

            // Continue the request
            _engine.UnblockBuildRequest(new BuildRequestUnblocker(request.GlobalRequestId));

            // Wait for the original request to complete
            WaitForEvent(_requestCompleteEvent, "RequestComplete");
            Assert.Equal(request, _requestComplete_Request);
            Assert.Equal(BuildResultCode.Success, _requestComplete_Result.OverallResult);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Idle);
        }
 internal RemoteHostHttpHandler(
     MockRequestBuilder mockRequestBuilder)
     : base(mockRequestBuilder)
 {
 }
Ejemplo n.º 5
0
 internal MockHttpHandler(MockRequestBuilder mockRequestBuilder)
 {
     MockRequestBuilder = mockRequestBuilder;
 }
Ejemplo n.º 6
0
 internal EmbeddedResourceHttpHandler(
     MockRequestBuilder mockRequestBuilder, Assembly resourceAssembly)
     : base(mockRequestBuilder)
 {
     _resourceAssembly = resourceAssembly;
 }