public async Task Phoenix_action_should_display_all_phoenix_in_cache()
{
Global.Cache.PhoenixFireCage.Add("item1", Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), new CacheItem { Data = "data", Key = "item1" }));
Global.Cache.PhoenixFireCage.Add("item2", Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), new CacheItem { Data = new MediaTypeHeaderValue("text/json"), Key = "item2" }));
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.Get(Arg.Any<string>()).Returns(c => new CacheItem
{
Key = c.Arg<string>(),
Data = "data"
});
var asyncStore = Substitute.For<IAsyncCacheStore>();
asyncStore.GetAsync(Arg.Any<string>()).Returns(c =>
{
object obj = new WebApiCacheItem
{
Key = c.Arg<string>(),
Content = new byte[0]
};
return Task.FromResult(obj);
});
var provider = Substitute.For<ICacheStoreProvider>();
provider.GetCacheStore(Arg.Any<int>()).Returns(syncStore);
provider.GetAsyncCacheStore(Arg.Any<int>()).Returns(asyncStore);
var controller = new FlatwhiteStatusController(provider);
// Action
var result = await controller.Phoenix();
var jsonResult = (JsonResult<List<FlatwhiteStatusController.CacheItemStatus>>)result;
// Assert
Assert.AreEqual(4, jsonResult.Content.Count);
}