public void DeserializedTestCaseContainsSameDataAsOriginalTestCase()
        {
            var testCollection = new XunitTestCollection();
            var type = typeof(ClassUnderTest);
            var method = type.GetMethod("FactMethod");
            var fact = CustomAttributeData.GetCustomAttributes(method).Single(cad => cad.AttributeType == typeof(FactAttribute));
            var testCase = new XunitTheoryTestCase(testCollection, Reflector.Wrap(type.Assembly), Reflector.Wrap(type), Reflector.Wrap(method), Reflector.Wrap(fact));
            var serialized = SerializationHelper.Serialize(testCase);

            var result = SerializationHelper.Deserialize<XunitTheoryTestCase>(serialized);

            Assert.Equal(testCase.Assembly.AssemblyPath, result.Assembly.AssemblyPath);
            Assert.Equal(testCase.Assembly.Name, result.Assembly.Name);
            Assert.Equal(testCase.Class.Name, result.Class.Name);
            Assert.Equal(testCase.Method.Name, result.Method.Name);
            Assert.Equal(testCase.DisplayName, result.DisplayName);
            Assert.Null(result.Arguments);
            Assert.Equal(testCase.SkipReason, result.SkipReason);
            Assert.Collection(result.Traits.Keys,
                key =>
                {
                    Assert.Equal("name", key);
                    Assert.Equal("value", Assert.Single(result.Traits[key]));
                });
        }
        public void CanSerializeFactBasedTestCase()
        {
            var testCollection = new XunitTestCollection();
            var type = typeof(ClassUnderTest);
            var method = type.GetMethod("FactMethod");
            var fact = CustomAttributeData.GetCustomAttributes(method).Single(cad => cad.AttributeType == typeof(FactAttribute));
            var testCase = new XunitTheoryTestCase(testCollection, Reflector.Wrap(type.Assembly), Reflector.Wrap(type), Reflector.Wrap(method), Reflector.Wrap(fact));

            Assert.DoesNotThrow(() => SerializationHelper.Serialize(testCase));
        }
 /// <summary>
 /// Converts a <see cref="XunitTheoryTestCase"/> into an equivalent theory test case for the discoverer.
 /// </summary>
 /// <param name="testCase">The test case to convert.</param>
 /// <param name="defaultMethodDisplay">The default test method display.</param>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages.</param>
 /// <param name="timeout">The amount of time the test case is allowed to run in milliseconds, or a value less than 1 to indicate no timeout.</param>
 /// <param name="useStaThread">Whether to use an STA thread to execute tests.</param>
 /// <returns>The converted test case (the default implementation returns a <see cref="TimeoutXunitTheoryTestCase"/>).</returns>
 protected virtual XunitTheoryTestCase ConvertTheoryTestCase(XunitTheoryTestCase testCase, TestMethodDisplay defaultMethodDisplay, IMessageSink diagnosticMessageSink, int timeout, bool useStaThread)
 {
     return(new TimeoutXunitTheoryTestCase(diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod, timeout, useStaThread));
 }