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 Attachments_ShouldBeEmpty_WhenNewObject() { // Arrange var attachments = Enumerable.Empty <Attachment>(); var error = new AttachmentErrorEventArgs(attachments); // Act var result = error.Attachments; // Assert result.Should().NotBeNull().And.BeEmpty(); }
public void Attachments_ShouldBe_Attachments() { // Arrange var attachments = new[] { new Attachment("C:\\folder\\file 1.txt").WithError(AttachmentErrorType.TooManyFiles), new Attachment("C:\\folder\\file 2.txt").WithError(AttachmentErrorType.FileTooLarge), new Attachment("C:\\folder\\file 3.txt").WithError(AttachmentErrorType.FileReadError) }; var error = new AttachmentErrorEventArgs(attachments); // Act var result = error.Attachments; // Assert result.Should().ContainInOrder(attachments); }