Exemple #1
0
        public void Get_With_Wrong_Type_Throws_Exception()
        {
            var key        = "token";
            var fillerText = "Hello World!";
            var val        = new StringBuilder();

            val.Append(fillerText);

            _cache.Add(key, val);
            ValidateObjectReturned <StringBuilder>(key, false, fillerText);

            var ex = Assert.Throws <ArgumentException>(() =>
            {
                _cache.Get <CacheContainerTests>(key);
            });

            Assert.IsNotNull(ex?.Message);
            Assert.IsTrue(ex.Message.IndexOf("CacheContainerTests", StringComparison.CurrentCulture) >= 0);
            Assert.IsTrue(ex.Message.IndexOf("StringBuilder", StringComparison.CurrentCulture) >= 0);
        }
 public ValuesController()
 {
     _valuesRepository = CacheContainer.Get <ValuesRepository>();
 }