PeanutButter
Loading...
Searching...
No Matches
PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies Class Reference

Provides a fake response cookies service. More...

Inheritance diagram for PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies:
PeanutButter.TestUtils.AspNetCore.Fakes.IFake

Public Member Functions

 FakeResponseCookies ()
 Creates an instance of FakeResponseCookies with its own internal HttpResponse that it's attached to.
 FakeResponseCookies (HttpResponse attachedTo)
 Constructs an instance of FakeResponseCookies attached to the provided HttpResponse.
bool ContainsKey (string key)
 Query if the store contains the key.
virtual void Append (string key, string value)
virtual void Append (string key, string value, CookieOptions options)
virtual void Delete (string key)
virtual void Delete (string key, CookieOptions options)

Static Public Member Functions

static IResponseCookies CreateSubstitutedIfPossible (HttpResponse attachedTo)
 Attempts to create a substitute for FakeResponseCookies using NSubstitute's Substitute.ForPartsOf<T> which means you should both be able to inspect the cookie store and assert that methods were called on the store within your code. However, there is a caveat: NSubstitute assertions seem to fail unless you've previously used NSubstitute in testing. This is most likely due to how NSubstitute is sought out via reflection and possibly manual assembly loading - so it may be an issue which is resolved in the future. For now, if you wish to verify calls, ensure that there is some other kind of NSubstitute invocation before performing assertions against this substitute. On the other hand, if you don't have NSubstitute available, you'll get a plain-old FakeResponseCookies object here.

Properties

IDictionary< string, FakeCookieSnapshot [get]
 Snapshot the current state of the cookies.
HttpResponse HttpResponse [get, set]
 The HttpResponse these cookies are attached to. You may override the response, but if you provide null, it will be replaced with a new HttpResponse.
FakeCookie this[string key] [get, set]
 Provides easier indexing into the store.
string[] Keys [get]
 Return all store keys.
FakeCookie[] Values [get]
 Return all store values.

Detailed Description

Provides a fake response cookies service.

Constructor & Destructor Documentation

◆ FakeResponseCookies()

PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies.FakeResponseCookies ( HttpResponse attachedTo)

Constructs an instance of FakeResponseCookies attached to the provided HttpResponse.

Parameters
attachedTo

Member Function Documentation

◆ ContainsKey()

bool PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies.ContainsKey ( string key)

Query if the store contains the key.

Parameters
key
Returns

◆ CreateSubstitutedIfPossible()

IResponseCookies PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies.CreateSubstitutedIfPossible ( HttpResponse attachedTo)
static

Attempts to create a substitute for FakeResponseCookies using NSubstitute's Substitute.ForPartsOf<T> which means you should both be able to inspect the cookie store and assert that methods were called on the store within your code. However, there is a caveat: NSubstitute assertions seem to fail unless you've previously used NSubstitute in testing. This is most likely due to how NSubstitute is sought out via reflection and possibly manual assembly loading - so it may be an issue which is resolved in the future. For now, if you wish to verify calls, ensure that there is some other kind of NSubstitute invocation before performing assertions against this substitute. On the other hand, if you don't have NSubstitute available, you'll get a plain-old FakeResponseCookies object here.

Returns

Property Documentation

◆ Snapshot

IDictionary<string, FakeCookie> PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies.Snapshot
get

Snapshot the current state of the cookies.

Returns

◆ this[string key]

FakeCookie PeanutButter.TestUtils.AspNetCore.Fakes.FakeResponseCookies.this[string key]
getset

Provides easier indexing into the store.

Parameters
key

The documentation for this class was generated from the following file:
  • source/TestUtils/PeanutButter.TestUtils.AspNetCore/Fakes/FakeResponseCookies.cs