public void ImportUploadTest() { SetupFile("../../../SampleRequest1.xlsx"); var response = _controller.Upload(_file.Object); Assert.IsInstanceOfType(response, typeof(IActionResult)); Assert.IsInstanceOfType(response, typeof(ViewResult)); Assert.IsInstanceOfType(((ViewResult)response).Model, typeof(TokenStringViewModel)); var modelResponse = ((ViewResult)response).Model as TokenStringViewModel; Debug.WriteLine($"Patients {modelResponse.Patients.Count} MedicationOrders {modelResponse.MedicationOrders.Count}"); Assert.IsTrue(modelResponse.Patients.Count == 2); }
public void UploadTest() { var controller = new ImportController <Client, ImportAppStatusRow>(); var tempPath = System.IO.Path.GetTempPath(); controller.UploadsDir = tempPath; var postedFile = new Moq.Mock <HttpPostedFileBase>(); var len = 1000; var content = new byte[len]; var rnd = new Random(); rnd.NextBytes(content); System.IO.MemoryStream ms = new System.IO.MemoryStream(content); postedFile.Setup(f => f.InputStream).Returns(ms); postedFile.Setup(f => f.SaveAs(Moq.It.IsAny <string>())).Verifiable(); var result = controller.Upload(postedFile.Object); var redirect = result as RedirectToRouteResult; Assert.IsTrue(redirect != null); var id = (Guid)redirect.RouteValues["id"]; var action = (string)redirect.RouteValues["action"]; Assert.IsTrue(!string.IsNullOrEmpty(action)); Assert.IsTrue(action.ToLower() == "Preview".ToLower()); postedFile.Verify(f => f.SaveAs(Moq.It.IsAny <string>())); }