public void Enumerable_ShouldBeEmpty_WhenSource_IsEmpty()
        {
            // Arrange
            _source.GetEnumerator().Returns(Enumerable.Empty <Attachment>().GetEnumerator());
            var converter = new AttachmentsToApiFiles(_source);
            // Act
            var result = converter.ToList();

            // Assert
            result.Should().BeEmpty();
        }
        public void Enumerable_ShouldThrow_WhenDirectory_NotExists()
        {
            // Arrange
            var attachments = new[] { new Attachment("Lost folder\\test.txt") };

            _source.GetEnumerator().Returns(attachments.Cast <Attachment>().GetEnumerator());
            var converter = new AttachmentsToApiFiles(_source);
            // Act
            Action action = () => converter.ToList();

            // Assert
            action.Should().Throw <DirectoryNotFoundException>();
        }
        public void Enumerable_ItemContent_ShouldBe_BinaryFileContent()
        {
            // Arrange
            var attachments = new[] { new Attachment("TestData\\test-3.txt") };

            _source.GetEnumerator().Returns(attachments.Cast <Attachment>().GetEnumerator());
            var expected  = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes("test-3")).ToArray();
            var converter = new AttachmentsToApiFiles(_source);
            // Act
            var result = converter.ToList();

            // Assert
            result.First().Content.Should().Equal(expected);
        }
        public void Enumerable_ItemName_ShouldBe_SourceName()
        {
            // Arrange
            var fileNames   = new[] { "test.txt", "test-2.txt", "test-3.txt" };
            var attachments = fileNames.Select(f => new Attachment($"TestData\\{f}"));

            _source.GetEnumerator().Returns(attachments.GetEnumerator());
            var converter = new AttachmentsToApiFiles(_source);
            // Act
            var result = converter.ToList();

            // Assert
            result.Select(i => i.Name).Should().BeEquivalentTo(fileNames);
        }