Beispiel #1
0
        public AnimesControllerTest()
        {
            //declare what mocks to use

            //mock setup

            updateAnimesMock = new Mock <IUpdateAnime>();
            anime            = new Anime();
            animes           = new List <Anime>();


            //ViewModels Mock setup
            animeViewModelMock   = new Mock <IViewAnime>();
            animesViewModelsMock = new List <IViewAnime>();


            //Controller Setup
            //animeControllerMock = new Mock<IAnimeController>();
            var animeMock        = new Mock <IAnime>();
            var animeResultsMock = new Mock <IActionResult>();

            mockRepo = new Mock <IRepositoryWrapper>();
            var allAnimes        = GetAnimes();
            var animesController = new AnimesController(mockRepo.Object);
        }
Beispiel #2
0
        public void AnimeControllerTestsInit()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            _context = new ApplicationDbContext(options);

            var genre = new Genre {
                ID = 25, Name = "Sports"
            };

            animes.Add(new Anime {
                ID = 12, Name = "Haikyuu!!", Episodes = 8, AirStart = DateTime.Now, Genres = genre
            });
            animes.Add(new Anime {
                ID = 103, Name = "Naruto", Episodes = 9, AirStart = DateTime.Now, Genres = genre
            });
            animes.Add(new Anime {
                ID = 64, Name = "Bleach", Episodes = 10, AirStart = DateTime.Now, Genres = genre
            });

            foreach (var a in animes)
            {
                _context.Animes.Add(a);
            }

            _context.SaveChanges();
            controller = new AnimesController(_context);
        }
Beispiel #3
0
        public void DeleteAnime_Test()
        {
            //Arrange
            mockRepo.Setup(repo => repo.Animes.FindByCondition(c => c.ID == It.IsAny <int>())).Returns(GetAnimes());
            mockRepo.Setup(repo => repo.Animes.Delete(GetAnime()));
            //Act
            var controllerActionResult = new AnimesController(mockRepo.Object).Delete(It.IsAny <int>());

            //Assert
            Assert.NotNull(controllerActionResult);
        }
Beispiel #4
0
        public void GetAllAnimes_Test()
        {
            //arrange
            mockRepo.Setup(repo => repo.Animes.FindAll()).Returns(GetAnimes);


            // ACt (call the controller)

            var controllerActionResult = new AnimesController(mockRepo.Object).Index();

            //assert
            Assert.NotNull(controllerActionResult);
        }