Exemplo n.º 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));
 }
Exemplo n.º 2
0
        public void GetParentThreadInfo()
        {
            ParentThread          = Thread.CurrentThread;
            ParentThreadApartment = GetApartmentState(ParentThread);

            TestContext.AddFormatter <Thread>((t) => "Thread #" + ((Thread)t).ManagedThreadId);
        }
Exemplo n.º 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"));
        }
Exemplo n.º 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));
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
 }
Exemplo n.º 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})");
     });
 }
Exemplo n.º 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"));
        }
Exemplo n.º 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"));
        }
Exemplo n.º 12
0
 static DataPropertyConstraint()
 {
     TestContext.AddFormatter <DataPropertyConstraint>(val => Format((DataPropertyConstraint)val));
 }
Exemplo n.º 13
0
 public void ConfigureFormatters()
 {
     TestContext.AddFormatter <HtmlNode>(n => HtmlRenderer.Default.RenderNode((HtmlNode)n));
 }
Exemplo n.º 14
0
 public void ConfigureFormatters()
 {
     TestContext.AddFormatter <HtmlEntity>(e => ((HtmlEntity)e).ToHtml());
 }