コード例 #1
0
        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);
        }
コード例 #2
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();
        }
コード例 #3
0
        public void Load_ShouldNotEnumerate_SelectFileSource()
        {
            // Arrange
            var subject = new ProtonVPN.BugReporting.Attachments.Attachments(_logger, _appConfig, _logFileSource, _selectFileSource);

            // Act
            subject.Load();
            // Assert
            _selectFileSource.DidNotReceive().GetEnumerator();
        }
コード例 #4
0
        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();
        }