public void DisplayCookiesSuccessWhenSomeCookiesFound() { var resultDictionary = new Dictionary <string, string>() { { "key", "val" } }; _cookiesHandlerServiceMock.GetCurrentCookies().Returns(resultDictionary); var result = _controller.DisplayCookies() as ViewResult; var data = result.ViewData.Model as Dictionary <string, string>; _cookiesHandlerServiceMock.Received().GetCurrentCookies(); Assert.AreEqual(resultDictionary.Count, data.Count); }
public IActionResult DisplayCookies() { try { var cookies = _cookiesHandler.GetCurrentCookies(); if (cookies.Count < 1) { return(View()); } return(View(cookies)); } catch (Exception ex) { @ViewData["Error"] = ex.Message; return(View()); } }