UploadFile() public method

public UploadFile ( ) : ActionResult
return ActionResult
Example #1
0
        public void  Upload_document_should_upload_document_and_return_dto()
        {
            //https://stackoverflow.com/questions/40860305/unit-testing-fileupload-with-moq-net-core
            //https://stackoverflow.com/questions/8308899/unit-test-a-file-upload-how

            var controller = new HomeController();

            var goalId = Guid.NewGuid();

            controller.ControllerContext = RequestWithFile();
            var result = controller.UploadFile();

            Assert.Equal(1, 1);
        }
Example #2
0
        public void TestMethod1()
        {
            var context      = new Mock <HttpContextBase>();
            var postedfile   = new Mock <HttpPostedFileBase>();
            var absPath      = Path.GetFullPath("../../input_user_story_dummy.txt");
            var streamReader = new StreamReader(absPath);

            postedfile.Setup(x => x.InputStream).Returns(streamReader.BaseStream);
            HomeController controller = new HomeController();

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            ViewResult result  = controller.UploadFile(postedfile.Object);
            var        Message = result.ViewBag.Message;

            Assert.AreEqual("600143155", Message);
        }