-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix content-type for ilivalidator plain text log
- Loading branch information
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using System; | ||
using System.IO; | ||
|
||
namespace ILICheck.Web.Controllers | ||
{ | ||
[TestClass] | ||
public sealed class DownloadControllerTest | ||
{ | ||
private readonly Guid jobId = Guid.Parse("28e1adff-765e-4c0b-b667-90458b33e1ca"); | ||
|
||
private Mock<ILogger<DownloadController>> loggerMock; | ||
private Mock<IFileProvider> fileProviderMock; | ||
private DownloadController controller; | ||
|
||
public TestContext TestContext { get; set; } | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
loggerMock = new Mock<ILogger<DownloadController>>(); | ||
fileProviderMock = new Mock<IFileProvider>(MockBehavior.Strict); | ||
|
||
controller = new DownloadController(loggerMock.Object, fileProviderMock.Object); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
loggerMock.VerifyAll(); | ||
fileProviderMock.VerifyAll(); | ||
|
||
controller.Dispose(); | ||
} | ||
|
||
[TestMethod] | ||
public void Download() | ||
{ | ||
fileProviderMock.Setup(x => x.Initialize(jobId)); | ||
fileProviderMock.Setup(x => x.GetFiles()).Returns(new[] { "OCEANSTEED_log.xtf", "DARKFOOT_log.log", "HAPPYPOINT_log.geojson" }); | ||
fileProviderMock.Setup(x => x.OpenText(It.IsAny<string>())).Returns(StreamReader.Null); | ||
|
||
void AssertContentType(LogType logType, string contentType) | ||
{ | ||
var result = controller.Download(jobId, logType) as FileStreamResult; | ||
Assert.AreEqual(result.ContentType, contentType); | ||
} | ||
|
||
AssertContentType(LogType.Log, "text/plain"); | ||
AssertContentType(LogType.Xtf, "text/xml; charset=utf-8"); | ||
AssertContentType(LogType.GeoJson, "application/geo+json"); | ||
} | ||
} | ||
} |