Example #1
0
        public async Task TestB()
        {
            var mocker = new MockDataV6();

            mocker.Reset();

            var serviceProvider = new ServiceCollection()
                                  .AddTransient <ICollectionRepo, CollectionRepo>()
                                  .AddTransient <IFlashcardProgressRepo, FlashcardProgressRepo>()
                                  .AddTransient <IFlashcardRepo, FlashcardRepo>()
                                  .AddDbContext <AppDbContext>(options => options.UseSqlServer(MockDatabaseFactory.DbMockConnectionString))
                                  .AddMediatR(typeof(MediatREntryPoint).Assembly)
                                  .BuildServiceProvider();

            var mediator = serviceProvider.GetService <IMediator>();

            var output = await mediator.Send(new GetFlashcardsListWithProgressQ(Guid.Parse("d30c8f79-291b-4532-8f22-b693e61d6bb5"), "9a4e1d79-d64e-4ec4-85e5-53bdef5043f4"));

            var flashcard = output.FirstOrDefault(e => e.Id == Guid.Parse("6aa83ba0-1396-428f-adb7-d7ab972459eb"));

            Assert.NotNull(flashcard);

            Assert.Equal("Foreign 1", flashcard.Foreign);
            Assert.Equal("Native 1", flashcard.Native);

            Assert.Equal(2, flashcard.ProgressForeignToNative.CorrectInRow);
            Assert.Equal(DateTime.Now.Date.AddDays(5).ToString("dd-MM-yyyy"), flashcard.ProgressForeignToNative.PracticeDate);
            Assert.Equal(DateTime.Now.Date.AddDays(5 + 3).ToString("dd-MM-yyyy"), flashcard.ProgressForeignToNative.PracticeDateIfCorrectAns);
        }
        public async Task TestE()
        {
            var mocker = new MockDataV6();

            mocker.Reset();

            _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjlhNGUxZDc5LWQ2NGUtNGVjNC04NWU1LTUzYmRlZjUwNDNmNCIsIm5iZiI6MTYxOTc2OTYzOCwiZXhwIjoxNjE5ODU2MDM4LCJpc3MiOiJhIn0.tohmUFgbnXqaMoehSX9i-p_F6vpdoziu9Jz5XgM1N1k");


            var response = await _client.GetAsync("api/practice/updateflashcardprogress/9dccbe2b-fd54-42e7-8f35-c0fba62855f7/3");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var response2 = await _client.GetAsync("api/practice/updateflashcardprogress/9dccbe2b-fd54-42e7-8f35-c0fba62855f7/3");

            Assert.Equal(HttpStatusCode.OK, response2.StatusCode);

            await Task.Delay(1000 * 5);

            using (var db = MockDatabaseFactory.Build())
            {
                var flashcardProgressModel = await db.FlashcardProgresses.FirstOrDefaultAsync(e => e.Id == Guid.Parse("9dccbe2b-fd54-42e7-8f35-c0fba62855f7"));

                Assert.Equal(3, flashcardProgressModel.CorrectInRow);
                Assert.Equal(DateTime.Now.Date, flashcardProgressModel.PracticeDate);
            }
        }
Example #3
0
        public async Task TestA()
        {
            var mocker = new MockDataV6();

            mocker.Reset();

            var serviceProvider = new ServiceCollection()
                                  .AddTransient <ICollectionRepo, CollectionRepo>()
                                  .AddTransient <IFlashcardRepo, FlashcardRepo>()
                                  .AddTransient <IFlashcardProgressRepo, FlashcardProgressRepo>()
                                  .AddDbContext <AppDbContext>(options => options.UseSqlServer(MockDatabaseFactory.DbMockConnectionString))
                                  .AddMediatR(typeof(MediatREntryPoint).Assembly)
                                  .BuildServiceProvider();

            var mediator = serviceProvider.GetService <IMediator>();

            var output = await mediator.Send(new GetFlashcardsListWithProgressQ(Guid.Parse("d30c8f79-291b-4532-8f22-b693e61d6bb5"), "9a4e1d79-d64e-4ec4-85e5-53bdef5043f4"));

            Assert.Equal(3, output.Count);
        }