示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
 public void Throws_When_Property_Has_Wrong_Attribute_Type()
 {
     Assert.Throws <InvalidOperationException>(() => {
         IndexDefinitionValidator.Validate <Article, DefinitionWithWrongAttributePropertyType>();
     });
 }
示例#7
0
 public void Throws_When_Generic_Property_Is_No_IndexedValue()
 {
     Assert.Throws <InvalidOperationException>(() => {
         IndexDefinitionValidator.Validate <Article, DefinitionWithWrongGenericProperty>();
     });
 }
示例#8
0
 public void Throws_When_Null_Returning_Property_Has_Broken_Setter()
 {
     Assert.Throws <InvalidOperationException>(() => {
         IndexDefinitionValidator.Validate <Article, DefinitionWithBrokenSetter>();
     });
 }
示例#9
0
 public void Throws_When_Property_Does_Not_Exists_On_Target()
 {
     Assert.Throws <InvalidOperationException>(() => {
         IndexDefinitionValidator.Validate <Article, DefinitionWithNonExistingProperty>();
     });
 }