コード例 #1
0
        public void GetMoviesCountShouldReturn0()
        {
            var repository = new Mock <IDeletableEntityRepository <Movie> >();
            var service    = new MoviesService(repository.Object);

            Assert.Equal(0, service.GetMoviesCount());
            repository.Verify(x => x.All(), Times.Once);
        }
コード例 #2
0
        public async Task GetMoviesCount_WithValidInput_ShouldReturnValidResult()
        {
            var dbContext = ApplicationDbContextCreatorInMemory.InitializeContext();

            await this.SeedData(dbContext);

            var moviesRepository = new EfDeletableEntityRepository <Movie>(dbContext);
            var genresRepository = new EfDeletableEntityRepository <Genre>(dbContext);
            var service          = new MoviesService(moviesRepository, genresRepository);

            var result = service.GetMoviesCount();

            Assert.Equal(2, result);
        }
コード例 #3
0
        public void GetMoviesCountShouldReturn3()
        {
            var repository = new Mock <IDeletableEntityRepository <Movie> >();

            repository.Setup(r => r.All()).Returns(new List <Movie>
            {
                new Movie(),
                new Movie(),
                new Movie(),
            }.AsQueryable());
            var service = new MoviesService(repository.Object);

            Assert.Equal(3, service.GetMoviesCount());
            repository.Verify(x => x.All(), Times.Once);
        }