Beispiel #1
0
        public void CreateGetTest()
        {
            var controller = new ProductTypesController();
            var context    = new Mock <HttpContextBase>();
            var session    = new Mock <HttpSessionStateBase>();

            context.Setup(c => c.Session).Returns(session.Object);
            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            session.Setup(s => s["UserName"]).Returns("abc");

            var result = controller.Create() as ViewResult;

            Assert.IsNotNull(result);
        }
Beispiel #2
0
        public void CreatePostTest()
        {
            var controller = new ProductTypesController();
            var db         = new DmQT03Entities();
            var context    = new Mock <HttpContextBase>();
            var request    = new Mock <HttpRequestBase>();
            var files      = new Mock <HttpFileCollectionBase>();
            var file       = new Mock <HttpPostedFileBase>();

            using (var scope = new TransactionScope())
            {
                var model = new ProductType();
                model.ProductTypeName = "ProductTypeName";
                model.ProductTypeCode = "TES";
                var result0 = controller.Create(model) as RedirectToRouteResult;
                Assert.IsNotNull(result0);
            }
        }