public void GuardNullShouldThrowArgumentNullExceptionWhenFirstParameterIsNullAndHasOptionalParameter() { // Arrange var gni = new GuardNullInterceptor(); var context = new InterceptionContext { Parameters = new List<Parameter> { new Parameter() { Name = "Dummy", Value = null}, new Parameter() { Name = "Dummy2", Value = null, IsOptional = true } } }; // Act & Assert gni.Invoking(x => gni.OnBeforeExecute(context)).ShouldThrow<ArgumentNullException>(); }
public void GuardNullShouldThrowArgumentNullExceptionWhenArgumentTypeIsStringAndIsEmpty() { // Arrange var gni = new GuardNullInterceptor(); var context = new InterceptionContext { Parameters = new List<Parameter> {new Parameter() {Name = "Dummy", Value = ""}} }; // Act & Assert gni.Invoking(x => gni.OnBeforeExecute(context)).ShouldThrow<ArgumentNullException>(); }
public void GuardNullShouldNotThrowArgumentNullExceptionWhenParameterIsOptional() { // Arrange var gni = new GuardNullInterceptor(); var context = new InterceptionContext { Parameters = new List <Parameter> { new Parameter() { Name = "Dummy", Value = null, IsOptional = true } } }; // Act & Assert gni.Invoking(x => gni.OnBeforeExecute(context)).ShouldNotThrow <ArgumentNullException>(); }
public void GuardNullShouldThrowArgumentNullExceptionWhenArgumentTypeIsStringAndIsEmpty() { // Arrange var gni = new GuardNullInterceptor(); var context = new InterceptionContext { Parameters = new List <Parameter> { new Parameter() { Name = "Dummy", Value = "" } } }; // Act & Assert gni.Invoking(x => gni.OnBeforeExecute(context)).ShouldThrow <ArgumentNullException>(); }