Esempio n. 1
0
        public void CanGetExistingAttributeForTheFirstTime()
        {
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithMockAttributeA));

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

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

            Assert.IsNotNull(attribute);
            Assert.AreEqual(1, attribute.value);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 6
0
        public void GetsNullForInheritedAttributeForTheFirstTime()
        {
            MockAttribute attribute = cache.GetCustomAttribute <MockAttribute>(typeof(TypeWithInheritedMockAttribute));

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

            Assert.IsNull(attribute);
        }