2008-11-19 10 views
14

मुझे हाल ही में nnnit में धाराप्रवाह इंटरफ़ेस के संपर्क में लाया गया है और मुझे यह पसंद है; हालांकि, मैं msTest का उपयोग कर रहा हूँ।क्या एमएसटीएस्ट के लिए एक धाराप्रवाह दावा API है?

क्या किसी को पता है कि कोई धाराप्रवाह इंटरफ़ेस है या तो परीक्षण फ्रेमवर्क अज्ञेयवादी या msTest के लिए है?

उत्तर

17

देखें Fluent Assertions। आप

"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 
+2

चश्मे! वे कुछ भी नहीं करते! – bzlm

0

मेरे शोध के आधार पर कोई नहीं है, लेकिन यदि आप बेहतर रिपोर्टिंग को त्यागने के इच्छुक हैं, जहां तक ​​एक जोर विफल रहा है और एक नया डीएल जोड़ने के इच्छुक हैं तो आप नूनिट का संदर्भ दे सकते हैं और उनका उपयोग कर सकते हैं ....

5

देखें http://sharptestex.codeplex.com/

नोट: SharpTestsEx अब सक्रिय रूप से विकसित कर रही है, की सिफारिश की वैकल्पिक http://www.fluentassertions.com/ है।

SharpTestsEx (तीव्र टेस्ट एक्सटेंशन) एक्स्टेंसिबल एक्सटेंशन का एक सेट है। मुख्य लक्ष्य छोटे दावे लिखना है जहां विजुअल स्टूडियो आईडीई इंटेलिजेंस आपकी मार्गदर्शिका है। #TestsEx का उपयोग न्यूटिट, एमएसटेस्ट्स, xUnit, MbUnit ... सिल्वरलाइट में भी किया जा सकता है। दृढ़ता से टाइप किया दावे के लिए

सिंटेक्स उदाहरण (वेबपेज से लिया गया):

true.Should().Be.True(); 
false.Should().Be.False(); 

const string something = "something"; 
something.Should().Contain("some"); 
something.Should().Not.Contain("also"); 
something.ToUpperInvariant().Should().Not.Contain("some"); 

something.Should() 
    .StartWith("so") 
    .And 
    .EndWith("ing") 
    .And 
    .Contain("meth"); 

something.Should() 
    .Not.StartWith("ing") 
    .And 
    .Not.EndWith("so") 
    .And 
    .Not.Contain("body"); 

var ints = new[] { 1, 2, 3 }; 
ints.Should().Have.SameSequenceAs(new[] { 1, 2, 3 }); 
ints.Should().Not.Have.SameSequenceAs(new[] { 3, 2, 1 }); 
ints.Should().Not.Be.Null(); 
ints.Should().Not.Be.Empty(); 

ints.Should() 
    .Contain(2) 
    .And 
    .Not.Contain(4); 

(new int[0]).Should().Be.Empty(); 
+0

जबकि मुझे लगता है कि हैरीडेव कुछ उपयोगी जानकारी जोड़ सकता था, मेरी राय में, SharpTestEx FluentAssertions से थोड़ा अधिक परिपक्व प्रतीत होता है। निश्चित रूप से प्रारंभिक अवलोकन। कोई भी मुझे यह दिखाने के लिए स्वतंत्र महसूस करता है कि FluentAssertions बेहतर क्यों हो सकता है। – llaughlin

+0

शार्पटेस्टएक्स मूल रूप से मर चुका है, जबकि फ्लुएंट एसरशन सक्रिय रूप से विकसित किए जा रहे हैं और सभी प्रमुख इकाई परीक्षण ढांचे के साथ-साथ .NET 4.5, WinRT, Silverlight 5 और WP7/8 सहित सभी .NET Framework संस्करणों के लिए समर्थन भी जोड़ते हैं। –

संबंधित मुद्दे