public void Remove_ShouldRemoveItem() { // Arrange var items = new[] { new Attachment("TestData\\test.txt"), new Attachment("TestData\\test-2.txt"), new Attachment("TestData\\test-3.txt") }; var expected = new[] { new Attachment("TestData\\test.txt"), new Attachment("TestData\\test-3.txt") }; _logFileSource.GetEnumerator().Returns(items.Cast <Attachment>().GetEnumerator()); var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource); subject.Load(); subject.Items.Should().BeEquivalentTo(items); // Act subject.Remove(new Attachment("TestData\\test-2.txt")); // Assert subject.Items.Should().BeEquivalentTo(expected); }
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 Load_ShouldNotEnumerate_SelectFileSource() { // Arrange var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource); // Act subject.Load(); // Assert _selectFileSource.DidNotReceive().GetEnumerator(); }
public void Items_ShouldByEmpty_Initially() { // Arrange var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource); // Act var result = subject.Items; // Assert result.Should().BeEmpty(); }
public FormViewModel( Common.Configuration.Config appConfig, IUserStorage userStorage, Attachments.Attachments attachments, IOsProcesses processes) { _appConfig = appConfig; _userStorage = userStorage; _attachments = attachments; _processes = processes; AddAttachmentCommand = new RelayCommand(AddAttachment); RemoveAttachmentCommand = new RelayCommand <Attachment>(RemoveAttachment); OpenAttachmentCommand = new RelayCommand <Attachment>(OpenAttachment); }
public void Load_ShouldClearItems_BeforeLoading() { // Arrange var items = new[] { new Attachment("TestData\\test.txt"), new Attachment("TestData\\test-2.txt"), new Attachment("TestData\\test-3.txt") }; _logFileSource.GetEnumerator().Returns(items.Cast <Attachment>().GetEnumerator()); var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource); subject.Load(); subject.Items.Should().NotBeEmpty(); _logFileSource.GetEnumerator().Returns(Enumerable.Empty <Attachment>().GetEnumerator()); // Act subject.Load(); // Assert subject.Items.Should().BeEmpty(); }
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); }
public BugReport(IApiClient apiClient, Attachments.Attachments attachments, NetworkLogWriter networkLogWriter) { _networkLogWriter = networkLogWriter; _apiClient = apiClient; _attachments = attachments; }
public BugReport(IApiClient apiClient, Attachments.Attachments attachments) { _apiClient = apiClient; _attachments = new AttachmentsToApiFiles(attachments.Items); }