public static IEnumerable<Test> ParseYears() {
     return parsedDates.Select(pd => {
         var name = "ParseYears " + pd.Key;
         Test t = new TestCase(name, () => Assert.AreEqual(pd.Value, DateTimeOffsetFieldParser.Parse(pd.Key)));
         return t;
     });
 }
        private static TestCase BuildTestCase(Type serializer, Type message)
        {
            string name = string.Format("{0}_{1}",serializer.Name.Replace("Adapter`1",""),message.Name);
            TestCase test = new TestCase(name, () => RunTest(serializer,message) );

            return test;
        }
 public void GetName()
 {
     StringWriter sw = new StringWriter();
     string name = "MyName";
     TestCase tc = new TestCase(name, new TestDelegate(this.Hello), sw);
     Assert.AreEqual(name, tc.Name);
 }
 public void AddDuplicateTestCase2()
 {
     TestSuite suite = new TestSuite("Suite");
     TestCase tc = new TestCase("Test", new TestDelegate(this.Test));
     suite.Add(tc);
     suite.Add(tc);
 }
 public void GetTest()
 {
     StringWriter sw = new StringWriter();
     string name = "MyName";
     Delegate hello = new TestDelegate(this.Hello);
     TestCase tc = new TestCase(name, hello, sw);
     Assert.AreEqual(hello.Method, tc.TestDelegate.Method);
 }
Beispiel #6
0
 public static IEnumerable<Test> Tests() {
     return testParams.Select(dv => {
         var expectedResult = dv.Value;
         var localParams = dv.Key;
         Test t = new TestCase(expectedResult, () => Assert.AreEqual(expectedResult, new LocalParams(localParams).ToString()));
         return t;
     });
 }
 public void GetParameters()
 {
     StringWriter sw = new StringWriter();
     string name = "MyName";
     Delegate hello = new TestDelegate(this.Hello);
     TestCase tc = new TestCase(name, hello, sw);
     ArrayAssert.AreEqual(new Object[] { sw }, tc.GetParameters());
 }
Beispiel #8
0
        public void CodeElement()
        {
            TestCase testCase = new TestCase("Name", delegate { });
            Assert.IsNull(testCase.CodeElement);

            ITypeInfo type = Reflector.Wrap(typeof(TestCase));
            testCase.CodeElement = type;
            Assert.AreSame(type, testCase.CodeElement);
        }
 public void Invoke()
 {
     StringWriter sw = new StringWriter();
     string name = "MyName";
     Delegate hello = new TestDelegate(this.Hello);
     TestCase tc = new TestCase(name, hello, sw);
     tc.Invoke(this,new ArrayList());
     Assert.AreEqual("hello", sw.ToString());
 }
 public static IEnumerable<Test> RoundTrip() {
     return dateTimes.Select(dt => {
         Test t = new TestCase("RoundTrip " + dt, () => {
             var value = DateTimeOffsetFieldParser.Parse(DateTimeOffsetFieldSerializer.Serialize(dt));
             Assert.AreEqual(dt, value);
         });
         return t;
     });
 }
Beispiel #11
0
        public void ConstructorRequiresNameAndExecuteAction()
        {
            Assert.Throws<ArgumentNullException>(() => new TestCase(null, delegate { }));
            Assert.Throws<ArgumentNullException>(() => new TestCase("Foo", null));

            Action execute = delegate { };
            TestCase testCase = new TestCase("Name", execute);
            Assert.AreEqual("Name", testCase.Name);
            Assert.AreSame(execute, testCase.Execute);
        }
 public static IEnumerable<Test> ParseYears() {
     return parsedDates.Select(pd => {
         var name = "ParseYears " + pd.Key;
         Test t = new TestCase(name, () => {
             var value = DateTimeFieldParser.ParseDate(pd.Key);
             Assert.AreEqual(pd.Value, value);
             Assert.AreEqual(pd.Value.Kind, value.Kind);
         });
         return t;
     });
 }
 public static TestCase Case(string name, Delegate test, params Object[] parameters)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (name.Length == 0)
         throw new ArgumentException("name is empty");
     if (test == null)
         throw new ArgumentNullException("test");
     TestCase tc = new TestCase(name, test, parameters);
     return tc;
 }
Beispiel #14
0
        public void TimeoutMustBeNullOrPositive()
        {
            TestCase testCase = new TestCase("Name", delegate { });
            Assert.AreEqual(TestAssemblyExecutionParameters.DefaultTestCaseTimeout, testCase.Timeout);

            testCase.Timeout = TimeSpan.FromSeconds(5);
            Assert.AreEqual(TimeSpan.FromSeconds(5), testCase.Timeout);

            testCase.Timeout = null;
            Assert.IsNull(testCase.Timeout);

            Assert.Throws<ArgumentOutOfRangeException>(() => testCase.Timeout = TimeSpan.FromSeconds(-1));
        }
Beispiel #15
0
        public void DescriptionStoredInMetadata()
        {
            TestCase testCase = new TestCase("Name", delegate { });
            Assert.IsNull(testCase.Description);
            Assert.IsFalse(testCase.Metadata.ContainsKey(MetadataKeys.Description));

            testCase.Description = "Description";
            Assert.AreEqual("Description", testCase.Description);
            Assert.AreEqual("Description", testCase.Metadata.GetValue(MetadataKeys.Description));

            testCase.Description = null;
            Assert.IsNull(testCase.Description);
            Assert.IsFalse(testCase.Metadata.ContainsKey(MetadataKeys.Description));
        }
 public static IEnumerable<Test> NullableRoundTrips() {
     var parser = new NullableFieldParser(new DateTimeOffsetFieldParser());
     var serializer = new NullableFieldSerializer(new DateTimeOffsetFieldSerializer());
     return dateTimes.Select(dt => {
         Test t = new TestCase("NullableRoundTrips " + dt, () => {
             var s = serializer.Serialize(dt).First().FieldValue;
             var xml = new XDocument();
             xml.Add(new XElement("date", s));
             var value = (DateTimeOffset?)parser.Parse(xml.Root, typeof(DateTimeOffset?));
             Assert.AreEqual(dt, value);
         });
         return t;
     });
 }
Beispiel #17
0
        /// <summary>
        /// Removes the test case from the suite
        /// </summary>
        /// <param name="testCase">Test case to remove</param>
        /// <exception cref="ArgumentNullException">
        /// 	<paramref name="testCase"/> is a null reference
        /// (Nothing in Visual Basic)
        /// </exception>
        public void Remove(TestCase testCase)
        {
            if (testCase == null)
                throw new ArgumentNullException("testCase");
            this.testCases.Remove(testCase);
 public void ParameterIncompatibleWithTest()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("test", null, 1);
 }
 public void NullTest()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("test", null, sw);
 }
 public void NullName()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase(null, new TestDelegate(this.Hello), sw);
 }
 public void EmptyName()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("", new TestDelegate(this.Hello), sw);
 }