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(IStorage storage, ITestStorage testStorage, ITestBuilderFactory testBuilderFactory, IEnumerable <IExerciseGenerator> generators, FilterGenerator filterGenerator) { this.storage = storage; this.testStorage = testStorage; this.testBuilderFactory = testBuilderFactory; this.filterGenerator = filterGenerator; generatorsByCaption = new Dictionary <string, IExerciseGenerator>(); foreach (var generator in generators) { generatorsByCaption[generator.GetTypeCaption()] = generator; } }
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"); }
/// <summary> /// Creates a new TestSuiteBuilder. /// </summary> /// <param name="testBuilderFactory">An alternate test builder factory to use.</param> public TestSuiteBuilder(ITestBuilderFactory testBuilderFactory) { _testBuilderFactory = testBuilderFactory; }