public async Task Store_action_should_get_all_cache_item_from_stores_that_matched_the_id()
{
Global.Cache.PhoenixFireCage.Add("item1", Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), new CacheItem()));
Global.Cache.PhoenixFireCage.Add("item2", Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), new CacheItem()));
Global.Cache.PhoenixFireCage.Add("item5", Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), new CacheItem()));
Global.Cache.PhoenixFireCage.Add("item6", Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), new CacheItem()));
var syncStore = Substitute.For<ICacheStore>();
syncStore.GetAll().Returns(new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("item0", null),
new KeyValuePair<string, object>("item1", new CacheItem {Data = "data", Key = "item1"}),
new KeyValuePair<string, object>("item2", new CacheItem {Data = new MediaTypeHeaderValue("text/json"), Key = "item2"}),
new KeyValuePair<string, object>("item3", new MediaTypeHeaderValue("application/xml")),
});
var asyncStore = Substitute.For<IAsyncCacheStore>();
asyncStore.GetAllAsync().Returns(Task.FromResult(new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("item4", new BadObject()),
new KeyValuePair<string, object>("item5", new WebApiCacheItem {Content = null, Key = "item5"}),
new KeyValuePair<string, object>("item6", new WebApiCacheItem {Content = new byte[0], Key = "item4"}),
new KeyValuePair<string, object>("item7", new MediaTypeHeaderValue("application/xml")),
}));
var provider = Substitute.For<ICacheStoreProvider>();
provider.GetCacheStore(1).Returns(syncStore);
provider.GetAsyncCacheStore(1).Returns(asyncStore);
var controller = new FlatwhiteStatusController(provider);
// Action
var result = await controller.Store(1);
var jsonResult = (JsonResult<List<FlatwhiteStatusController.CacheItemStatus>>) result;
// Assert
Assert.AreEqual(8, jsonResult.Content.Count);
}