public void TestGetNotRegistered() { var cache = new PropertyGetterCache(); Func<object, object> getter = cache.Get( typeof(PropertyGetterCacheTests), nameof(TestContext) ); Assert.AreSame(TestContext, getter(this)); }
public void TestGetRegisteredGeneric() { var cache = new PropertyGetterCache(); cache.Register<PropertyGetterCacheTests>( nameof(TestContext), (obj) => 5 ); Func<object, object> getter = cache.Get( typeof(PropertyGetterCacheTests), nameof(TestContext) ); Assert.AreEqual(5, getter(this)); }
public void TestRegisterAlreadyRegistered() { var cache = new PropertyGetterCache(); cache.Register( typeof(PropertyGetterCacheTests), nameof(TestContext), (obj) => 5 ); cache.Register( typeof(PropertyGetterCacheTests), nameof(TestContext), (obj) => 7 ); var getter = cache.Get( typeof(PropertyGetterCacheTests), nameof(TestContext) ); Assert.AreEqual(7, getter(this)); }