Example #1
0
        public async Task GetMostRecentPosts_ShouldGetPosts(int amountOfPosts)
        {
            var ids = new List <int>();

            for (int i = 0; i < amountOfPosts + 1; i++)
            {
                ids.Add(i + 1);
            }

            _testRepository.SeedPosts(amountOfPosts, out List <Post> seededPosts);

            var results = await _postsRepository.GetMostRecentPosts(amountOfPosts);

            Assert.Equal(amountOfPosts, results.Count());

            results.Should().BeEquivalentTo(seededPosts, config =>
            {
                config.Excluding(property => property.Id);
                config.Using <DateTime>(context => context.Subject.Should().BeCloseTo(context.Expectation)).WhenTypeIs <DateTime>();
                return(config);
            });
        }