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 );
        }
 public void IsForManyShouldReturnExpectedResult( Type serviceType, bool expected )
 {
     var assembler = new ServiceTypeAssembler();
     var actual = assembler.IsForMany( serviceType );
     Assert.Equal( expected, actual );
 }
 public void ForManyShouldReturnExpectedType( Type serviceType, Type expected )
 {
     var assembler = new ServiceTypeAssembler();
     var actual = assembler.ForMany( serviceType );
     Assert.Equal( expected, actual );
 }
 public void ExtractKeyShouldReturnNullForUndecoratedType( Type serviceType )
 {
     var assembler = new ServiceTypeAssembler();
     var actual = assembler.ExtractKey( serviceType );
     Assert.Null( actual );
 }