private void SaveMaterialContentFromFile(MaterialContent content)
        {
            SourceFileInfo.NullCheck("SourceFileInfo");

            if (CheckSourceFileExists)
            {
                ExceptionHelper.FalseThrow(SourceFileInfo.Exists, string.Format(Resources.FileNotFound, SourceFileInfo.Name));
            }

            if (SourceFileInfo.Exists)
            {
                content.FileSize = SourceFileInfo.Length;

                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    using (FileStream stream = SourceFileInfo.OpenRead())
                    {
                        MaterialContentAdapter.Instance.Update(content, stream);

                        TransactionScopeFactory.AttachCommittedAction(new Action <TransactionEventArgs>(Current_TransactionCompleted), false);
                    }

                    scope.Complete();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// - Gets specific encrypted source file from server.
        /// - Encryption and Decription using AES symetric and commonSecret derived from EC Diffie-Helman key Exchange
        /// - Decrypts source files
        /// - verifies digital signature of source code
        /// </summary>
        /// <param name="sourceFileInfo">the file to get</param>
        /// <returns>verified and decrypted source file or null if operation unsuccessfull</returns>
        private string DecryptSourceFromServer(SourceFileInfo sourceFileInfo)
        {
            byte[] dhClientPublic;
            byte[] dhClientPrivate;
            _keyGen.GenerateKeyPair(out dhClientPrivate, out dhClientPublic);

            string uri = (TroubleShooterClient.SERVICE_PATH + "/source");
            ProtectedSourceRequest request = new ProtectedSourceRequest()
            {
                DhClientPublic = dhClientPublic, FileName = sourceFileInfo.FileName
            };
            HttpResponseMessage response = _client.PostAsJsonAsync(uri, request).GetAwaiter().GetResult();

            if (response.IsSuccessStatusCode)
            {
                ProtectedSource source          = response.Content.ReadAsAsync <ProtectedSource>().GetAwaiter().GetResult();
                byte[]          sharedSecret    = _diffieHelman.SharedSecret(dhClientPrivate, source.DhPublicServer);
                string          decryptedSource = AesHandler.DecryptStringFromBytes_Aes(source.SourceCode, sharedSecret);
                if (_verifier.VerifySignature(decryptedSource, source.Signature, _signatureKey))
                {
                    return(decryptedSource);
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
        private string CreateInfFile(string psFile, string jobFolder, string psFileInJobFolder, string printerName)
        {
            var psFilename = Path.GetFileName(psFile);
            var infFile    = Path.Combine(jobFolder, psFilename + ".inf");

            var jobInfo = new JobInfo();

            var sourceFileInfo = new SourceFileInfo();

            sourceFileInfo.Filename       = psFileInJobFolder;
            sourceFileInfo.Author         = Environment.UserName;
            sourceFileInfo.ClientComputer = Environment.MachineName.Replace("\\", "");
            sourceFileInfo.Copies         = 1;
            sourceFileInfo.DocumentTitle  = psFile;
            sourceFileInfo.JobCounter     = 0;
            sourceFileInfo.JobId          = 0;
            sourceFileInfo.PrinterName    = printerName;
            sourceFileInfo.SessionId      = Process.GetCurrentProcess().SessionId;
            sourceFileInfo.TotalPages     = GetNumberOfPages(psFile);
            sourceFileInfo.Type           = JobType.PsJob;
            sourceFileInfo.WinStation     = Environment.GetEnvironmentVariable("SESSIONNAME");
            jobInfo.SourceFiles.Add(sourceFileInfo);

            _jobInfoManager.SaveToInfFile(jobInfo, infFile);
            Logger.Debug("Created inf-file for ps-file: " + infFile);

            return(infFile);
        }
        private SourceFileInfo BuildSourceFileInfo(JobType type)
        {
            var sfi = new SourceFileInfo();

            sfi.Filename           = "MyFileName";
            sfi.SessionId          = 321;
            sfi.WinStation         = "SomeStation";
            sfi.Author             = "Me";
            sfi.ClientComputer     = "MyComputer";
            sfi.PrinterName        = "SomePrinterName";
            sfi.JobCounter         = 4243;
            sfi.JobId              = 24;
            sfi.DocumentTitle      = "My awesome Document";
            sfi.Type               = type;
            sfi.TotalPages         = 341;
            sfi.Copies             = 3;
            sfi.UserTokenEvaluated = true;

            var userToken = new UserToken();

            userToken.AddKeyValuePair("testkey", "test value");
            sfi.UserToken = userToken;

            return(sfi);
        }
Ejemplo n.º 5
0
        public async Task AddFileToArchiveAsync(SourceFileInfo fileInfo, CancellationToken cancellationToken)
        {
            if (isClosed)
            {
                throw new InvalidOperationException("Archive has been closed");
            }

            var fileName = fileInfo.GetNameWithPath("/");

            var tarHeader = new TarHeader
            {
                Name    = fileName,
                Size    = fileInfo.Length,
                ModTime = fileInfo.LastModified ?? DateTime.UtcNow
            };

            Log.Debug(() => $"Adding {fileName} ({fileInfo.Length} bytes) to archive");

            var tarEntry = new TarEntry(tarHeader);

            this.tarOutputStream.PutNextEntry(tarEntry);

            using (var inputStream = await fileInfo.GetStreamAsync(cancellationToken))
            {
                if (inputStream != null && inputStream.Length > 0)
                {
                    await inputStream.CopyToAsync(tarOutputStream, 81920, cancellationToken);
                }
            }

            this.tarOutputStream.CloseEntry();
        }
                /// <summary>
                /// Parses test unit information from the provided string
                /// </summary>
                /// <param name="value">The string to parse</param>
                /// <returns>Test unit information contained within value</returns>
                /// <exception cref="FormatException"></exception>
                public TestUnitInfo Parse(string value)
                {
                    TestUnitInfo info = new TestUnitInfo(this.id);

                    string[] properties = value.Split('|');

                    if (properties.Length > 0)
                    {
                        info.Name = properties[0];
                    }
                    if (properties.Length > 1)
                    {
                        info.SourceInfo = SourceFileInfo.Parse(properties[1]);
                    }
                    if (properties.Length > 2)
                    {
                        foreach (var attribute in ParseKeyValuePairs(properties.Skip(2)))
                        {
                            ParseNamedAttribute(info, attribute);
                        }
                    }

                    // Replace the contents of 'this' with that of 'info'
                    Set(info);

                    return(this);
                }
Ejemplo n.º 7
0
        public void SetUp()
        {
            _tokenReplacerFactory = Substitute.For <ITokenReplacerFactory>();
            _tokenReplacer        = new TokenReplacer();
            _tokenReplacer.AddStringToken("author", AuthorTokenValue);
            _tokenReplacer.AddStringToken("title", TitleTokenValue);
            _tokenReplacerFactory.BuildTokenReplacerWithoutOutputfiles(Arg.Any <Job>()).Returns(_tokenReplacer);
            _pageNumberCalculator = Substitute.For <IPageNumberCalculator>();
            _userTokenExtractor   = Substitute.For <IUserTokenExtractor>();

            _jobDataUpdater = new JobDataUpdater(_tokenReplacerFactory, _pageNumberCalculator, _userTokenExtractor);

            var jobInfo = new JobInfo();

            jobInfo.Metadata          = new Metadata();
            jobInfo.Metadata.Author   = "<author>";
            jobInfo.Metadata.Title    = "<title>";
            jobInfo.Metadata.Subject  = "Test Subject";
            jobInfo.Metadata.Keywords = "Test Keywords";
            var sfi1 = new SourceFileInfo();

            sfi1.Filename = PSFile1;
            jobInfo.SourceFiles.Add(sfi1);
            var sfi2 = new SourceFileInfo();

            sfi2.Filename = PSFile2;
            jobInfo.SourceFiles.Add(sfi2);

            var profile = new ConversionProfile();

            _job = new Job(jobInfo, profile, new Accounts());

            _userTokenExtractor.ExtractUserTokenFromPsFile(PSFile1, _job.Profile.UserTokens.Seperator).Returns(_userToken1);
            _userTokenExtractor.ExtractUserTokenFromPsFile(PSFile2, _job.Profile.UserTokens.Seperator).Returns(_userToken2);
        }
 private void AddSourceFileTokens(SourceFileInfo sourceFileInfo)
 {
     _tokenReplacer.AddStringToken("ClientComputer", sourceFileInfo.ClientComputer);
     _tokenReplacer.AddNumberToken("Counter", sourceFileInfo.JobCounter);
     _tokenReplacer.AddNumberToken("JobId", sourceFileInfo.JobId);
     _tokenReplacer.AddStringToken("PrinterName", sourceFileInfo.PrinterName);
     _tokenReplacer.AddNumberToken("SessionId", sourceFileInfo.SessionId);
 }
Ejemplo n.º 9
0
        public ResolvedSource ResolveSource(SourceFileInfo sourceFileInfo, ImmutableArray <SourceLink> sourceLinks, Encoding encoding)
        {
            var pdbDocumentPath = sourceFileInfo.SourceFilePath;

            if (sourceFileInfo.EmbeddedText is { } embeddedText)
            {
                return(new ResolvedSource(OnDiskPath: null, embeddedText, sourceFileInfo));
            }
        /// <summary>
        /// Builds a new TestCase.
        /// </summary>
        /// <param name="name">Test Case Name</param>
        /// <param name="id">Test Case Id</param>
        /// <param name="source">Test Case source file debug information</param>
        /// <param name="labels">Test Case labels</param>
        /// <returns>this</returns>
        public TestFrameworkBuilder TestCase(string name, int?id, SourceFileInfo source, IEnumerable <string> labels)
        {
            TestCase testCase = new TestCase(name, this.Parent);

            testCase.Id     = id;
            testCase.Source = source;
            testCase.Labels = labels;

            return(this);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructs a LogEntryMemoryLeak and populates the main components
 /// </summary>
 /// <param name="leakLocation">The location of the memory leak.</param>
 /// <param name="leakSizeInBytes">The number of bytes leaked.</param>
 /// <param name="leakMemoryAllocationNumber">The memory allocation number.</param>
 /// <param name="leakLeakedDataContents">The memory contents which were leaked.</param>
 /// <returns>A new LogEntryMemoryLeak instance populated accordingly</returns>
 public static LogEntryMemoryLeak MakeLogEntryMemoryLeak(SourceFileInfo leakLocation, uint?leakSizeInBytes, uint?leakMemoryAllocationNumber, string leakLeakedDataContents)
 {
     return(new LogEntryMemoryLeak()
     {
         Source = leakLocation,
         LeakSizeInBytes = leakSizeInBytes,
         LeakMemoryAllocationNumber = leakMemoryAllocationNumber,
         LeakLeakedDataContents = leakLeakedDataContents
     });
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Reads source files and returns info collection (name and version).
 /// </summary>
 /// <param name="sourceFilesDirectory">Source files path.</param>
 /// <returns>Source file info collection.</returns>
 public static IEnumerable <SourceFileInfo> GetSourceFiles(string sourceFilesDirectory)
 {
     foreach (string sourceFile in Directory.GetFiles(sourceFilesDirectory, "*.cs"))
     {
         SourceFileInfo info       = new SourceFileInfo();
         string         sourceCode = System.IO.File.ReadAllText(sourceFile);
         info.FileName = Path.GetFileName(sourceFile);
         info.Version  = GetVersionFromSource(sourceCode, info.FileName);
         yield return(info);
     }
 }
Ejemplo n.º 13
0
        public void WriteSourceFileInfo_WritesCorrectSourceFileType()
        {
            var data = Data.CreateDataStorage();

            var sfi = new SourceFileInfo();

            sfi.Type = JobType.XpsJob;
            sfi.WriteSourceFileInfo(data, "0\\");

            Assert.AreEqual("xps", data.GetValue("0\\SourceFileType"));
        }
        /// <summary>
        /// Builds a new TestSuite. Starts a new context in which
        /// newly created TestUnits will be parented to this TestSuite.
        /// </summary>
        /// <param name="name">Test Suite Name</param>
        /// <param name="id">Test Suite Id</param>
        /// <param name="source">Test Suite source file debug information</param>
        /// <returns>this</returns>
        public TestFrameworkBuilder TestSuite(string name, int?id, SourceFileInfo source)
        {
            TestSuite testSuite = new TestSuite(name, this.Parent);

            testSuite.Id     = id;
            testSuite.Source = source;

            this.Parent = testSuite;

            return(this);
        }
Ejemplo n.º 15
0
        public void SetUp()
        {
            _sourceFileInfoDataReader = new SourceFileInfoDataReader();
            _tempFileInfoFile         = TempFileHelper.CreateTempFile(nameof(SourceFileInfoDataReaderTest), "TestFileInfo.inf");
            _data = Data.CreateDataStorage();
            _infFileIniStorage = new IniStorage(_tempFileInfoFile, Encoding.GetEncoding("Unicode"));

            Fixture fixture = new Fixture();

            _sfi = fixture.Create <SourceFileInfo>();
        }
        /// <summary>
        /// Builds a new TestCase.
        /// </summary>
        /// <param name="name">Test Case Name</param>
        /// <param name="id">Test Case Id</param>
        /// <param name="source">Test Case source file debug information</param>
        /// <param name="labels">Test Case labels</param>
        /// <param name="enabled">Test Case enabled or disabled</param>
        /// <returns>this</returns>
        public TestFrameworkBuilder TestCase(string name, int?id, SourceFileInfo source, IEnumerable <string> labels, bool enabled)
        {
            TestCase testCase = new TestCase(name, this.Parent);

            testCase.Id             = id;
            testCase.Source         = source;
            testCase.Labels         = ((labels == null)? Enumerable.Empty <string>() : labels);
            testCase.DefaultEnabled = enabled;

            return(this);
        }
Ejemplo n.º 17
0
        public override void SaveMaterialContent(MaterialContent content)
        {
            SourceFileInfo.NullCheck("SourceFileInfo");
            DestFileInfo.NullCheck("DestFileInfo");

            if (CheckSourceFileExists)
            {
                ExceptionHelper.FalseThrow(SourceFileInfo.Exists, string.Format(Resource.FileNotFound, SourceFileInfo.Name));
            }

            MoveFile(SourceFileInfo, DestFileInfo);
        }
Ejemplo n.º 18
0
        public SymbolCodeDataProvider(CpuType type, ISymbolProvider symbolProvider, SourceFileInfo file)
        {
            //_prgRom = DebugApi.GetMemoryState(SnesMemoryType.PrgRom);
            _cpuType        = type;
            _symbolProvider = symbolProvider;
            _file           = file;
            _lineCount      = file.Data.Length;

            string filename = file.Name.ToLower();

            _isC = filename.EndsWith(".h") || filename.EndsWith(".c");
        }
Ejemplo n.º 19
0
        public void SetUp()
        {
            _jobInfo = new JobInfo();

            var sourceFileInfo = new SourceFileInfo();

            sourceFileInfo.ClientComputer = "someComputer";
            sourceFileInfo.JobCounter     = 3;
            sourceFileInfo.JobId          = 14;
            sourceFileInfo.PrinterName    = "SomePrinter";
            sourceFileInfo.SessionId      = 121;
            _jobInfo.SourceFiles.Add(sourceFileInfo);

            var metadata = new Metadata();

            metadata.PrintJobAuthor = "someAuthor";
            metadata.PrintJobName   = "somePrintJobName";
            metadata.Author         = "someAuthor";
            metadata.Title          = "someTitle";
            _jobInfo.Metadata       = metadata;

            _tokenReplacerFactory = new TokenReplacerFactory();

            _fileUtil = new MockFileUtil();
            _fileUtil.SetInstanceToMock();

            _environment = MockRepository.GenerateStub <IEnvironment>();
            _environment.Stub(e => e.UserName).Return("someUser");
            _environment.Stub(e => e.MachineName).Return("someMachine");

            var dateTime = MockRepository.GenerateStub <IDateTime>();

            dateTime.Stub(dt => dt.Now).Return(new DateTimeWrap(2000, 1, 1, 1, 1, 1));

            _job = MockRepository.GenerateStub <IJob>();
            _job.Stub(j => j.JobInfo).Return(_jobInfo);
            _job.Stub(j => j.NumberOfCopies).Return(5);
            _job.Stub(j => j.NumberOfPages).Return(14);

            _job.OutputFiles = new List <string>()
            {
                "outputFile", "test"
            };

            var path = MockRepository.GenerateStub <IPath>();

            path.Stub(p => p.GetFullPath("outputFile")).Return("fullPath");
            path.Stub(p => p.GetFileNameWithoutExtension("C:\\thedir\\thefile.txt")).Return("thefile");
            path.Stub(p => p.GetDirectoryName("C:\\thedir\\thefile.txt")).Return("C:\\thedir");
            path.Stub(p => p.GetFileName("")).IgnoreArguments().Return("file");

            _tokenReplacerFactory = new TokenReplacerFactory(dateTime, _environment, path);
        }
Ejemplo n.º 20
0
 public virtual void RefreshCode(ISymbolProvider symbolProvider, SourceFileInfo file)
 {
     _symbolProvider = symbolProvider;
     if (file == null)
     {
         this._provider = new CodeDataProvider(CpuType.Cpu);
     }
     else
     {
         this._provider = new SymbolCodeDataProvider(CpuType.Cpu, symbolProvider, file);
     }
 }
Ejemplo n.º 21
0
        public void SetUp()
        {
            _jobInfo = new JobInfo();

            var sourceFileInfo = new SourceFileInfo();

            sourceFileInfo.ClientComputer = "someComputer";
            sourceFileInfo.JobCounter     = 3;
            sourceFileInfo.JobId          = 14;
            sourceFileInfo.PrinterName    = "SomePrinter";
            sourceFileInfo.SessionId      = 121;
            _jobInfo.SourceFiles.Add(sourceFileInfo);

            var metadata = new Metadata();

            metadata.PrintJobAuthor = "someAuthor";
            metadata.PrintJobName   = "somePrintJobName";
            metadata.Author         = "someAuthor";
            metadata.Title          = "someTitle";
            metadata.Subject        = "someSubject";
            metadata.Keywords       = "SomeKeyword";
            _jobInfo.Metadata       = metadata;

            _tokenReplacerFactory = new TokenReplacerFactory(new DateTimeProvider(), new EnvironmentWrap(), new PathWrap(), new PathUtil(new PathWrap(), new DirectoryWrap()));

            _pathUtil = Substitute.For <IPathUtil>();

            _environment = MockRepository.GenerateStub <IEnvironment>();
            _environment.Stub(e => e.UserName).Return("someUser");
            _environment.Stub(e => e.MachineName).Return("someMachine");

            var dateTime = MockRepository.GenerateStub <IDateTimeProvider>();

            dateTime.Stub(dt => dt.Now()).Return(new DateTime(2000, 1, 1, 1, 1, 1));

            _job = new Job(_jobInfo, new ConversionProfile(), new JobTranslations(), new Accounts());
            _job.NumberOfCopies = 5;
            _job.NumberOfPages  = 14;

            _job.OutputFiles = new List <string> {
                "outputFile", "test"
            };

            var path = MockRepository.GenerateStub <IPath>();

            path.Stub(p => p.GetFullPath("outputFile")).Return("fullPath");
            path.Stub(p => p.GetFileNameWithoutExtension("C:\\thedir\\thefile.txt")).Return("thefile");
            path.Stub(p => p.GetDirectoryName("C:\\thedir\\thefile.txt")).Return("C:\\thedir");
            path.Stub(p => p.GetFileName("")).IgnoreArguments().Return("file");

            _tokenReplacerFactory = new TokenReplacerFactory(dateTime, _environment, path, _pathUtil);
        }
        public TestFrameworkBuilder TestSuite(string name, int?id, SourceFileInfo source, bool enabled)
        {
            TestSuite testSuite = new TestSuite(name, this.Parent);

            testSuite.Id     = id;
            testSuite.Source = source;

            this.Parent = testSuite;

            testSuite.DefaultEnabled = enabled;

            return(this);
        }
        /// <summary>
        /// Parses the <em>entire</em> test case/suite declaration
        /// </summary>
        /// <param name="splitMacro">The current source line split into tokens</param>
        /// <param name="sourceInfo">Source file and line information/param>
        /// <param name="code">The entire code split by line</param>
        /// <param name="line">The current source code line which is being evaluated</param>
        /// <returns>An array of string components which are of interest for test component evaluation</returns>
        private static string[] ParseTestDeclaration(string[] splitMacro, SourceFileInfo sourceInfo, string[] code, ref string line)
        {
            int newLineNumber = ScrollLines(sourceInfo.LineNumber, code, ref line);

            if (sourceInfo.LineNumber != newLineNumber)
            {
                // re calculate splitMacro
                splitMacro            = SplitMacro(line);
                sourceInfo.LineNumber = newLineNumber;
            }

            return(splitMacro);
        }
Ejemplo n.º 24
0
        private static void AssertSfiAreEqual(SourceFileInfo expectedSfi, SourceFileInfo actualSfi)
        {
            var type = typeof(SourceFileInfo);

            foreach (var propertyInfo in type.GetProperties())
            {
                if (propertyInfo.PropertyType == typeof(UserToken))
                {
                    continue;
                }

                Assert.AreEqual(propertyInfo.GetValue(expectedSfi), propertyInfo.GetValue(actualSfi), $"Failed Property: {propertyInfo.Name}");
            }
        }
 private static void AssertSfiAreEqual(SourceFileInfo result, SourceFileInfo sfi)
 {
     Assert.AreEqual(result.Filename, sfi.Filename);
     Assert.AreEqual(result.SessionId, sfi.SessionId);
     Assert.AreEqual(result.WinStation, sfi.WinStation);
     Assert.AreEqual(result.Author, sfi.Author);
     Assert.AreEqual(result.ClientComputer, sfi.ClientComputer);
     Assert.AreEqual(result.PrinterName, sfi.PrinterName);
     Assert.AreEqual(result.JobCounter, sfi.JobCounter);
     Assert.AreEqual(result.JobId, sfi.JobId);
     Assert.AreEqual(result.DocumentTitle, sfi.DocumentTitle);
     Assert.AreEqual(result.Type, sfi.Type);
     Assert.AreEqual(result.Copies, sfi.Copies);
     Assert.AreEqual(result.UserTokenEvaluated, sfi.UserTokenEvaluated);
     Assert.AreEqual(result.UserToken.KeyValueDict, sfi.UserToken.KeyValueDict);
 }
Ejemplo n.º 26
0
        public void WriteSourceFileInfo_WritesCorrectInfoToData()
        {
            var sfi = new SourceFileInfo();

            sfi.DocumentTitle = "title";
            sfi.WinStation    = "winstation";
            sfi.Author        = "author";
            var data = Data.CreateDataStorage();

            sfi.WriteSourceFileInfo(data, "0\\");

            Assert.AreEqual(sfi.DocumentTitle, data.GetValue("0\\DocumentTitle"));
            Assert.AreEqual(sfi.WinStation, data.GetValue("0\\WinStation"));
            Assert.AreEqual(sfi.Author, data.GetValue("0\\UserName"));

            // TODO extend this
        }
Ejemplo n.º 27
0
        public bool SelectFile(SourceFileInfo file)
        {
            if (!_inSourceView)
            {
                ToggleView();
            }

            foreach (SourceFileInfo fileInfo in cboSourceFile.Items)
            {
                if (fileInfo == file)
                {
                    cboSourceFile.SelectedItem = fileInfo;
                    return(true);
                }
            }

            return(false);
        }
        private void AddTokensForDocumentTitle(SourceFileInfo sfi, Metadata metadata)
        {
            var titleFilename = "";
            var titleFolder   = "";

            if (_pathUtil.IsValidRootedPath(sfi.DocumentTitle))
            {
                titleFilename = _pathWrapSafe.GetFileNameWithoutExtension(sfi.DocumentTitle);
                titleFolder   = _pathWrapSafe.GetDirectoryName(sfi.DocumentTitle);
            }
            else
            {
                titleFilename = metadata.PrintJobName;
            }

            _tokenReplacer.AddStringToken("InputFilename", titleFilename);
            _tokenReplacer.AddStringToken("InputFilePath", titleFolder);
        }
        /// <summary>
        /// Creates a new TestCase object.
        /// </summary>
        /// <param name="sourceExe">Name of the project executable</param>
        /// <param name="sourceInfo">.cpp file path and TestCase line number</param>
        /// <param name="suite">The suite in which testcase is present</param>
        /// <param name="testCaseName">Name of the testcase</param>
        /// <param name="isEnabled">The enabling status of the testcase</param>
        /// <returns>The created TestCase object</returns>
        public static TestCase CreateTestCase(string sourceExe, SourceFileInfo sourceInfo, QualifiedNameBuilder suite, string testCaseName, bool isEnabled = true)
        {
            suite.Push(testCaseName);

            string qualifiedName = suite.ToString();

            suite.Pop();

            var testCase = new TestCase(qualifiedName, BoostTestExecutor.ExecutorUri, sourceExe)
            {
                CodeFilePath = sourceInfo.File,
                LineNumber   = sourceInfo.LineNumber,
                DisplayName  = testCaseName,
            };

            GroupViaTraits(suite.ToString(), testCase, isEnabled);

            return(testCase);
        }
        /// <summary>
        /// Asserts test case details
        /// </summary>
        /// <param name="unit">The test case to test</param>
        /// <param name="id">The expected Id of the test case</param>
        /// <param name="info">The expected source file information of the test case</param>
        /// <param name="parent">The expected parent of the test case</param>
        private void AssertTestCase(TestUnit unit, int id, SourceFileInfo info, TestUnit parent)
        {
            AssertTestUnit(unit, typeof(TestCase), id, parent);

            TestCase test = ((TestCase)unit);

            Assert.That(test.Children, Is.Empty);

            SourceFileInfo unitInfo = test.Source;

            if (info == null)
            {
                Assert.That(unitInfo, Is.Null);
            }
            else
            {
                Assert.That(unitInfo.File, Is.EqualTo(info.File));
                Assert.That(unitInfo.LineNumber, Is.EqualTo(info.LineNumber));
            }
        }
        /// <summary>
        /// Appends the SourceInfo instance information to the provided StringBuilder.
        /// </summary>
        /// <param name="info">The SourceInfo instance to stringify.</param>
        /// <param name="sb">The StringBuilder which will host the result.</param>
        /// <returns>sb</returns>
        private static StringBuilder AppendSourceInfo(SourceFileInfo info, StringBuilder sb)
        {
            sb.Append((string.IsNullOrEmpty(info.File) ? "unknown location" : info.File));
            if (info.LineNumber > -1)
            {
                sb.Append('(').Append(info.LineNumber).Append(')');
            }

            sb.Append(": ");

            return sb;
        }
 /// <summary>
 /// Appends the SourceInfo instance information to the provided StringBuilder.
 /// </summary>
 /// <param name="info">The SourceInfo instance to stringify.</param>
 /// <param name="sb">The StringBuilder which will host the result.</param>
 /// <returns>sb</returns>
 private static StringBuilder AppendSourceInfo(SourceFileInfo info, StringBuilder sb)
 {
     return sb.Append(info).Append(": ");
 }