shouldly - Shouldly Documentation Release 2.6.0 Dave Newman Xerxes Battiwalla Anthony Egerton Peter van der Contents 1 ShouldBe 1.1 Objects 1.2 Numeric

shouldly - Shouldly Documentation Release 2.6.0 Dave Newman...

This preview shows page 1 - 8 out of 29 pages.

Shouldly DocumentationRelease 2.6.0Dave Newman, Xerxes Battiwalla, Anthony Egerton, Peter van derDecember 04, 2016
Background image
Background image
Contents1ShouldBe31.1Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31.2Numeric. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31.3DateTime(Offset). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31.4TimeSpan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31.5Enumerables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31.6Enumerables of Numerics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41.7Bools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42ShouldNotBe52.1Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52.2Numeric. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52.3DateTime(Offset). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52.4TimeSpan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53ShouldMatchApproved73.1Approved File does not exist. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73.2Approved File does not match received. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73.3Options and customisation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83.4Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104ShouldBeTrue/False134.1ShouldBeTrue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134.2ShouldBeFalse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135ShouldBeNull/NotBeNull155.1ShouldBeNull. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .155.2ShouldNotBeNull. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156ShouldHaveFlag/NotHaveFlag176.1ShouldHaveFlag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176.2ShouldNotHaveFlag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177Example Classes198Contributing218.1Style Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219Configuration23i
Background image
9.1DefaultFloatingPointTolerance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239.2DefaultTaskTimeout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239.3CompareAsObjectTypes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2310 Indices and tables25ii
Background image
Shouldly Documentation, Release 2.6.0How assertingShouldbeAttention:These docs are in progress! Get involved at Learn more abouton GitHub, contributions welcome!First time contributors welcome, we are happy to help you get started.This is the oldAssertway:Assert.That(contestant.Points, Is.EqualTo(1337));For your troubles, you get this message, when it fails:Expected 1337 but was 0How itShouldbe:contestant.Points.ShouldBe(1337);Which is just syntax, so far, but check out the message when it fails:contestant.Points should be 1337 but was 0It might be easy to underestimate how useful this is. Another example, side by side:Assert.That(map.IndexOfValue("boo"), Is.EqualTo(2));// -> Expected 2 but was 1map.IndexOfValue("boo").ShouldBe(2);// -> map.IndexOfValue("boo") should be 2 butShouldlyuses the variables within theShouldBestatement to report on errors, which makes diagnosing easier.Another example, if you compare two collections:new[] {1,2,3}.ShouldBe(new[] {1,2,4});and it fails because they’re different, it’ll show you the differences between the two collections:should be[1, 2, 4]but was[1, 2, 3]difference[1, 2,*3*]Shouldly has plenty of different assertions, have a look under the assertions folder for all the options.Contents1
Background image
Shouldly Documentation, Release 2.6.02Contents
Background image
CHAPTER1ShouldBe1.1 ObjectsShouldBeExamplesworks on all types and compares using.Equals.Exception1.2 NumericShouldBenumeric overloads accept tolerances and has overloads forfloat,doubleanddecimaltypes.Exception1.3 DateTime(Offset)DateTime overloads are similar to the numeric overloads and support tolerances.Exception1.4 TimeSpanTimeSpan also has tolerance overloadsExceptionWant to improve shouldy? We have an open issue at [#303]() to im-prove this error message!1.5 EnumerablesEnumerable comparison is done on the elements in the enumerable, so you can compare an array to a list and have itpass.
Background image
Image of page 8

You've reached the end of your free preview.

Want to read all 29 pages?

  • Spring '17
  • gg
  • Default, Default judgment, Diff, Shouldly Documentation, Shouldly

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture