コード例 #1
0
 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;
     });
 }
コード例 #2
0
        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;
        }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #6
0
ファイル: LocalParamsTests.cs プロジェクト: FilipVV/SolrNet
 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;
     });
 }
コード例 #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());
 }
コード例 #8
0
ファイル: TestCaseTest.cs プロジェクト: rprouse/mbunit-v3
        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);
        }
コード例 #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());
 }
コード例 #10
0
 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;
     });
 }
コード例 #11
0
ファイル: TestCaseTest.cs プロジェクト: rprouse/mbunit-v3
        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);
        }
コード例 #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;
     });
 }
コード例 #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;
 }
コード例 #14
0
ファイル: TestCaseTest.cs プロジェクト: rprouse/mbunit-v3
        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));
        }
コード例 #15
0
ファイル: TestCaseTest.cs プロジェクト: rprouse/mbunit-v3
        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));
        }
コード例 #16
0
 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;
     });
 }
コード例 #17
0
ファイル: TestSuite.cs プロジェクト: timonela/mb-unit
        /// <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);
コード例 #18
0
 public void ParameterIncompatibleWithTest()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("test", null, 1);
 }
コード例 #19
0
 public void NullTest()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("test", null, sw);
 }
コード例 #20
0
 public void NullName()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase(null, new TestDelegate(this.Hello), sw);
 }
コード例 #21
0
 public void EmptyName()
 {
     StringWriter sw = new StringWriter();
     TestCase tc = new TestCase("", new TestDelegate(this.Hello), sw);
 }