Ejemplo n.º 1
0
        public async Task ShouldBeReturningTheEvaluationOfAGivenExpression()
        {
            var body1    = "body1";
            var body2    = "body2";
            var body3    = "body3";
            var body4    = "body4";
            var repo     = new MoviesMemoryRepository(TimeSpan.FromSeconds(10));
            var movieId1 = Guid.NewGuid();
            var movieId2 = Guid.NewGuid();
            var movieId3 = Guid.NewGuid();
            var movieId4 = Guid.NewGuid();

            await repo.Add(new Movie()
            {
                body = body1, id = movieId1
            });

            await repo.Add(new Movie()
            {
                body = body2, id = movieId2
            });

            await repo.Add(new Movie()
            {
                body = body3, id = movieId3
            });

            await repo.Add(new Movie()
            {
                body = body4, id = movieId4
            });

            var movie = await repo.Select(s => s.id == movieId2);


            Assert.Equal(movie.First().body, body2);

            //clean up
            await repo.RemoveAll(new List <Guid>() { movieId1, movieId2, movieId3, movieId4 });
        }
Ejemplo n.º 2
0
        public async Task ShouldReturnTwoMoviesGivenAnExpressionThatFitsTwoMovies()
        {
            var body1    = "body1";
            var body2    = "body2";
            var body3    = "body2";
            var body4    = "body4";
            var repo     = new MoviesMemoryRepository(TimeSpan.FromSeconds(10));
            var movieId1 = Guid.NewGuid();
            var movieId2 = Guid.NewGuid();
            var movieId3 = Guid.NewGuid();
            var movieId4 = Guid.NewGuid();

            await repo.Add(new Movie()
            {
                body = body1, id = movieId1
            });

            await repo.Add(new Movie()
            {
                body = body2, id = movieId2
            });

            await repo.Add(new Movie()
            {
                body = body3, id = movieId3
            });

            await repo.Add(new Movie()
            {
                body = body4, id = movieId4
            });

            var movie = await repo.Select(s => s.body == body3);


            Assert.True(movie.Count() == 2);

            //clean up
            await repo.RemoveAll(new List <Guid>() { movieId1, movieId2, movieId3, movieId4 });
        }