Class MockBucketStore
- Namespace
- Kuestenlogik.Bowire.Mock.State
- Assembly
- Kuestenlogik.Bowire.Mock.dll
The data buckets of a running mock (#1096): JSON the mock holds and requests change. Seeded from the configuration when the mock starts; the state lives in memory, so a restart starts from the configuration again.
public sealed class MockBucketStore
- Inheritance
-
MockBucketStore
- Inherited Members
Remarks
Each bucket has its own lock, held for the whole of one operation, so concurrent requests see every change whole and never half of one.
Constructors
MockBucketStore(IEnumerable<MockDataBucket>)
A store with the configuration's buckets at their seed.
public MockBucketStore(IEnumerable<MockDataBucket> buckets)
Parameters
bucketsIEnumerable<MockDataBucket>
Methods
Contains(string)
Whether a bucket of that name exists.
public bool Contains(string name)
Parameters
namestring
Returns
Describe()
Every bucket with its id property, its shape and how many records it holds now, in configuration order.
public IReadOnlyList<MockBucketInfo> Describe()
Returns
IdPropertyOf(string)
The bucket's id property; null for an unknown bucket.
public string? IdPropertyOf(string name)
Parameters
namestring
Returns
Read(string)
A copy of the bucket's content as it is now; null for an unknown bucket.
public JsonNode? Read(string name)
Parameters
namestring
Returns
Reset(string)
Put one bucket back to its seed. False for an unknown bucket.
public bool Reset(string name)
Parameters
namestring
Returns
ResetAll()
Put every bucket back to its seed.
public void ResetAll()
Write(string, JsonNode)
Replace the bucket's content, so a test starts from a state it names. False for an unknown bucket; ArgumentException when the content is not of the bucket's shape (records for a collection, one object for an object bucket), because its routes answer by that shape.
public bool Write(string name, JsonNode content)