Пример #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);
        }