Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReportGenerator
- {
- string Generate(string inputPathA, string inputPathB)
- {
- //do stuff
- }
- }
- [TextFixture]
- public class ReportGeneratorTests
- {
- static Diff(string pathToExpectedResult, string pathToActualResult)
- {
- using (StreamReader rs1 = File.OpenText(pathToExpectedResult))
- {
- using (StreamReader rs2 = File.OpenText(pathToActualResult))
- {
- string actualContents = rs2.ReadToEnd();
- string expectedContents = rs1.ReadToEnd();
- //this works, but the output could be a LOT more useful.
- Assert.AreEqual(expectedContents, actualContents);
- }
- }
- }
- static TestGenerate(string pathToInputA, string pathToInputB, string pathToExpectedResult)
- {
- ReportGenerator obj = new ReportGenerator();
- string pathToResult = obj.Generate(pathToInputA, pathToInputB);
- Diff(pathToExpectedResult, pathToResult);
- }
- [Test]
- public void TestX()
- {
- TestGenerate("x1.xml", "x2.xml", "x-expected.txt");
- }
- [Test]
- public void TestY()
- {
- TestGenerate("y1.xml", "y2.xml", "y-expected.txt");
- }
- //etc...
- }
- using NUnit.Framework.Extensions;
- [RowTest]
- [Row("x1.xml", "x2.xml", "x-expected.xml")]
- [Row("y1.xml", "y2.xml", "y-expected.xml")]
- public void TestGenerate(string pathToInputA, string pathToInputB, string pathToExpectedResult)
- {
- ReportGenerator obj = new ReportGenerator();
- string pathToResult = obj.Generate(pathToInputA, pathToInputB);
- Diff(pathToExpectedResult, pathToResult);
- }
- [Test] public void TestX() { DoTest("X"); }
- [Test] public void TestY() { DoTest("Y"); }
Add Comment
Please, Sign In to add comment