示例#1
0
 public void SetUp()
 {
     TestContext.AddFormatter <EventExpectation> (o => Formatter.Format((EventExpectation)o));
     TestContext.AddFormatter <EventExpectation[]> (o => Formatter.Format((EventExpectation[])o));
     TestContext.AddFormatter <Event> (o => Formatter.Format((Event)o));
     TestContext.AddFormatter <IEnumerable <Event> > (o => Formatter.Format((IEnumerable <Event>)o));
 }
示例#2
0
        public void GetParentThreadInfo()
        {
            ParentThread          = Thread.CurrentThread;
            ParentThreadApartment = GetApartmentState(ParentThread);

            TestContext.AddFormatter <Thread>((t) => "Thread #" + ((Thread)t).ManagedThreadId);
        }
示例#3
0
        public static void FormatValue_ContextualCustomFormatterNotInvokedForNull()
        {
            // If this factory is actually called with null, it will throw
            TestContext.AddFormatter(next => val => (val.GetType() == typeof(CustomFormattableType)) ? val.ToString() : next(val));

            Assert.That(MsgUtils.FormatValue(null), Is.EqualTo("null"));
        }
示例#4
0
 public void SetUpTests()
 {
     TestContext.AddFormatter <Point>(val => PointToString((Point)val));
     TestContext.AddFormatter <Size>(val => SizeToString((Size)val));
     TestContext.AddFormatter <Line>(val => LineToString((Line)val));
     TestContext.AddFormatter <Rect>(val => RectToString((Rect)val));
 }
示例#5
0
 public void SetUp()
 {
     TestContext.AddFormatter <TObject>(obj =>
     {
         var tObj = (TObject)obj;
         return($"{tObj} (T = {tObj.Time}, L = {tObj.Length})");
     });
 }
 public void SetUp()
 {
     TestContext.AddFormatter <ILengthedObject>(obj =>
     {
         var lengthedObject = (ILengthedObject)obj;
         return($"{obj} (T = {lengthedObject.Time}, L = {lengthedObject.Length})");
     });
 }
        public void TestApprox2(float input, float roundTo, float expected)
        {
            TestContext.AddFormatter <float>(val => ((float)val).ToString("F6"));

            var output = input.RoundTo(roundTo);

            Assert.AreEqual(expected, output);
        }
示例#8
0
 public void SetUp()
 {
     // Work around NUnit bug/feature.
     // NUnit tries to enumerate any IEnumerable for informational
     // purposes (NUnit.Framework.Constraints.MsgUtils), but Variant
     // will throw an exception if it is not a container. This causes
     // tests to fail unexpectedly. So, we add a value formatter for
     // Variant so that it does not try to use the built-in IEnumerable.
     TestContext.AddFormatter <Variant> (v => ((Variant)v).Print(true));
 }
示例#9
0
 public void SetUp()
 {
     TestContext.AddFormatter <ITimedObject>(obj =>
     {
         var timedObject    = (ITimedObject)obj;
         var lengthedObject = obj as ILengthedObject;
         return(lengthedObject != null
             ? $"{obj} (T = {lengthedObject.Time}, L = {lengthedObject.Length})"
             : $"{obj} (T = {timedObject.Time})");
     });
 }
示例#10
0
        public static void FormatValue_ContextualCustomFormatterInvoked_FormatterArg()
        {
            TestContext.AddFormatter <CustomFormattableType>(val => "custom_formatted_using_type");

            Assert.That(MsgUtils.FormatValue(new CustomFormattableType()), Is.EqualTo("custom_formatted_using_type"));
        }
示例#11
0
        public static void FormatValue_ContextualCustomFormatterInvoked_FactoryArg()
        {
            TestContext.AddFormatter(next => val => (val is CustomFormattableType) ? "custom_formatted" : next(val));

            Assert.That(MsgUtils.FormatValue(new CustomFormattableType()), Is.EqualTo("custom_formatted"));
        }
示例#12
0
 static DataPropertyConstraint()
 {
     TestContext.AddFormatter <DataPropertyConstraint>(val => Format((DataPropertyConstraint)val));
 }
示例#13
0
 public void ConfigureFormatters()
 {
     TestContext.AddFormatter <HtmlNode>(n => HtmlRenderer.Default.RenderNode((HtmlNode)n));
 }
示例#14
0
文件: Setup.cs 项目: radiaku/LtGt
 public void ConfigureFormatters()
 {
     TestContext.AddFormatter <HtmlEntity>(e => ((HtmlEntity)e).ToHtml());
 }