Beispiel #1
0
        public async void TestDownload()
        {
            // Arrange
            var controller = new FakeManifestController();

            // Act
            var result = controller.Download(FakeManifest);

            // Assert
            var fileResult = Assert.IsType <FileContentResult>(result);

            Assert.Equal($"{FakeManifest.Name}.zip", fileResult.FileDownloadName);
            Assert.Equal("application/zip", fileResult.ContentType);
            var zipFile     = fileResult.FileContents;
            var zipContents = await ZipUtils.GetInsideAZipContentsAsync(zipFile);

            Assert.Single(zipContents);

            var keysEnumerator = zipContents.Keys.GetEnumerator();

            keysEnumerator.MoveNext();
            var firstKey = keysEnumerator.Current;

            Assert.Equal(FakeManifest.Name, firstKey);
            Assert.Equal(FakeManifest.ToString(), zipContents[firstKey]);
        }
        public IActionResult Download(FakeManifest manifest)
        {
            var manifestContent = manifest.ToString();

            var zippedFileBytes = ZipUtils.GetZippedFileFromString(manifestContent, manifest.Name);

            return(File(zippedFileBytes,
                        "application/zip",
                        $"{manifest.Name}.zip"));
        }
Beispiel #3
0
        public void TestGenerateHappy()
        {
            // Arrange
            var controller = new FakeManifestController();

            // Act
            var result = controller.Generate(FakeManifest);

            // Assert
            var viewResult = Assert.IsType <String>(result);

            Assert.Equal(FakeManifest.ToString(), result);
        }
Beispiel #4
0
        public void TestGenerateAndDownload()
        {
            // Arrange
            var controller = new FakeManifestController();

            // Act
            var result = controller.GenerateAndDownload(FakeManifest);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Equal(FakeManifest.ToString(), viewResult.Model.ToString());
            Assert.Null(viewResult.ViewName);
        }
 public string Generate(FakeManifest manifest)
 {
     return(manifest.ToString());
 }