Returns() public method

Sets the expected result for the test
public Returns ( object result ) : TestCaseData
result object The expected result
return TestCaseData
        private static TestCaseData GetTestCaseData(string name)
        {
            var asm = Assembly.GetExecutingAssembly();
            var originalStream = asm.GetManifestResourceStream(typeof (_Dummy), name + ".txt");
            var goldStream = asm.GetManifestResourceStream(typeof (_Dummy), name + ".gold");

            Debug.Assert(originalStream != null, "originalStream != null");
            Debug.Assert(goldStream != null, "goldStream != null");

            string original;
            string gold;

            using (var streamReader = new StreamReader(originalStream, Encoding.UTF8))
                original = streamReader.ReadToEnd();

            using (var streamReader = new StreamReader(goldStream, Encoding.UTF8))
                gold = streamReader.ReadToEnd();

            var testCaseData = new TestCaseData(original);

            testCaseData.SetName(name);
            testCaseData.Returns(gold.Split(new[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries));

            return testCaseData;
        }
Example #2
0
        private static TestCaseData datumToTestCase(Datum d)
        {
            var ignore = false;
            var quoted = checkQuote(d);
            if(quoted != null)
            {
                d = quoted;
                ignore = true;
            }
            var combo = d.ToArray();

            if (combo.Length < 3)
                throw new Exception(string.Format("'{0}' is not a valid test case", d));
            var name = combo[0] as Symbol;
            if (name == null)
                throw new Exception(string.Format("'{0}' is not a valid test case", d));

            var expected = combo[1];
            var expression = combo[2];
            var testCase = new TestCaseData(expression);
            testCase.Returns(expected);
            testCase.SetName(name.Identifier);
            if (ignore)
                testCase.Ignore("quoted");
            return testCase;
        }