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;
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 public void AddDuplicateTestCase2()
 {
     TestSuite suite = new TestSuite("Suite");
     TestCase tc = new TestCase("Test", new TestDelegate(this.Test));
     suite.Add(tc);
     suite.Add(tc);
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 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;
     });
 }
Exemplo n.º 7
0
 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());
 }
Exemplo n.º 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);
        }
Exemplo n.º 9
0
 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;
     });
 }
Exemplo n.º 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);
        }
Exemplo n.º 12
0
 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;
     });
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 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));
        }
Exemplo n.º 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;
     });
 }
Exemplo n.º 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);
Exemplo n.º 18
0
 public void ParameterIncompatibleWithTest()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("test", null, 1);
 }
Exemplo n.º 19
0
 public void NullTest()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("test", null, sw);
 }
Exemplo n.º 20
0
 public void NullName()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase(null, new TestDelegate(this.Hello), sw);
 }
Exemplo n.º 21
0
 public void EmptyName()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("", new TestDelegate(this.Hello), sw);
 }