public async Task SetCachedItemTest() { //Arrange var accessor = new BlogCacheAccessor(_cfg, _connectionMultiplexer); var item = new CacheTestModel { Number = 64, Text = $"{_testKeys["SetCachedItemTest"]}", StringCollection = new[] { "Last test first", "this should work" } }; //Act await accessor.CacheEnt(_testKeys["SetCachedItemTest"], item); Task.Delay(500).Wait(); var result = await accessor.GetEnt <CacheTestModel>(_testKeys["SetCachedItemTest"]); //Assert Assert.IsNotNull(result, "Should have cached the item, and retrieved it"); Assert.IsInstanceOfType(result, typeof(CacheTestModel)); Assert.AreEqual(item.Number, result.Number, "Should be equal"); Assert.AreEqual(item.Text, result.Text, "Should be equal"); Assert.AreEqual(item.StringCollection.Count(), result.StringCollection.Count(), "Should be equal"); }
public ActionResult CacheTest() { Response.AddHeader("Cache-Control", "public, max-age=900, s-maxage=900"); CacheTestModel cacheTestModel = new CacheTestModel(); ViewBag.Message = "Cache Testing Page."; return(View(cacheTestModel)); }
public bool Equals(CacheTestModel obj) { return(this != null && obj != null && this.MyIntProperty == obj.MyIntProperty && this.MyStringProperty == obj.MyStringProperty && ((this.MyObjectProperty == null && obj.MyObjectProperty == null) || (this.MyObjectProperty.Equals(obj.MyObjectProperty)))); }