public void ContentEditor_CreateContent_Method_With_No_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange object[] parametersOutRanged = { null, null }; var contentEditor = new ContentEditor(); var methodName = "CreateContent"; // Act var createContentMethodInfo1 = contentEditor.GetType().GetMethod(methodName); var createContentMethodInfo2 = contentEditor.GetType().GetMethod(methodName); var returnType1 = createContentMethodInfo1.ReturnType; var returnType2 = createContentMethodInfo2.ReturnType; // Assert parametersOutRanged.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); contentEditor.ShouldNotBeNull(); createContentMethodInfo1.ShouldNotBeNull(); createContentMethodInfo2.ShouldNotBeNull(); createContentMethodInfo1.ShouldBe(createContentMethodInfo2); Should.Throw <Exception>(actual: () => createContentMethodInfo1.Invoke(contentEditor, parametersOutRanged)); Should.Throw <Exception>(actual: () => createContentMethodInfo2.Invoke(contentEditor, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => createContentMethodInfo1.Invoke(contentEditor, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => createContentMethodInfo2.Invoke(contentEditor, parametersOutRanged)); }
public void ContentEditor_CreateSurveyBlast_Method_With_2_Parameters_Call_With_Reflection_No_Exception_Thrown_Test() { // Arrange var sender = Fixture.Create <object>(); var e = Fixture.Create <EventArgs>(); object[] parametersOfCreateSurveyBlast = { sender, e }; var contentEditor = new ContentEditor(); var methodName = "CreateSurveyBlast"; // Act var createSurveyBlastMethodInfo1 = contentEditor.GetType().GetMethod(methodName); var createSurveyBlastMethodInfo2 = contentEditor.GetType().GetMethod(methodName); var returnType1 = createSurveyBlastMethodInfo1.ReturnType; var returnType2 = createSurveyBlastMethodInfo2.ReturnType; // Assert parametersOfCreateSurveyBlast.ShouldNotBeNull(); contentEditor.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); createSurveyBlastMethodInfo1.ShouldNotBeNull(); createSurveyBlastMethodInfo2.ShouldNotBeNull(); createSurveyBlastMethodInfo1.ShouldBe(createSurveyBlastMethodInfo2); Should.Throw <Exception>(actual: () => createSurveyBlastMethodInfo1.Invoke(contentEditor, parametersOfCreateSurveyBlast)); Should.Throw <Exception>(actual: () => createSurveyBlastMethodInfo2.Invoke(contentEditor, parametersOfCreateSurveyBlast)); }
public void ContentEditor_GetTextFromHTML_Method_With_2_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange var sender = Fixture.Create <object>(); var e = Fixture.Create <EventArgs>(); object[] parametersOutRanged = { sender, e, null }; object[] parametersInDifferentNumber = { sender }; var contentEditor = new ContentEditor(); var methodName = "GetTextFromHTML"; // Act var getTextFromHtmlMethodInfo1 = contentEditor.GetType().GetMethod(methodName); var getTextFromHtmlMethodInfo2 = contentEditor.GetType().GetMethod(methodName); var returnType1 = getTextFromHtmlMethodInfo1.ReturnType; var returnType2 = getTextFromHtmlMethodInfo2.ReturnType; // Assert parametersOutRanged.ShouldNotBeNull(); parametersInDifferentNumber.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); contentEditor.ShouldNotBeNull(); getTextFromHtmlMethodInfo1.ShouldNotBeNull(); getTextFromHtmlMethodInfo2.ShouldNotBeNull(); getTextFromHtmlMethodInfo1.ShouldBe(getTextFromHtmlMethodInfo2); Should.Throw <Exception>(actual: () => getTextFromHtmlMethodInfo1.Invoke(contentEditor, parametersOutRanged)); Should.Throw <Exception>(actual: () => getTextFromHtmlMethodInfo2.Invoke(contentEditor, parametersOutRanged)); Should.Throw <Exception>(actual: () => getTextFromHtmlMethodInfo1.Invoke(contentEditor, parametersInDifferentNumber)); Should.Throw <Exception>(actual: () => getTextFromHtmlMethodInfo2.Invoke(contentEditor, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(actual: () => getTextFromHtmlMethodInfo1.Invoke(contentEditor, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => getTextFromHtmlMethodInfo2.Invoke(contentEditor, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => getTextFromHtmlMethodInfo1.Invoke(contentEditor, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(actual: () => getTextFromHtmlMethodInfo2.Invoke(contentEditor, parametersInDifferentNumber)); }