public async void WorkerClient_Builds_On_Request() { //arrange BuildResultDto actualResult = null; //hold actual result var buildRequest = new BuildRequestDto { SessionId = arrangement.SessionId, RunOnSuccess = false, SourceCode = MockSourceCodeRepository.Get_Working_SimpleOutput_Code() }; //act arrangement.WorkerService.StartListening(); arrangement.WorkerService.WorkerConnected += (TcpClient workerClient, string sessionId) => { arrangement.WorkerService.SendWorkerMessage(workerClient, MessageType.ServerBuildRequest, buildRequest); }; arrangement.WorkerService.WorkerCompletedBuild += delegate(TcpClient workerClient, BuildResultDto message) { arrangement.Worker?.Stop(); arrangement.WorkerService?.StopListening(); actualResult = message; }; await arrangement.Worker.Start(arrangement.ServiceHostName, arrangement.ServicePort, arrangement.SessionId); //assert Assert.True(actualResult.IsSuccess); }
public async void WorkerClient_Build_Fails_When_Ambiguous_EntryPoint() { //arrange BuildResultDto actualResult = null; //hold actual result var buildRequest = new BuildRequestDto { SessionId = arrangement.SessionId, RunOnSuccess = true, SourceCode = MockSourceCodeRepository.Get_AmbiguousMain_Code() }; //act arrangement.WorkerService.StartListening(); arrangement.WorkerService.WorkerConnected += (TcpClient workerClient, string sessionId) => { arrangement.WorkerService.SendWorkerMessage(workerClient, MessageType.ServerBuildRequest, buildRequest); }; arrangement.WorkerService.WorkerCompletedBuild += delegate(TcpClient workerClient, BuildResultDto message) { arrangement.Worker?.Stop(); arrangement.WorkerService?.StopListening(); actualResult = message; }; await arrangement.Worker.Start(arrangement.ServiceHostName, arrangement.ServicePort, arrangement.SessionId); //assert Assert.False(actualResult.IsSuccess); //CS0017 = Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. Assert.Equal("CS0017", actualResult.BuildErrors.First().Id); }
public async void WorkerClient_Reports_ExecutionState() { //arrange Queue <ExecutionStateDto> actualStates = new Queue <ExecutionStateDto>(); //hold actual result var buildRequest = new BuildRequestDto { SessionId = arrangement.SessionId, RunOnSuccess = true, SourceCode = MockSourceCodeRepository.Get_Working_SimpleOutput_Code() }; //act arrangement.WorkerService.StartListening(); arrangement.WorkerService.WorkerConnected += (TcpClient workerClient, string sessionId) => { arrangement.WorkerService.SendWorkerMessage(workerClient, MessageType.ServerBuildRequest, buildRequest); }; arrangement.WorkerService.WorkerExecutionStateChanged += delegate(TcpClient workerClient, ExecutionStateDto message) { var outputtest = message.Output?.Replace("\r", "[CR]")?.Replace("\n", "LF"); actualStates.Enqueue(message); if (actualStates.Count >= 4) { arrangement.Worker?.Stop(); arrangement.WorkerService?.StopListening(); } }; await arrangement.Worker.Start(arrangement.ServiceHostName, arrangement.ServicePort, arrangement.SessionId); //assert ExecutionStateDto nextState; nextState = actualStates.Dequeue(); Assert.Equal(RemoteAppState.Running, nextState.State); nextState = actualStates.Dequeue(); Assert.Equal(RemoteAppState.WriteOutput, nextState.State); Assert.Equal("All your base are belong to us.", nextState.Output); nextState = actualStates.Dequeue(); Assert.Equal(RemoteAppState.WriteOutput, nextState.State); Assert.Contains("\n", nextState.Output); nextState = actualStates.Dequeue(); Assert.Equal(RemoteAppState.Ended, nextState.State); }