/// <summary> /// Asserts TestFramework equality i.e. both test hierarchies are equivalent in test units /// </summary> /// <param name="actual">The actual TestFramework to be compared against</param> /// <param name="expected">The expected TestFramework 'actual' should match</param> public static void IsEqualTo(TestFramework actual, TestFramework expected) { Assert.That(actual.Source, Is.EqualTo(expected.Source)); if (actual.MasterTestSuite == null) { Assert.That(expected.MasterTestSuite, Is.Null); } else { actual.MasterTestSuite.Apply(new FrameworkEqualityVisitor(expected.MasterTestSuite)); } }
/// <summary> /// Serializes the provided TestFramework as an XmlDocument /// </summary> /// <param name="framework">The TestFramework to serialize</param> /// <returns>The serialized Xml for the provided TestFramework</returns> private static XmlDocument Serialize(TestFramework framework) { XmlDocument doc = new XmlDocument(); using (XmlWriter writer = doc.CreateNavigator().AppendChild()) { XmlSerializer serializer = new XmlSerializer(typeof(TestFramework)); serializer.Serialize(writer, framework); } return doc; }
/// <summary> /// Compares a test framework deserialised from the provided embedded resource against the expected one /// </summary> /// <param name="resource">Path to an embedded resource which is to be treated as input for TestFramework deserialisation</param> /// <param name="expected">The TestFramework which the deserialised version should be compared against</param> private void Compare(string resource, TestFramework expected) { using (var stream = TestHelper.LoadEmbeddedResource(resource)) { TestFrameworkDOTDeserialiser parser = new TestFrameworkDOTDeserialiser(Source); TestFramework framework = parser.Deserialise(stream); FrameworkEqualityVisitor.IsEqualTo(framework, expected, false); } }