コード例 #1
0
        public void ExportAllJournalsWithNullStreamThrowsArgumentNullException()
        {
            // Arrange
            var    journalsExport = new JournalsExport(Mock.Of <IJournalRepository>());
            Stream nullStream     = null;

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => journalsExport.ExportAllJournals(nullStream));
        }
コード例 #2
0
        public FileContentResult Download(string type)
        {
            using (var memoryStream = new MemoryStream())
            {
                if (type == "all")
                {
                    journalsExport.ExportAllJournals(memoryStream);
                }
                else
                {
                    journalsExport.ExportOpenAccessJournals(memoryStream);
                }

                return(this.File(memoryStream.ToArray(), "application/csv", "journals.csv"));
            }
        }
コード例 #3
0
        public void ExportAllJournalsExportAllJournalsInCorrectCsvFormat()
        {
            // Arrange
            var mockJournalRepository = new Mock <IJournalRepository>();

            mockJournalRepository.Setup(j => j.AllIncluding(It.IsAny <Expression <Func <Journal, object> >[]>())).Returns(CreateJournals());

            var journalsExport = new JournalsExport(mockJournalRepository.Object);
            var memoryStream   = new MemoryStream();

            // Act
            journalsExport.ExportAllJournals(memoryStream);

            // Assert
            var csvContent = Encoding.Default.GetString(memoryStream.ToArray());

            Assert.Equal(ExpectedJournalsCsv, csvContent);
        }