public void CreateIsReadOnlyMethod_ClassHasMultipleDynamicReadOnlyValidationMethods_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicReadOnlyPropertyAndMultipleValidationMethods(); // Call TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }
public void CreateIsReadOnlyMethod_ClassHasDynamicReadOnlyValidationMethodWithNonBoolReturnType_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodReturnsIncorrectValueType(); // Call TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }
public void CreateIsReadOnlyMethod_ClassLacksDynamicReadOnlyValidationMethod_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicReadOnlyPropertyButNoValidationMethod(); // Call TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }