public void ExtractKeyShouldReturnValueFromDecoratedTypes( Type serviceType, string key )
        {
            var assembler = new ServiceTypeAssembler();
            var type = assembler.ApplyKey( serviceType, key );
            var actual = assembler.ExtractKey( type );

            Assert.Equal( key, actual );
        }
        public void ApplyKeyShouldNotReplaceExplicitAttributeDeclaration()
        {
            var assembler = new ServiceTypeAssembler();
            var expected = "Gregorian";
            var type = assembler.ApplyKey( typeof( MockCalendarService ), "Fiscal" );
            var actual = type.GetCustomAttribute<ServiceKeyAttribute>( false );

            Assert.NotNull( actual );
            Assert.Equal( expected, actual.Key );
        }
        public void ApplyKeyShouldReturnProjectedType( Type serviceType, string key )
        {
            var assembler = new ServiceTypeAssembler();
            var type = assembler.ApplyKey( serviceType, key );

            // unwrap nested generics
            while ( type.IsGenericType )
                type = type.GenericTypeArguments[0];

            var actual = type.GetCustomAttribute<ServiceKeyAttribute>( false );

            Assert.NotNull( actual );
            Assert.Equal( key, actual.Key );
        }