Example #1
0
 public void SetUp()
 {
     storage     = A.Fake <IStorage>();
     testStorage = A.Fake <ITestStorage>();
     factory     = A.Fake <ITestBuilderFactory>();
     controller  = new TestsController(storage, testStorage, factory, new IExerciseGenerator[0], null);
     ControllerTestsHelper.AttachUserToControllerContext(controller, "admin");
 }
        public TestsController_GeneratingTests()
        {
            generators = new IExerciseGenerator[] {
                new OpenQuestionExerciseGenerator(),
                new MatchingQuestionExerciseGenerator(),
                new ChoiceQuestionExerciseGenerator()
            };

            exercises = new Exercise[0];
            cards     = new List <Card>
            {
                new Card("t1", "d1", "admin", id),
                new Card("t2", "d2", "admin", id)
            };
            collection = new Collection("coll", "admin", id);
            testQuery  = new TestQueryDto(id,
                                          new List <TestBlockDto>
            {
                new TestBlockDto(generators[0].GetTypeCaption(), 1),
                new TestBlockDto(generators[1].GetTypeCaption(), 2),
                new TestBlockDto(generators[2].GetTypeCaption(), 3)
            }, null);

            fakeStorage     = A.Fake <IStorage>();
            fakeTestStorage = A.Fake <ITestStorage>();
            factory         = A.Fake <ITestBuilderFactory>();
            fakeBuilder     = A.Fake <ITestBuilder>();

            A.CallTo(() => fakeStorage.FindCollection(A <Guid> ._, A <CancellationToken> ._)).Returns(collection);
            A.CallTo(() => fakeStorage.GetCollectionCards(id, A <CancellationToken> ._)).Returns(cards);
            A.CallTo(() => fakeBuilder.Build()).Returns(exercises);
            A.CallTo(() => fakeBuilder.WithGenerator(A <IExerciseGenerator> ._, A <int> ._)).Returns(fakeBuilder);
            A.CallTo(() => factory.GetBuilder(cards, A <ICardsSelector> ._)).Returns(fakeBuilder);

            controller = new TestsController(fakeStorage, fakeTestStorage, factory, generators, null);
            ControllerTestsHelper.AttachUserToControllerContext(controller, "admin");
        }
 public void SetUp()
 {
     fakeStorage = A.Fake <IStorage>();
     controller  = new CardsController(fakeStorage, null);
     ControllerTestsHelper.AttachUserToControllerContext(controller, "admin");
 }