private KeyValuePair <string, ITestCase> Deserialize(XunitTestFrameworkDiscoverer discoverer,
                                                             ITestFrameworkExecutor executor,
                                                             string serialization)
        {
            var testCase = default(ITestCase);

            try
            {
                if (serialization.Length > 3 && serialization.StartsWith(":F:"))
                {
                    // Format from TestCaseDescriptorFactory: ":F:{typeName}:{methodName}:{defaultMethodDisplay}"
                    var parts = serialization.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length > 3)
                    {
                        var typeInfo             = discoverer.AssemblyInfo.GetType(parts[1]);
                        var testClass            = discoverer.CreateTestClass(typeInfo);
                        var methodInfo           = testClass.Class.GetMethod(parts[2], true);
                        var testMethod           = new TestMethod(testClass, methodInfo);
                        var defaultMethodDisplay = (TestMethodDisplay)int.Parse(parts[3]);
                        testCase = new XunitTestCase(DiagnosticMessageSink, defaultMethodDisplay, testMethod);
                    }
                }

                if (testCase == null)
                {
                    testCase = executor.Deserialize(serialization);
                }

                return(new KeyValuePair <string, ITestCase>(testCase.UniqueID, testCase));
            }
            catch (Exception ex)
            {
                return(new KeyValuePair <string, ITestCase>(ex.ToString(), null));
            }
        }
Exemple #2
0
 static ITestCase Deserialize(LoggerHelper logger, ITestFrameworkExecutor executor, TestCase testCase)
 {
     try
     {
         return(executor.Deserialize(testCase.GetPropertyValue <string>(SerializedTestCaseProperty, null)));
     }
     catch (Exception ex)
     {
         logger.LogError("Unable to de-serialize test case {0}: {1}", testCase.DisplayName, ex);
         return(null);
     }
 }
Exemple #3
0
 private static KeyValuePair <string, ITestCase> Deserialize(ITestFrameworkDiscoverer discoverer,
                                                             ITestFrameworkExecutor executor,
                                                             string serialization)
 {
     try
     {
         var testCase = executor.Deserialize(serialization);
         return(new KeyValuePair <string, ITestCase>(testCase.UniqueID, testCase));
     }
     catch (Exception ex)
     {
         return(new KeyValuePair <string, ITestCase>($"Test case deserialization failure: {ex}", null));
     }
 }
Exemple #4
0
 /// <inheritdoc/>
 public ITestCase Deserialize(string value)
 {
     return(executor.Deserialize(value));
 }
Exemple #5
0
 /// <inheritdoc/>
 public List <KeyValuePair <string?, ITestCase?> > BulkDeserialize(List <string> serializations) =>
 serializations
 .Select(serialization => executor.Deserialize(serialization))
 .Select(testCase => new KeyValuePair <string?, ITestCase?>(testCase?.UniqueID, testCase))
 .ToList();