diff options
| author | mo khan <mo@mokhan.ca> | 2007-11-02 17:03:42 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2007-11-02 17:03:42 -0600 |
| commit | 36ffa9f174c831146ca5630a41b75c9d213f3db6 (patch) | |
| tree | 3ba71964656b385995bb9557c87a05b131348ddf /src/test/PlayingWithActiveReports.Test/Repositories/QuestionBankTest.cs | |
Diffstat (limited to 'src/test/PlayingWithActiveReports.Test/Repositories/QuestionBankTest.cs')
| -rw-r--r-- | src/test/PlayingWithActiveReports.Test/Repositories/QuestionBankTest.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/PlayingWithActiveReports.Test/Repositories/QuestionBankTest.cs b/src/test/PlayingWithActiveReports.Test/Repositories/QuestionBankTest.cs new file mode 100644 index 0000000..a8d86cb --- /dev/null +++ b/src/test/PlayingWithActiveReports.Test/Repositories/QuestionBankTest.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic;
+using MbUnit.Framework;
+using PlayingWithActiveReports.Core.Domain;
+using PlayingWithActiveReports.Core.Repositories;
+
+namespace PlayingWithActiveReports.Test {
+ [TestFixture]
+ public class QuestionBankTest {
+ [Test]
+ public void Should_Be_Able_To_Create_A_New_Question( ) {
+ const string withText = "How are you?";
+ IQuestionBank bank = CreateSut( );
+ IQuestion question = bank.CreateQuestion( withText );
+
+ Assert.AreEqual( withText, question.Text );
+ Assert.IsNotNull( question.Id );
+ }
+
+ [Test]
+ public void Should_Contain_No_Items( ) {
+ IEnumerable< IQuestion > allQuestions = CreateSut( ).FindAll( );
+ Assert.AreEqual( 0, GetCountFor( allQuestions ) );
+ }
+
+ [Test]
+ public void Should_Return_Count_Of_2( ) {
+ IQuestionBank bank = CreateSut( );
+ bank.CreateQuestion( "What is your name?" );
+ bank.CreateQuestion( "How old are you?" );
+
+ Assert.AreEqual( 2, bank.Count );
+ }
+
+ [RowTest]
+ [Row( 1 )]
+ [Row( 2 )]
+ [Row( 3 )]
+ [Row( 4 )]
+ public void Should_Return_2_Items( int expectedCount ) {
+ IQuestionBank bank = CreateSut( );
+
+ for( int i = 0; i < expectedCount; i++ ) {
+ bank.CreateQuestion( "How old are you?" );
+ }
+
+ Assert.AreEqual( expectedCount, GetCountFor( bank.FindAll( ) ) );
+ }
+
+ private int GetCountFor< T >( IEnumerable< T > items ) {
+ return new List< T >( items ).Count;
+ }
+
+ private IQuestionBank CreateSut( ) {
+ return new QuestionBank( );
+ }
+ }
+}
\ No newline at end of file |
