public void IsVisible_NoPropertyName_ReturnTrue(string propertyName) { // Call bool isVisible = DynamicVisibleAttribute.IsVisible(new object(), propertyName); // Assert Assert.IsTrue(isVisible); }
public void DefaultConstructor_ExpectedValues() { // Call var attribute = new DynamicVisibleAttribute(); // Assert Assert.IsInstanceOf <Attribute>(attribute); }
public void IsVisible_GivenPropertyDoesNotHaveDynamicVisibleAttribute_ReturnTrue() { // Setup var o = new ClassWithPropertyWithoutDynamicVisibleAttribute(); // Call bool isVisible = DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert Assert.IsTrue(isVisible); }
public void IsVisible_ClassWithDynamicVisibleProperty_ReturnResultFromValidationMethod(bool isVisible) { // Setup var o = new ClassWithDynamicVisibleProperty(isVisible); // Call bool result = DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert Assert.AreEqual(isVisible, result); }
public void IsVisible_GivenPropertyNameDoesNotExistOnObject_ThrowMissingMemberException() { // Setup var o = new object(); // Call TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "NotExistingProperty"); // Assert string exceptionMessage = Assert.Throws <MissingMemberException>(call).Message; Assert.AreEqual($"Kon eigenschap NotExistingProperty van type {o.GetType()} niet vinden.", exceptionMessage); }
public void IsVisible_ClassHasMultipleDynamicVisibleValidationMethods_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicVisiblePropertyAndMultipleValidationMethods(); // Call TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }
public void IsVisible_ClassLacksDynamicVisibleValidationMethod_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicVisiblePropertyButNoValidationMethod(); // Call TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }
public void IsVisible_ClassHasDynamicVisibleValidationMethodWithIncorrectArgumentType_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodArgumentNotString(); // Call TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }
public void IsVisible_ClassHasDynamicVisibleValidationMethodWithIncorrectArgumentCount_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodNotOneArgument(); // Call TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }
public void IsVisible_ClassHasDynamicVisibleValidationMethodWithNonBoolReturnType_ThrowsMissingMethodException() { // Setup var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodReturnsIncorrectValueType(); // Call TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); // Assert string exceptionMessage = Assert.Throws <MissingMethodException>(call).Message; string expectedMessage = $"DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {o.GetType()}."; Assert.AreEqual(expectedMessage, exceptionMessage); }