예제 #1
0
        /// <summary>
        /// Explore a test assembly.
        /// </summary>
        private void Explore(ExploreRequest request, Response response)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (response == null)
            {
                throw new ArgumentNullException(nameof(response));
            }

            NUnitRunner runner  = new NUnitRunner(request.AssemblyPath, response.Directory);
            string      message = runner.ExploreAssembly();

            runner.Dispose();

            ExploreResponse exploreResponse = new ExploreResponse {
                Timestamp    = DateTime.Now,
                Id           = request.Id,
                AssemblyPath = request.AssemblyPath,
                ExploreFile  = runner.ExploreResultFile,
                Message      = message
            };

            JsonHelper.ToFile(Path.Combine(response.Directory, FileNames.ExploreResponseFileName), exploreResponse);
        }
예제 #2
0
        /// <summary>
        /// Start a expolre request.
        /// </summary>
        public async Task <ExploreResponse> ExploreAssemblyAsync(string aAssemblyPath, string aRevitVersion, CancellationToken aCancellationToken)
        {
            ExploreResponse response = null;
            ExploreRequest  request  = new ExploreRequest {
                Timestamp     = DateTime.Now,
                Id            = GenerateId(),
                ClientName    = mClientName,
                ClientVersion = mClientVersion,
                AssemblyPath  = aAssemblyPath
            };

            RevitHelper.StartRevit(aRevitVersion);
            bool isRunnerAvailable = await IsRunnerAvailable(aCancellationToken);

            if (isRunnerAvailable)
            {
                string requestFilePath = FileNames.ExploreRequestFilePath(request.Id);
                JsonHelper.ToFile(requestFilePath, request);

                var responseDirectoryPath = await GetResponseDirectory(request.Id);

                if (Directory.Exists(responseDirectoryPath))
                {
                    while (response == null && !aCancellationToken.IsCancellationRequested)
                    {
                        string responseFile = Path.Combine(responseDirectoryPath, FileNames.ExploreResponseFileName);
                        response = JsonHelper.FromFile <ExploreResponse>(responseFile);

                        if (response == null)
                        {
                            await Task.Delay(500, aCancellationToken);
                        }
                    }
                }
                else
                {
                    FileHelper.DeleteWithLock(requestFilePath);
                }
            }

            return(response);
        }