public void AssertIsAssignable() { Assert.Throws( Is.TypeOf <ArgumentNullException>() .And.Message.EqualTo(new ArgumentNullException("valType").Message) , delegate { ArgUtils.AssertIsAssignable <IConvertible>("arg", null); } ); #if !PORTABLE Assert.Throws( Is.TypeOf <ArgumentOutOfRangeException>() .And.Message.EqualTo(new ArgumentOutOfRangeException("this", this.GetType(), string.Format("Type '{0}' of parameter '{1}' is not assignable to target type '{2}'" , this.GetType().AssemblyQualifiedName , "this" , typeof(ISerializable).AssemblyQualifiedName)).Message) , delegate { ArgUtils.AssertIsAssignable <ISerializable>("this", this.GetType()); } ); #endif Type type = typeof(Int32); Assert.AreSame(type, ArgUtils.AssertIsAssignable <IConvertible>("arg", type)); }
/// <summary> /// /// </summary> /// <param name="factoryAdapterType"> /// The <see cref="ILoggerFactoryAdapter" /> type /// that will be used for creating <see cref="ILog" /> /// </param> /// <param name="properties"> /// Additional user supplied properties that are passed to the /// <paramref key="factoryAdapterType" />'s constructor. /// </param> public LogSetting(Type factoryAdapterType, NameValueCollection properties) { ArgUtils.AssertNotNull("factoryAdapterType", factoryAdapterType); ArgUtils.AssertIsAssignable <ILoggerFactoryAdapter>("factoryAdapterType", factoryAdapterType , "Type {0} does not implement {1}", factoryAdapterType.AssemblyQualifiedName, typeof(ILoggerFactoryAdapter).FullName); _factoryAdapterType = factoryAdapterType; _properties = properties; }