コード例 #1
0
        public bool TryGetValue(string key, out TestResult testResult)
        {
            var blob = TestResultsContainer.GetBlockBlobReference(key);

            if (!blob.Exists())
            {
                testResult = default(TestResult);
                return(false);
            }

            var str = blob.DownloadText();
            var obj = (TestResultJson)JsonConvert.DeserializeObject(str, typeof(TestResultJson));

            testResult = new TestResult(
                exitCode: obj.ExitCode,
                outputStandard: obj.OutputStandard,
                outputError: obj.OutputError,
                resultsFileName: obj.ResultsFileName,
                resultsFileContent: obj.ResultsFileContent,
                unitTestData: new UnitTestData(
                    passed: obj.Passed,
                    failed: obj.Failed,
                    skipped: obj.Skipped),
                elapsed: TimeSpan.FromSeconds(obj.ElapsedSeconds));
            return(true);
        }
コード例 #2
0
        public void Add(string key, TestResult value)
        {
            if (string.IsNullOrEmpty(value.ResultsFileContent) || value.ResultsFileContent.Length > SizeLimit)
            {
                throw new Exception("Data too big");
            }

            var blob = TestResultsContainer.GetBlockBlobReference(key);

            var obj = new TestResultJson()
            {
                ExitCode           = value.ExitCode,
                OutputStandard     = value.OutputStandard,
                OutputError        = value.OutputError,
                ResultsFileName    = value.ResultsFileName,
                ResultsFileContent = value.ResultsFileContent,
                ElapsedSeconds     = value.Elapsed.TotalSeconds,
                Passed             = value.UnitTestData.Passed,
                Failed             = value.UnitTestData.Failed,
                Skipped            = value.UnitTestData.Skipped
            };

            var str = JsonConvert.SerializeObject(obj);

            blob.UploadText(str);
        }