public void SutIsGuardClauseCommand() { // Fixture setup var dummyMethod = new DelegatingMethod(); var dummyExpansion = new DelegatingExpansion <object>(); var dummyParameter = MethodInvokeCommandTest.CreateAnonymousParameterInfo(); // Exercise system var sut = new MethodInvokeCommand(dummyMethod, dummyExpansion, dummyParameter); // Verify outcome Assert.IsAssignableFrom <IGuardClauseCommand>(sut); // Teardown }
public void ParameterInfoIsCorrect() { // Fixture setup var dummyMethod = new DelegatingMethod(); var dummyExpansion = new DelegatingExpansion <object>(); var parameter = MethodInvokeCommandTest.CreateAnonymousParameterInfo(); var sut = new MethodInvokeCommand(dummyMethod, dummyExpansion, parameter); // Exercise system ParameterInfo result = sut.ParameterInfo; // Verify outcome Assert.Equal(parameter, result); // Teardown }
public void CreateExceptionReturnsExceptionWithCorrectMessage() { // Fixture setup var dummyMethod = new DelegatingMethod(); var dummyExpansion = new DelegatingExpansion <object>(); var parameter = MethodInvokeCommandTest.CreateAnonymousParameterInfo(); var sut = new MethodInvokeCommand(dummyMethod, dummyExpansion, parameter); // Exercise system var message = Guid.NewGuid().ToString(); var result = sut.CreateException(message); // Verify outcome var e = Assert.IsAssignableFrom <GuardClauseException>(result); Assert.Contains(message, e.Message); // Teardown }
public void ExecuteCorrectlyInvokesMethod() { // Fixture setup var value = new object(); var arguments = new[] { new object(), new object(), new object() }; var expansion = new DelegatingExpansion <object> { OnExpand = v => v == value ? arguments : new object[0] }; var dummyParameter = MethodInvokeCommandTest.CreateAnonymousParameterInfo(); var mockVerified = false; var method = new DelegatingMethod { OnInvoke = a => mockVerified = a == arguments }; var sut = new MethodInvokeCommand(method, expansion, dummyParameter); // Exercise system sut.Execute(value); // Verify outcome Assert.True(mockVerified); // Teardown }