Chapter 2 Projection - Test not passed but status ok

Hi all,
my version of the “GetMoviesByCountryAsync” methid is below:

public async Task<IReadOnlyList<MovieByCountryProjection>> GetMoviesByCountryAsync(
            CancellationToken cancellationToken = default,
            params string[] countries
            var projectionFilter = Builders<Movie>.Projection
                            .Include(m => m.Title);

            return await _moviesCollection
                .Find(Builders<Movie>.Filter.In("Countries", countries))

The test result is fail:
String lengths are both 24. Strings differ at index 6.
Expected: “573a13f3f29313caabddf331”
But was: “573a1392f29313caabcd9d4f”
but the validation code is right.

What am I doing wrong?

Hi @Andrea_Agostini, welcome to the community.
Please add the following method before ToListAsync method and after Project method:

.SortByDescending(m => m.Title)

I hope it helps.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

Thanks a lot; it works!

1 Like