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