public void ShouldDisplayReleaseDetails() { //given string teamName = "ENZO"; string releaseNumber = "REL1216"; string releaseFIInstructions = "FI as Normal"; string prePatEmail = "we all love pre pat meetings"; string serviceNowTicketLink = "www.google.co.uk"; var expectedReleaseDetailsModel = new ReleaseDetailsModel { ReleaseNumber = releaseNumber, ReleaseFiInstructions = releaseFIInstructions, TeamName = teamName, PrePatEmail = prePatEmail, ServiceNowTicketLink = serviceNowTicketLink }; var releaseRepository = new Mock<IReleaseRepository>(); releaseRepository.Setup(x => x.GetReleaseDetails(releaseNumber)).Returns(expectedReleaseDetailsModel); var releaseDetailsController = new ReleaseDetailsController(releaseRepository.Object); //when ViewResult result = releaseDetailsController.Index(releaseNumber); var model = (ReleaseDetailsModel) result.ViewData.Model; //then Assert.That(result.ViewName, Is.EqualTo("ReleaseDetails")); Assert.That(model, Is.EqualTo(expectedReleaseDetailsModel)); Assert.That(model.ReleaseFiInstructions, Is.EqualTo(releaseFIInstructions)); Assert.That(model.ReleaseNumber, Is.EqualTo(releaseNumber)); Assert.That(model.TeamName, Is.EqualTo(teamName)); Assert.That(model.PrePatEmail, Is.EqualTo(prePatEmail)); Assert.That(model.ServiceNowTicketLink, Is.EqualTo(serviceNowTicketLink)); }
public void ShouldDownloadPrePatEmailFile() { //given var releaseRepository = new Mock<IReleaseRepository>(); var release = new ReleaseDetailsController(releaseRepository.Object); string expectedFileName = "Enzo Pre-PAT release 19122011 ref REL11125.0.00"; MemoryStream expectedStream = new MemoryStream(Encoding.ASCII.GetBytes("test")); releaseRepository.Setup(x => x.GetPrePatEmailFile(expectedFileName)).Returns(expectedStream); //when FileStreamResult fileResult = (FileStreamResult) release.DownloadPrePatEmailFile(expectedFileName); Assert.That(fileResult.FileStream, Is.EqualTo(expectedStream)); Assert.That(fileResult.ContentType, Is.EqualTo("application/vnd.ms-outlook")); Assert.That(fileResult.FileDownloadName, Is.EqualTo(expectedFileName)); }
public void ShouldDisplayReleaseDetails() { //given string releaseNumber = "REL1216"; var expectedReleaseDetailsModel = new Release { ReleaseNumber = releaseNumber, ReleaseFiInstructions = "FI as Normal", TeamName = "ENZO", PrePatEmailFileInfo = new PrePatEmailFileInfo(){Length=123, Name="prepatemailfile"}, ServiceNowTicketLink = "www.google.co.uk" }; var releaseRepository = new Mock<IReleaseRepository>(); releaseRepository.Setup(x => x.GetReleaseDetails(releaseNumber)).Returns(expectedReleaseDetailsModel); var releaseDetailsController = new ReleaseDetailsController(releaseRepository.Object); //when ViewResult result = releaseDetailsController.Index(releaseNumber); var model = (Release) result.ViewData.Model; //then Assert.That(result.ViewName, Is.EqualTo("ReleaseDetails")); Assert.That(model, Is.EqualTo(expectedReleaseDetailsModel)); }