Beispiel #1
0
        public async Task Results_Results_WhenSearchIsTitle()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                var controller = new SearchController(db);

                var picture = new Picture
                {
                    Id         = 1,
                    IsImage    = true,
                    Likes      = 10,
                    Title      = "Test",
                    UploadDate = DateTime.Now,
                    Url        = "//Test",
                    UserId     = "test",
                    UserName   = "******"
                };

                await db.Pictures.AddAsync(picture);

                await db.SaveChangesAsync();

                string searchTerm = "Test";

                controller.Results(searchTerm);

                Assert.AreEqual(1, controller.PictureResults.Count);
            }
        }
Beispiel #2
0
        public async Task AddChapter_ImageIsNotUploaded_WhenImageIsNull()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                var controller = new ComicController(db);

                await controller.AddChapter(null, "Test", 1);

                Assert.AreEqual(controller.ModelState.ErrorCount, 1);
            }
        }
Beispiel #3
0
        public async Task DeleteMessageAsync_MessageIsDeleted_WhenMessageIsFound()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                //var comicController = new ComicController(db);



                Assert.AreEqual(0, 0);
            }
        }
Beispiel #4
0
        public async Task AddChapter_ChapterIsNotUploaded_WhenImageIsNotCorrect()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                var physicalFile = new FileInfo("links.txt");
                var formFile     = physicalFile.AsMockIFormFile();

                var controller = new ComicController(db);

                await controller.AddChapter(formFile, "Test", 1);

                Assert.AreEqual(controller.ModelState.ErrorCount, 1);
            }
        }
Beispiel #5
0
        public void Results_NoResults_WhenSearchStringIsNull()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                var controller = new SearchController(db);

                string searchTag = null;

                RedirectToPageResult result = (RedirectToPageResult)controller.Results(searchTag);


                Assert.AreEqual(result.PageName, "/Index");
            }
        }
Beispiel #6
0
        public async Task UploadComic_ComicIsUploaded_WhenImageIsCorrectPng()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                var physicalFile = new FileInfo("002.png");
                var formFile     = physicalFile.AsMockIFormFile();

                var controller = new ComicController(db);
                try
                {
                    await controller.UploadComic(formFile, "Test", "Test", "Test");
                }
                catch { }

                Assert.AreEqual(controller.ModelState.ErrorCount, 0);
            }
        }
Beispiel #7
0
        public async Task UploadImage_ImageIsNotUploaded_WhenImageIsNull()
        {
            using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions()))
            {
                var controller = new ImageController(db);

                try
                {
                    await controller.UploadImage(null, "Test", "Test");
                }
                catch { }


                var a = controller.ModelState.ErrorCount;

                Assert.AreEqual(controller.ModelState.ErrorCount, 1);
            }
        }