コード例 #1
0
        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]));
            });
        }
コード例 #2
0
        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));
        }