예제 #1
0
        public void CanGetExistingAttributeForTheFirstTime()
        {
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA));

            Assert.IsNotNull(attribute);
            Assert.AreEqual(1, attribute.value);
        }
예제 #2
0
        public void CanGetNonExistingAttributeForTheSecondTime()
        {
            cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithoutMockAttribute));
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithoutMockAttribute));

            Assert.IsNull(attribute);
        }
예제 #3
0
        public void CanGetInheritedAttributeForTheFirstTimeWithInheritance()
        {
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithInheritedMockAttribute), true);

            Assert.IsNotNull(attribute);
            Assert.AreEqual(1, attribute.value);
        }
예제 #4
0
        public void CanGetExistingAttributeForTheSecondTimeWithInheritance()
        {
            cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA), true);
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA), true);

            Assert.IsNotNull(attribute);
            Assert.AreEqual(1, attribute.value);
        }
예제 #5
0
        public void CanCacheSameAttributeForDifferentTypes()
        {
            MockAttribute attributeA = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA));

            Assert.IsTrue(cache.HasCachedCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA)));
            Assert.IsFalse(cache.HasCachedCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeB)));
            MockAttribute attributeB = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeB));

            Assert.IsTrue(cache.HasCachedCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA)));
            Assert.IsTrue(cache.HasCachedCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeB)));
            Assert.AreEqual(1, attributeA.value);
            Assert.AreEqual(2, attributeB.value);
        }
예제 #6
0
        public void GetsNullForInheritedAttributeForTheFirstTime()
        {
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithInheritedMockAttribute));

            Assert.IsNull(attribute);
        }
예제 #7
0
        public void GetsNullForNonExistingAttributeForTheFirstTime()
        {
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithoutMockAttribute));

            Assert.IsNull(attribute);
        }