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)); }
public void GetParentThreadInfo() { ParentThread = Thread.CurrentThread; ParentThreadApartment = GetApartmentState(ParentThread); TestContext.AddFormatter <Thread>((t) => "Thread #" + ((Thread)t).ManagedThreadId); }
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")); }
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)); }
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); }
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)); }
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})"); }); }
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")); }
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")); }
static DataPropertyConstraint() { TestContext.AddFormatter <DataPropertyConstraint>(val => Format((DataPropertyConstraint)val)); }
public void ConfigureFormatters() { TestContext.AddFormatter <HtmlNode>(n => HtmlRenderer.Default.RenderNode((HtmlNode)n)); }
public void ConfigureFormatters() { TestContext.AddFormatter <HtmlEntity>(e => ((HtmlEntity)e).ToHtml()); }