示例#1
0
        public void SelectFiles_ShouldRaise_OnErrorOccured_WhenAttachments_HaveMaxCount()
        {
            // Arrange
            const int maxItems = 2;

            _appConfig.ReportBugMaxFiles = maxItems;
            var logItems = new[]
            {
                new Attachment("TestData\\test.txt"),
                new Attachment("TestData\\test-2.txt")
            };
            var newItems = new[]
            {
                new Attachment("TestData\\test-3.txt"),
                new Attachment("TestData\\test-4.txt")
            };

            _logFileSource.GetEnumerator().Returns(logItems.Cast <Attachment>().GetEnumerator());
            _selectFileSource.GetEnumerator().Returns(newItems.Cast <Attachment>().GetEnumerator());

            var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource);

            subject.Load();
            AttachmentErrorEventArgs error = null;

            subject.OnErrorOccured += (sender, attachmentError) => error = attachmentError;
            // Act
            subject.SelectFiles();
            // Assert
            error.Should().NotBeNull();
        }
示例#2
0
        public void SelectFiles_ShouldRaise_OnErrorOccured_WithTooLargeItems()
        {
            // Arrange
            const long maxSize = 50;

            _appConfig.ReportBugMaxFileSize = maxSize;
            var items = new[]
            {
                new Attachment("TestData\\test.txt"),
                new Attachment("TestData\\test-2.txt"),
                new Attachment("TestData\\test-3.txt")
            };
            var tooLarge = new[]
            {
                new Attachment("TestData\\test-2.txt")
            };

            _selectFileSource.GetEnumerator().Returns(items.Cast <Attachment>().GetEnumerator());

            var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource);
            AttachmentErrorEventArgs error = null;

            subject.OnErrorOccured += (sender, attachmentError) => error = attachmentError;
            // Act
            subject.SelectFiles();
            // Assert
            error.Attachments.Should().BeEquivalentTo(tooLarge);
            error.Attachments.TooLarge().Should().BeEquivalentTo(tooLarge);
        }
示例#3
0
        public void SelectFiles_ShouldEnumerate_SelectFileSource()
        {
            // Arrange
            var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource);

            // Act
            subject.SelectFiles();
            // Assert
            _selectFileSource.Received(1).GetEnumerator();
        }
示例#4
0
        public void SelectFiles_ShouldLoad_UpToMaxItems()
        {
            // Arrange
            const int maxItems = 2;

            _appConfig.ReportBugMaxFiles = maxItems;
            var items = new[]
            {
                new Attachment("TestData\\test.txt"),
                new Attachment("TestData\\test-2.txt"),
                new Attachment("TestData\\test-3.txt"),
                new Attachment("TestData\\test-4.txt")
            };

            _selectFileSource.GetEnumerator().Returns(items.Cast <Attachment>().GetEnumerator());
            var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource);

            // Act
            subject.SelectFiles();
            // Assert
            subject.Items.Should().HaveCount(maxItems);
        }