Exemple #1
0
        public async Task ShouldRemovePost()
        {
            // Arrange
            IPostRepository repository = new BlobPostRepository();
            await repository.AddPost(_data);

            // Act
            await repository.RemovePost(_data.Title);

            // Assert
            var data = await repository.GetPost(_data.Title);

            Check.That(data.Title).IsNullOrWhiteSpace();
            Check.That(data.Content).IsNullOrWhiteSpace();
        }
Exemple #2
0
        public async Task ShouldGetPost()
        {
            // Arrange
            IPostRepository repository = new BlobPostRepository();
            await repository.AddPost(_data);

            // Act
            var data = await repository.GetPost(_data.Title);

            // Assert
            Check.That(data).IsEqualTo(_data);

            // Clean
            await repository.RemovePost(_data.Title);
        }
Exemple #3
0
        public async Task ShouldGetAllPosts()
        {
            // Arrange
            IPostRepository repository           = new BlobPostRepository();
            const int       howManyArticlesToAdd = 2;

            for (var i = 0; i < howManyArticlesToAdd; i++)
            {
                var post = new BlogPostData($"{_data.Title}-{i}", _data.Content);
                await repository.AddPost(post);
            }

            // Act
            var posts = await repository.GetPosts();

            // Assert
            Check.That(posts.Count).IsEqualTo(howManyArticlesToAdd);
            Check.That(posts).ContainsOnlyElementsThatMatch(post =>
                                                            !string.IsNullOrWhiteSpace(post.Title) &&
                                                            !string.IsNullOrWhiteSpace(post.Content));
        }