diff --git a/Frontend.Tests/PagesTests/TaskList/HtbDocument/DownloadTests.cs b/Frontend.Tests/PagesTests/TaskList/HtbDocument/DownloadTests.cs index da3a46654..8ad573c4d 100644 --- a/Frontend.Tests/PagesTests/TaskList/HtbDocument/DownloadTests.cs +++ b/Frontend.Tests/PagesTests/TaskList/HtbDocument/DownloadTests.cs @@ -21,7 +21,13 @@ protected DownloadTests() }; _createHtbDocument.Setup(s => s.Execute(ProjectUrn0001)).ReturnsAsync(new CreateProjectTemplateResponse - {Document = new byte[] {0, 1}}); + { + Document = new byte[] { 0, 1 } + }); + + FoundInformationForProject.Project.TransferringAcademies[0].IncomingTrustName = "Incoming Trust"; + FoundInformationForProject.Project.OutgoingTrustName = "Outgoing Trust"; + FoundInformationForProject.Project.Reference = "SW-MAT-10000001"; } public class GetTests : DownloadTests @@ -29,11 +35,18 @@ public class GetTests : DownloadTests [Fact] public async void GivenId_GetsProjectInformation() { - FoundInformationForProject.Project.TransferringAcademies[0].IncomingTrustName = "Incoming Trust"; await _subject.OnGetAsync(); GetInformationForProject.Verify(s => s.Execute(ProjectUrn0001), Times.Once); } + + [Fact] + public async void GivenId_SetsFileName() + { + await _subject.OnGetAsync(); + + Assert.Equal("SW-MAT-10000001_Outgoing-Trust_Incoming-Trust_project-template", _subject.FileName); + } } public class GetDownloadTests : DownloadTests @@ -41,25 +54,26 @@ public class GetDownloadTests : DownloadTests [Fact] public async void GivenId_GeneratesAnHtbDocumentForTheProject() { - FoundInformationForProject.Project.TransferringAcademies[0].IncomingTrustName = "Incoming Trust"; await _subject.OnGetGenerateDocumentAsync(); + _createHtbDocument.Verify(s => s.Execute(ProjectUrn0001), Times.Once); } [Fact] public async void GivenId_ReturnsAFileWithTheGeneratedDocument() { - var fileContents = new byte[] {1, 2, 3, 4}; + var fileContents = new byte[] { 1, 2, 3, 4 }; var createDocumentResponse = new CreateProjectTemplateResponse { Document = fileContents }; _createHtbDocument.Setup(s => s.Execute(ProjectUrn0001)).ReturnsAsync(createDocumentResponse); - FoundInformationForProject.Project.TransferringAcademies[0].IncomingTrustName = "Incoming Trust"; + var response = await _subject.OnGetGenerateDocumentAsync(); - var fileResponse = Assert.IsType(response); + var fileResponse = Assert.IsType(response); Assert.Equal(fileContents, fileResponse.FileContents); + Assert.Equal("SW-MAT-10000001_Outgoing-Trust_Incoming-Trust_project-template.docx", fileResponse.FileDownloadName); } } } diff --git a/Frontend/Pages/TaskList/HtbDocument/Download.cshtml b/Frontend/Pages/TaskList/HtbDocument/Download.cshtml index a53cd9973..ece47e36c 100644 --- a/Frontend/Pages/TaskList/HtbDocument/Download.cshtml +++ b/Frontend/Pages/TaskList/HtbDocument/Download.cshtml @@ -31,7 +31,7 @@

- @Model.IncomingTrustName, @Model.ProjectReference project template + @Model.FileName