public void ExecuteResult_should_write_correct_content_to_response(ApiResponseFormat responseFormat, string content) { var alias = new Alias { Name = "MSDN", ShortUrl = new ShortUrl { Title = "MSDN", Url = "http://msdn.microsoft.com/" } }; var shortUrlDto = new ShortUrlDTO(alias, 3, "http://shrinkr.com/msdn", "http://shrinkr.com/Preview/msdn"); var viewModel = new CreateUrlViewModel(shortUrlDto); controllerContext.Controller.ViewData = new ViewDataDictionary(viewModel); var result = new ApiResult(responseFormat); result.ExecuteResult(controllerContext); httpContext.Verify(c => c.Response.Write(content)); }
public async Task <IActionResult> CreateUrl(CreateUrlViewModel model) { var user = await userManager.FindByNameAsync(User.Identity.Name); if (ModelState.IsValid) { LHUrl lHUrl = new LHUrl() { UrlTitle = model.UrlTitle, LHUrlName = model.LHUrlName, Description = model.Description, CategoryId = model.CategoryId, IsApproved = false, Id = user.Id }; LHUrlBs.Create(lHUrl); return(RedirectToAction("CreateUrl")); } ViewBag.Categories = CategoryBs.GetAll(); return(View()); }