public void WithParameter_AccessorIsNull_ThrowsArgumentNullException() { var regBuilder = Substitute.For <IRegistrationBuilder <ExampleType, ReflectionActivatorData, object> >(); string parameterName = "value1"; Func <IComponentContext, object> accessor = null; const string message = "valueAccessor should not be null."; Assert.That(() => AutofacExtensions.WithParameter(regBuilder, parameterName, accessor), Throws.TypeOf <ArgumentNullException>() .And.Message.Contains(message)); }
public void WithParameter_ParameterNameIsEmpty_ThrowsArgumentException() { var regBuilder = Substitute.For <IRegistrationBuilder <ExampleType, ReflectionActivatorData, object> >(); string parameterName = String.Empty; Func <IComponentContext, object> accessor = c => new object(); const string message = "parameterName should not be an empty string."; Assert.That(() => AutofacExtensions.WithParameter(regBuilder, parameterName, accessor), Throws.TypeOf <ArgumentException>() .And.Message.Contains(message)); }