-
Notifications
You must be signed in to change notification settings - Fork 178
Closed
Description
In my app I use cookies to display simple success/error messages. I do it like that:
protected void ViewError(Exception e)
{
HttpContext.Response.Cookies.Append("ErrorMessageKey", e.GetExceptionMessage());
}
and then I delete them in client-side javascript after showing it to the User.
Is there a way to check if a cookie with a specified key was set in action? Or if cookie exists?
I was thinkink about something like this:
//calling Register() action will set ErrorMessage in cookies
MyMvc.Controller<AccountController>()
.WithDbContext(builder => builder.WithSet<User>(set => set.Add(new User() {Username = "foo", Password = "foo", Email = "foo"})))
.Calling(x => x.Register(registerViewModel))
.ShouldReturn()
.View()
.WithModel(registerViewModel)
.AndAlso()
.ShouldPassForThe<HttpContext>(x=>x.Response.Cookies.Exists("ErrorMessageKey"));
Anyway, amazing library, makes you want to do TDD, thanks for sharing! 👍