Esempio n. 1
0
        public void Enumerable_ShouldMark_TooLarge_SourceItems()
        {
            // Arrange
            const long maxSize = 1000;
            var        source  = new[]
            {
                new Attachment("A").WithLength(0),
                new Attachment("B").WithLength(maxSize - 1),
                new Attachment("C").WithLength(maxSize),
                new Attachment("D").WithLength(maxSize + 1),
                new Attachment("E").WithLength(long.MaxValue),
                new Attachment("F").WithLength(-1),
            };
            var expected = new[]
            {
                new Attachment("D"),
                new Attachment("E")
            };
            var filter = new TooLargeAttachmentFilter(maxSize, source);
            // Act
            var result = filter.ToList();

            // Assert
            result.TooLarge().Should().BeEquivalentTo(expected);
        }
Esempio n. 2
0
        public void Enumerable_ShouldBe_Empty_WhenSource_IsEmpty()
        {
            // Arrange
            var source = Enumerable.Empty <Attachment>();
            var filter = new TooLargeAttachmentFilter(234, source);
            // Act
            var result = filter.ToList();

            // Assert
            result.Should().BeEmpty();
        }
Esempio n. 3
0
        public void Enumerable_ShouldKeep_SourceItems_WithError()
        {
            // Arrange
            const long maxSize = 3753;
            var        source  = new[]
            {
                new Attachment("B").WithLength(maxSize).WithError(AttachmentErrorType.FileReadError),
                new Attachment("C").WithLength(maxSize + 1).WithError(AttachmentErrorType.TooManyFiles),
            };
            var filter = new TooLargeAttachmentFilter(maxSize, source);
            // Act
            var result = filter.ToList();

            // Assert
            result
            .WithError()
            .Where(i => i.ErrorType != AttachmentErrorType.FileTooLarge)
            .Should().BeEquivalentTo(source);
        }