public void Create_Get()
        {
            var returnUrl  = "/";
            var expectedVm = new EditViewModel
            {
                EditorMode = EditorMode.Create,
                ReturnUrl  = returnUrl
            };

            var context = MakeContext();

            var controller = new BranchesController(context.BranchesDao)
            {
                TempData          = context.TempDataDictionary,
                ControllerContext = context.ControllerContext
            };

            var r = controller.Create(returnUrl) as ViewResult;

            Assert.NotNull(r);
            Assert.Equal(nameof(controller.Edit), r.ViewName);
            var vm = r.Model as EditViewModel;

            Assert.NotNull(vm);
            Assert.Equal(expectedVm.EditorMode, vm.EditorMode);
            Assert.Equal(expectedVm.ReturnUrl, vm.ReturnUrl);
        }
예제 #2
0
        public void BranchCreateTestSuccess()
        {
            var result = controller.Create(new Branch()
            {
                //ID = new Guid("12345678-1234-1234-1234-123456789012") ,
                Name       = "name",
                Street     = "street",
                City       = "city",
                Province   = "province",
                Country    = "country",
                PostalCode = "postal",
                Phone      = "123-456-7890",
                Fax        = "987-654-3210",
                Email      = "*****@*****.**",
                Website    = "web"
            }) as ActionResult;

            Console.WriteLine(result);

            Assert.That(result is RedirectToRouteResult);
        }