Skip to content

Instantly share code, notes, and snippets.

@danappleyard
Created July 11, 2011 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danappleyard/1076372 to your computer and use it in GitHub Desktop.
Save danappleyard/1076372 to your computer and use it in GitHub Desktop.
[Test]
public void adding_valid_question_to_existing_question_pool_returns_valid()
{
var transBuilder = Isolate.Fake.Instance<ITransactionFactory>();
var questionPoolRepo = Isolate.Fake.Instance<IQuestionPoolRepository>();
var questionRepo = Isolate.Fake.Instance<IQuestionRepository>();
var distractorRepo = Isolate.Fake.Instance<IDistractorRepository>();
var synchronizer = Isolate.Fake.Instance<ILearningReviewQuestionSynchronizationService>();
var archiver = Isolate.Fake.Instance<IQuestionArchiveService>();
var resequencer = Isolate.Fake.Instance<IQuestionSequenceService>();
var validator = Isolate.Fake.Instance<IQuestionValidationService>();
var svc = new QuestionService(transBuilder, questionPoolRepo, questionRepo, distractorRepo, synchronizer, archiver, resequencer, validator);
var question = new QuestionsEntity {QuestionPoolID = 33};
var distractors = new List<DistractorsEntity>();
var ts = new TimeStamp(1, 44, DateTime.UtcNow);
var trans = Isolate.Fake.Instance<Transaction>();
Isolate.WhenCalled(() => validator.ValidateNewQuestionForExistingQuestionPool(new QuestionViewModel())).WillReturn(new Validation(true));
Isolate.WhenCalled(() => transBuilder.BuildTransaction("AddNewQuestion")).WillReturn(trans);
Isolate.WhenCalled(() => questionPoolRepo.GetNextSequenceNumber(33, ref trans)).WillReturn(3);
var val = svc.AddQuestionToExistingQuestionPool(question, distractors, ts);
Isolate.Verify.WasCalledWithAnyArguments(() => transBuilder.BuildTransaction("AddNewQuestion"));
Assert.IsTrue(val.IsValid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment