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(); }
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); }
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(); }
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); }