Inheritance: ApiController
        public void AccountPostGet()
        {
            AccountController controller = new AccountController(new MockDatabase());
            controller.Create(new Account
            {
                FacebookId = 123,
                FullName = "Hey Guys",
                PreferredName = "Hey",
                Height = 100,
                Weight = 120,
                Birthdate = DateTime.Now,
                Zip = 80303,
                Sex = false
            });

            var account = controller.Get(1) as OkNegotiatedContentResult<Account>;
            var faccount = controller.Facebook(123) as OkNegotiatedContentResult<Account>;

            Assert.IsNotNull(account);
            Assert.IsNotNull(faccount);

            Assert.AreEqual(account.Content.FullName, "Hey Guys");

            Assert.AreEqual(account.Content.Height, 100);
            Assert.AreEqual(account.Content.Weight, 120);
        }
Exemplo n.º 2
0
        public ActionResult Create(UserViewModel user)
        {
            if (ModelState.IsValid)
            {
                AutoMapper.Mapper.CreateMap<UserViewModel, DAL.Models.User>();
                var userModel = AutoMapper.Mapper.Map<User>(user);
                int id =userContracts.Add(userModel);
                if (id <= 0)
                {
                    TempData["fail"] = "Failed to create the user";
                    return RedirectToAction("Create");
                }
                else
                {
                    TempData["success"] = "User Created";
                    AccountController account = new AccountController();
                    return RedirectToAction("Create");

                }

            }
            TempData["fail"] = "Failed to create the user";
            return View();
        }
 private static AccountController GetAccountController()
 {
     AccountController controller = new AccountController()
     {
         FormsService = new MockFormsAuthenticationService(),
         MembershipService = new MockMembershipService()
     };
     controller.ControllerContext = new ControllerContext()
     {
         Controller = controller,
         RequestContext = new RequestContext(new MockHttpContext(), new RouteData())
     };
     return controller;
 }