public void Throws_With_Correct_Message_When_Property_Is_No_IndexedValue() { var message = string.Empty; try{ IndexDefinitionValidator.Validate <Article, DefinitionWithWrongProperty>(); }catch (Exception e) { message = e.Message; } Assert.AreEqual("DefinitionWithWrongProperty: Unexpected property Description of type String. Properties of an IndexDefinition should be of type IndexedValue<,>.", message); }
public void Throws_With_Correct_Message_When_Null_Returning_Property_Has_Broken_Setter() { var message = string.Empty; try{ IndexDefinitionValidator.Validate <Article, DefinitionWithBrokenSetter>(); }catch (Exception e) { message = e.Message; } Assert.AreEqual("DefinitionWithBrokenSetter: Description has a broken set method. It looks like a default IndexedValue (because it returns null by default), however, get is not returning what was set." , message); }
public void Throws_With_Correct_Message_When_Null_Returning_Property_Has_No_Setter() { var message = string.Empty; try{ IndexDefinitionValidator.Validate <Article, DefinitionWithNoSetter>(); }catch (Exception e) { message = e.Message; } Assert.AreEqual("DefinitionWithNoSetter: Description does not have a setter. It looks like a default IndexedValue (because it returns null by default). Either add a setter or return base.IndexedValue()" , message); }
public void Throws_With_Correct_Message_When_Property_Does_Not_Exists_On_Target() { var message = string.Empty; try{ IndexDefinitionValidator.Validate <Article, DefinitionWithNonExistingProperty>(); }catch (Exception e) { message = e.Message; } Assert.AreEqual("DefinitionWithNonExistingProperty: NoSuchProperty cannot be indexed because NoSuchProperty does not exist on Article." , message); }
public void Throws_With_Correct_Message_When_Property_Has_Wrong_Attribute_Type() { var message = string.Empty; try{ IndexDefinitionValidator.Validate <Article, DefinitionWithWrongAttributePropertyType>(); }catch (Exception e) { message = e.Message; } Assert.AreEqual("DefinitionWithWrongAttributePropertyType: Property Description cannot be indexed as a String because it is of type Int32." + "\nDid you mean:" + "\npublic IndexedValue<Article, Int32> Description {get; set;}" , message); }
public void Throws_When_Property_Has_Wrong_Attribute_Type() { Assert.Throws <InvalidOperationException>(() => { IndexDefinitionValidator.Validate <Article, DefinitionWithWrongAttributePropertyType>(); }); }
public void Throws_When_Generic_Property_Is_No_IndexedValue() { Assert.Throws <InvalidOperationException>(() => { IndexDefinitionValidator.Validate <Article, DefinitionWithWrongGenericProperty>(); }); }
public void Throws_When_Null_Returning_Property_Has_Broken_Setter() { Assert.Throws <InvalidOperationException>(() => { IndexDefinitionValidator.Validate <Article, DefinitionWithBrokenSetter>(); }); }
public void Throws_When_Property_Does_Not_Exists_On_Target() { Assert.Throws <InvalidOperationException>(() => { IndexDefinitionValidator.Validate <Article, DefinitionWithNonExistingProperty>(); }); }