Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestResult"/> class.
        /// </summary>
        /// <param name="computerName">
        /// The computer name.
        /// </param>
        /// <param name="runId">
        /// The run id.
        /// </param>
        /// <param name="test">
        /// The test.
        /// </param>
        /// <param name="outcome">
        /// The outcome.
        /// </param>
        public TestResult(
            Guid runId,
            Guid testId,
            Guid executionId,
            Guid parentExecutionId,
            string resultName,
            string computerName,
            TestOutcome outcome,
            TestType testType,
            TestListCategoryId testCategoryId,
            TrxFileHelper trxFileHelper)
        {
            Debug.Assert(computerName != null, "computername is null");
            Debug.Assert(!Guid.Empty.Equals(executionId), "ExecutionId is empty");
            Debug.Assert(!Guid.Empty.Equals(testId), "TestId is empty");

            this.Initialize();

            this.id           = new TestResultId(runId, executionId, parentExecutionId, testId);
            this.resultName   = resultName;
            this.testType     = testType;
            this.computerInfo = computerName;
            this.outcome      = outcome;
            this.categoryId   = testCategoryId;
            this.relativeTestResultsDirectory = TestRunDirectories.GetRelativeTestResultsDirectory(executionId);
            this.trxFileHelper = trxFileHelper;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestRunConfiguration"/> class.
        /// </summary>
        /// <param name="name">
        /// The name of Run Configuration.
        /// </param>
        /// <param name="trxFileHelper">
        /// InternalFileHelper instance to use in file operations.
        /// </param>
        internal TestRunConfiguration(string name, TrxFileHelper trxFileHelper)
        {
            EqtAssert.ParameterNotNull(name, "name");

            this.name = name;
            this.runDeploymentRoot = string.Empty;
            this.id            = new TestRunConfigurationId();
            this.trxFileHelper = trxFileHelper;
        }
 public TestResultAggregation(
     Guid runId,
     Guid testId,
     Guid executionId,
     Guid parentExecutionId,
     string resultName,
     string computerName,
     TestOutcome outcome,
     TestType testType,
     TestListCategoryId testCategoryId,
     TrxFileHelper trxFileHelper) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper)
 {
 }
Example #4
0
        public void DefaultTrxFileNameVerification()
        {
            this.parameters.Remove(TrxLoggerConstants.LogFileNameKey);
            this.parameters[TrxLoggerConstants.LogFilePrefixKey] = DefaultLogFilePrefixParameterValue;

            var time          = DateTime.Now;
            var trxFileHelper = new TrxFileHelper(() => time);

            testableTrxLogger = new TestableTrxLogger(new FileHelper(), trxFileHelper);
            testableTrxLogger.Initialize(this.events.Object, this.parameters);

            MakeTestRunComplete();

            var fileName     = Path.GetFileName(testableTrxLogger.trxFile);
            var expectedName = $"{DefaultLogFilePrefixParameterValue}{time:_yyyyMMddHHmmss}.trx";

            Assert.AreEqual(expectedName, fileName, "Trx file name pattern has changed. It should be in the form of prefix_yyyyMMddHHmmss.trx, Azure Devops VSTest task depends on this naming.");
        }
Example #5
0
        private string[] TestMultipleTrxLoggers()
        {
            var files = new string[2];

            try
            {
                var time = new DateTime(2020, 1, 1, 0, 0, 0);

                var trxFileHelper = new TrxFileHelper(() => time);
                var trxLogger1    = new TestableTrxLogger(new FileHelper(), trxFileHelper);
                var trxLogger2    = new TestableTrxLogger(new FileHelper(), trxFileHelper);

                trxLogger1.Initialize(this.events.Object, this.parameters);
                trxLogger2.Initialize(this.events.Object, this.parameters);

                MakeTestRunComplete(trxLogger1);
                files[0] = trxLogger1.trxFile;

                MakeTestRunComplete(trxLogger2);
                files[1] = trxLogger2.trxFile;
            }
            finally
            {
                files = files
                        .Where(i => !string.IsNullOrWhiteSpace(i))
                        .Distinct()
                        .ToArray();

                foreach (var file in files)
                {
                    if (!string.IsNullOrEmpty(file) && File.Exists(file))
                    {
                        File.Delete(file);
                    }
                }
            }

            return(files);
        }
Example #6
0
 internal TrxLogger(IFileHelper fileHelper, TrxFileHelper trxFileHelper)
 {
     this.converter     = new Converter(fileHelper, trxFileHelper);
     this.trxFileHelper = trxFileHelper;
 }
Example #7
0
 public TestableTrxLogger(IFileHelper fileHelper, TrxFileHelper trxFileHelper) : base(fileHelper, trxFileHelper)
 {
 }
Example #8
0
        /// <summary>
        /// Initializes the URI data attachment
        /// </summary>
        /// <param name="description">Short description for the attachment</param>
        /// <param name="uri">The URI pointing to the resource</param>
        /// <param name="trxFileHelper">InternalFileHelper class instance to use in file operations.</param>
        /// <exception cref="ArgumentException">'name' is null or empty</exception>
        /// <exception cref="ArgumentNullException">'uri' is null</exception>
        public UriDataAttachment(string description, Uri uri, TrxFileHelper trxFileHelper)
        {
            this.trxFileHelper = trxFileHelper;

            Initialize(description, uri);
        }
        public void ReplaceInvalidFileNameCharsShouldReplaceSpace()
        {
            var fileHelper = new TrxFileHelper();

            Assert.AreEqual("samadala_SAMADALA_2017-10-13_18_33_17", fileHelper.ReplaceInvalidFileNameChars("samadala_SAMADALA 2017-10-13 18_33_17"));
        }
Example #10
0
 public ConverterTests()
 {
     this.fileHelper    = new Mock <IFileHelper>();
     this.trxFileHelper = new TrxFileHelper();
     this.converter     = new Converter(this.fileHelper.Object, trxFileHelper);
 }