Example #1
0
        public async Task TestEditTextTemplateAsyncMethod()
        {
            var optionsBuilder   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("testDb3");
            var virtualDbContext = new ApplicationDbContext(optionsBuilder.Options);

            IEFRepository <TextTemplate> textTemplateRepository = new EFRepository <TextTemplate>(virtualDbContext);
            IEFRepository <Obituary>     obituaryRepository     = new EFRepository <Obituary>(virtualDbContext);

            var textService = new TextsService(textTemplateRepository, obituaryRepository);

            await textService.AddTextToDbAsync("text test 1");

            await textService.AddTextToDbAsync("text test 2");

            await textTemplateRepository.SaveChangesAsync();

            var textId = textTemplateRepository.All()
                         .Select(t => t.Id).FirstOrDefault();
            await textService.EditTextTemplateAsync(textId, "new edited text");

            await textTemplateRepository.SaveChangesAsync();

            var text = textTemplateRepository.All()
                       .Select(t => t.Text).FirstOrDefault();

            Assert.Equal("new edited text", text);
        }
Example #2
0
        public void TestReturnFirtsTextMethod()
        {
            var textService = new TextsService(textTemplateRepo.Object, obituaryRepo.Object);
            var text        = textService.ReturnFirtsText();

            Assert.Equal("Text test 1", text);
        }
Example #3
0
        public void TestGetTextByIdMethod()
        {
            var textService = new TextsService(textTemplateRepo.Object, obituaryRepo.Object);
            var text        = textService.GetTextById("ttId1");

            Assert.Equal("Text test 1", text);
        }
Example #4
0
        public void TestShowAllTextsMethod()
        {
            var textService = new TextsService(textTemplateRepo.Object, obituaryRepo.Object);

            var textsCount = textService.ShowAllTexts().Count();

            Assert.Equal(2, textsCount);
        }
Example #5
0
        public async Task TestAddTextToDbAsyncMethod()
        {
            var optionsBuilder   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("testDb");
            var virtualDbContext = new ApplicationDbContext(optionsBuilder.Options);

            IEFRepository <TextTemplate> textTemplateRepository = new EFRepository <TextTemplate>(virtualDbContext);
            IEFRepository <Obituary>     obituaryRepository     = new EFRepository <Obituary>(virtualDbContext);

            var textService = new TextsService(textTemplateRepository, obituaryRepository);

            await textService.AddTextToDbAsync("text test 1");

            await textService.AddTextToDbAsync("text test 2");

            await textTemplateRepository.SaveChangesAsync();

            var dbCount = textTemplateRepository.All().Count();

            Assert.Equal(2, dbCount);
        }