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);
        }
        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);
        }
Exemple #3
0
            public static IEnumerable <TestCaseData> SingleValue(bool testReturnsAValue)
            {
                string       valueToSend  = "abc";
                TestCaseData testCaseData = new TestCaseData(_IPENDPOINT, valueToSend);

                if (testReturnsAValue)
                {
                    testCaseData.Returns(valueToSend);
                }
                yield return(testCaseData);
            }
Exemple #4
0
            TestCaseData GenPayData
                (int fullYears, double expectedPay, Exception exception = null)
            {
                TestCaseData data = GenData(fullYears);

                data.SetDescription(string.Format(descriptionPatternPay, fullYears, expectedPay));
                if (exception != null)
                {
                    data.Throws(exception.GetType());
                }
                else
                {
                    data.Returns(expectedPay);
                }
                return(data);
            }
            private static TestCaseData GetManagerWithSubordinnatesData(int fullYears, double expectedResult, int[] gruntYears = null, int[] managersYears = null, int[] salesYears = null)
            {
                var manager       = new Organization.Manager("Manager", "Manageroff", DateTime.Now.AddYears(-fullYears), Organization.BASEPAYRATE);
                int gruntsCount   = 0;
                int managersCount = 0;
                int salesCount    = 0;

                if (gruntYears != null)
                {
                    gruntsCount = gruntYears.Length;
                    foreach (var fullYear in gruntYears)
                    {
                        GetGrunt(fullYear).SetManager(manager);
                    }
                }

                if (managersYears != null)
                {
                    managersCount = managersYears.Length;
                    foreach (var fullYear in managersYears)
                    {
                        GetManager(fullYear).SetManager(manager);
                    }
                }

                if (salesYears != null)
                {
                    salesCount = salesYears.Length;

                    foreach (var fullYear in salesYears)
                    {
                        GetSales(fullYear).SetManager(manager);
                    }
                }
                var data = new TestCaseData(manager);

                data.SetCategory(categoryName);
                data.SetDescription(string.Format(descriptionPattern, fullYears, gruntsCount, managersCount, salesCount));
                data.SetName(string.Format(namePattern, fullYears, gruntsCount + managersCount + salesCount));
                data.Returns(expectedResult);

                return(data);
            }
        public static TestCaseData WithArguments(
            [NotNull] this TestCaseData AData,
            [NotNull] params object[] AParams
            )
        {
            var with = new TestCaseData(AParams);

            foreach (var key in AData.Properties.Keys)
            {
                with.Properties.Set(key, AData.Properties.Get(key));
            }

            if (AData.HasExpectedResult)
            {
                with.Returns(AData.ExpectedResult);
            }

            return(with);
        }