public void ObjectScenarioShouldFail() { var a = new object(); var b = new object(); var c = new object(); var d = new object(); var target = new[] { a, b, c }; Verify.ShouldFail(() => target.ShouldContain(d, "Some additional context"), errorWithSource: @"target should contain System.Object (000000) but was actually [System.Object (000000), System.Object (000000), System.Object (000000)] Additional Info: Some additional context", errorWithoutSource: @"[System.Object (000000), System.Object (000000), System.Object (000000)] should contain System.Object (000000) but did not Additional Info: Some additional context"); }
protected override void ShouldPass() { var a = new Object(); var b = new Object(); var c = new Object(); var target = new[] { a, b, c }; target.ShouldContain(b); }
public void ShouldPass() { var a = new Object(); var b = new Object(); var c = new Object(); var target = new[] { a, b, c }; target.ShouldContain(b); }
protected override void ShouldThrowAWobbly() { var a = new Object(); var b = new Object(); var c = new Object(); var d = new Object(); var target = new[] { a, b, c }; target.ShouldContain(d, "Some additional context"); }
public void available_values_generator() { var names = new[] { "name1", "name2", "name3" }; var generated = Rand.NextArrayOf<Account>(CollectionSize); foreach (var item in generated) { names.ShouldContain(item.Name); } }
public void ShouldContain_WithPredicate_UsingObjectsShouldDisplayMeaningfulMessage() { var vampires = new[] { new Vampire {BitesTaken = 1}, new Vampire {BitesTaken = 2}, new Vampire {BitesTaken = 3}, new Vampire {BitesTaken = 4}, new Vampire {BitesTaken = 5}, new Vampire {BitesTaken = 6}, }; TestHelper.ShouldFailWithError(() => vampires.ShouldContain(x => x.BitesTaken > 7), "vampires should contain an element satisfying the condition (x.BitesTaken > 7)"); }
public void ShouldContain() { var longString = new string('a', 110); Should.Error( () => longString.ShouldContain("zzzz"), string.Format("() => longString should contain \"zzzz\" but was \"{0}\"", longString.Substring(0, 100)) ); var justTheRightLengthString = new string('a', 80); Should.Error( () => justTheRightLengthString.ShouldContain("zzzz"), string.Format("() => justTheRightLengthString should contain \"zzzz\" but was \"{0}\"", justTheRightLengthString) ); Should.Error(() => new[] { 1, 2, 3 }.ShouldContain(5), "new[]{ 1, 2, 3 } should contain 5 but was [1, 2, 3]"); var vampires = new[] { new Vampire {BitesTaken = 1}, new Vampire {BitesTaken = 2}, new Vampire {BitesTaken = 3}, new Vampire {BitesTaken = 4}, new Vampire {BitesTaken = 5}, new Vampire {BitesTaken = 6}, }; Should.Error(() => vampires.ShouldContain(x => x.BitesTaken > 7), "vampires should contain an element satisfying the condition (x.BitesTaken > 7) but does not"); Should.Error(() => new[] { 1, 2, 3 }.ShouldContain(x => x % 4 == 0), "new[]{1,2,3} should contain an element satisfying the condition ((x % 4) = 0) but does not"); Should.Error(() => new[] { 1.0, 2.1, Math.PI, 4.321, 5.4321 }.ShouldContain(3.14, 0.001), "new[] { 1.0, 2.1, Math.PI, 4.321, 5.4321 } should contain 3.14 but was [1, 2.1, 3.14159265358979, 4.321, 5.4321]"); Should.Error(() => new[] { 1.0f, 2.1f, (float)Math.PI, 4.321f, 5.4321f }.ShouldContain(3.14f, 0.001), "new[] { 1.0f, 2.1f, (float)Math.PI, 4.321f, 5.4321f } should contain 3.14 but was [1, 2.1, 3.141593, 4.321, 5.4321]"); }
public void contains_fails_when_element_is_not_found() { var items = new[] {"one", "two"}; Executing(() => items.ShouldContain("three")) .ShouldThrow<AssertionException>(); }
public void contains_doesnt_fail_when_element_is_found() { var items = new[] {"one", "two"}; items.ShouldContain("one"); }
public void ReturnsJson_WithIEnumerable_IncludingNonDefaultValues() { var databaseValues = new[] { "S1", "S2" }; var scenarioOptions = new ScenarioOptions(); var controller = CreateController(scenarioOptions); scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(It.Is(FindDistinctSuffixesQuery))) .Returns(databaseValues); var result = controller.AutoCompleteSuffixes(null); result.ShouldNotBeNull(); result.ShouldBeType<JsonResult>(); result.Data.ShouldImplement<IEnumerable<object>>(); var enumerable = (IEnumerable<object>)result.Data; foreach (var anonymous in enumerable) { dynamic item = anonymous; string value = item.value; string label = item.label; if (label == PersonNameController.SalutationAndSuffixNullValueLabel) continue; if (PersonNameController.DefaultSuffixValues.Contains(value)) continue; databaseValues.ShouldContain(value); databaseValues.ShouldContain(label); } }