views:

366

answers:

3

I've recently been exposed to the fluent interface in nUnit and I love it; however, I am using msTest.

Does anyone know if there is a fluent interface that is either testing framework agnostic or for msTest?

Thanks,

Josh

+1  A: 

Based on my research there isn't one, but if your willing to sacrifice the better reportability as far as why an assert failed and willing to add a new dll you can reference nunit and use theirs....

JoshBerke
+3  A: 

See http://sharptestex.codeplex.com/

harrydev
+2  A: 

See http://fluentassertions.codeplex.com. You can do stuff like

"ABCDEFGHI".Should().StartWith("AB").And.EndWith("HI").And.Contain("EF").And.HaveLength(9);

new[] { 1, 2, 3 }.Should().HaveCount(4, "because we thought we put three items in the 
collection"))

dtoCollection.Should().Contain(dto => dto.Id != null);

collection.Should().HaveCount(c => c >= 3);

dto.ShouldHave().AllPropertiesBut(d => d.Id).EqualTo(customer);

dt1.Should().BeWithin(TimeSpan.FromHours(50)).Before(dt2); 

Action action = () => recipe.AddIngredient("Milk", 100, Unit.Spoon);
action
   .ShouldThrow<RuleViolationException>()
   .WithMessage("Cannot change the unit of an existing ingredient")
   .And.Violations.Should().Contain(BusinessRule.CannotChangeIngredientQuanity
Dennis Doomen