public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable() { //Create a new TypeTable var table = new TypeTable(false); //Create some selectors that we're going to add var stringSelector1 = new StringSelector(); var stringSelector2 = new FullNameSelector(); var stringSelector3 = new EmailSelector(); Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet"); //Add the first selector (our default string selector) table.AddSelector <string>(stringSelector1); Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'"); var firstselector = table.GetSelectors <string>().First(); Assert.IsInstanceOf <StringSelector>(firstselector); //Add the second selector (the full name selector) table.AddSelector <string>(stringSelector2); Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'"); firstselector = table.GetSelectors <string>().First(); Assert.IsInstanceOf <FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector! //Add the thrid selector (the email address selector) table.AddSelector <string>(stringSelector3); Assert.AreEqual(3, table.CountSelectors <string>(), "should have THREE type selectors for type 'string'"); firstselector = table.GetSelectors <string>().First(); Assert.IsInstanceOf <EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector! }
public void Should_Add_Selector_To_Back_Of_List() { //Create a new TypeTable var table = new TypeTable(false); //Create some selectors that we're going to add var stringSelector1 = new StringSelector(); var stringSelector2 = new FullNameSelector(); Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet"); //Add the first selector (our default string selector) table.AddSelector <string>(stringSelector1); Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'"); var firstselector = table.GetSelectors <string>().First(); Assert.IsInstanceOf <StringSelector>(firstselector); //Add the second selector (FullNameSelector) to the back of the processing queue table.AddSelector(stringSelector2, SelectorPosition.Last); Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'"); firstselector = table.GetSelectors <string>().First(); Assert.IsInstanceOf <StringSelector>(firstselector); var lastselector = table.GetSelectors <string>().Last(); Assert.IsInstanceOf <FullNameSelector>(lastselector); }
public void Should_Add_Selector_To_Back_Of_List() { //Create a new TypeTable var table = new TypeTable(false); //Create some selectors that we're going to add var stringSelector1 = new StringSelector(); var stringSelector2 = new FullNameSelector(); Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet"); //Add the first selector (our default string selector) table.AddSelector<string>(stringSelector1); Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'"); var firstselector = table.GetSelectors<string>().First(); Assert.IsInstanceOf<StringSelector>(firstselector); //Add the second selector (FullNameSelector) to the back of the processing queue table.AddSelector(stringSelector2, SelectorPosition.Last); Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'"); firstselector = table.GetSelectors<string>().First(); Assert.IsInstanceOf<StringSelector>(firstselector); var lastselector = table.GetSelectors<string>().Last(); Assert.IsInstanceOf<FullNameSelector>(lastselector); }
public void Full_Name_Variations_All_Match() { var nameSelector = new FullNameSelector(); var fullNameClass = new FullNameTestClass(); //Iterate over all of the properties in the fullNameClass object... foreach (var property in fullNameClass.GetType().GetProperties()) { var nameSelectorResult = nameSelector.CanBind(property); Assert.IsTrue(nameSelectorResult, string.Format("{0} should have been a valid match", property.Name)); } }
public void Full_Name_Variations_All_Injected() { var nameSelector = new FullNameSelector(); var fullNameClass = new FullNameTestClass(); //Iterate over all of the properties in the fullNameClass object... foreach (var property in fullNameClass.GetType().GetProperties()) { //Inject the value into the property nameSelector.Generate(fullNameClass, property); } //Iterate over all of the properties again foreach (var property in fullNameClass.GetType().GetProperties()) { var fieldValue = property.GetValue(fullNameClass, null) as string; Assert.IsNotNullOrEmpty(fieldValue); Assert.IsAssignableFrom <string>(fieldValue, "Should be type of string..."); Assert.That(fieldValue.Length > 0); } }
public void Should_Clear_TypeSelector_List() { //Create a new TypeTable var table = new TypeTable(false); //Create some selectors that we're going to add var stringSelector1 = new StringSelector(); var stringSelector2 = new FullNameSelector(); Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet"); //Add some type selectors to our typetable table.AddSelector(stringSelector1); table.AddSelector(stringSelector2); //Check to see that our table contains at least two items... Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'"); //Clear all of the string selectors table.ClearSelectors <string>(); //Count the new number of string selectors (should equal zero) Assert.AreEqual(0, table.CountSelectors <string>()); }
public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable() { //Create a new TypeTable var table = new TypeTable(false); //Create some selectors that we're going to add var stringSelector1 = new StringSelector(); var stringSelector2 = new FullNameSelector(); var stringSelector3 = new EmailSelector(); Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet"); //Add the first selector (our default string selector) table.AddSelector<string>(stringSelector1); Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'"); var firstselector = table.GetSelectors<string>().First(); Assert.IsInstanceOf<StringSelector>(firstselector); //Add the second selector (the full name selector) table.AddSelector<string>(stringSelector2); Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'"); firstselector = table.GetSelectors<string>().First(); Assert.IsInstanceOf<FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector! //Add the thrid selector (the email address selector) table.AddSelector<string>(stringSelector3); Assert.AreEqual(3, table.CountSelectors<string>(), "should have THREE type selectors for type 'string'"); firstselector = table.GetSelectors<string>().First(); Assert.IsInstanceOf<EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector! }
public void Should_Clear_TypeSelector_List() { //Create a new TypeTable var table = new TypeTable(false); //Create some selectors that we're going to add var stringSelector1 = new StringSelector(); var stringSelector2 = new FullNameSelector(); Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet"); //Add some type selectors to our typetable table.AddSelector(stringSelector1); table.AddSelector(stringSelector2); //Check to see that our table contains at least two items... Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'"); //Clear all of the string selectors table.ClearSelectors<string>(); //Count the new number of string selectors (should equal zero) Assert.AreEqual(0, table.CountSelectors<string>()); }
public void Full_Name_Variations_All_Injected() { var nameSelector = new FullNameSelector(); var fullNameClass = new FullNameTestClass(); //Iterate over all of the properties in the fullNameClass object... foreach (var property in fullNameClass.GetType().GetProperties()) { //Inject the value into the property nameSelector.Generate(fullNameClass, property); } //Iterate over all of the properties again foreach(var property in fullNameClass.GetType().GetProperties()) { var fieldValue = property.GetValue(fullNameClass, null) as string; Assert.IsNotNullOrEmpty(fieldValue); Assert.IsAssignableFrom<string>(fieldValue, "Should be type of string..."); Assert.That(fieldValue.Length > 0); } }
public void Full_Name_Variations_All_Match() { var nameSelector = new FullNameSelector(); var fullNameClass = new FullNameTestClass(); //Iterate over all of the properties in the fullNameClass object... foreach(var property in fullNameClass.GetType().GetProperties()) { var nameSelectorResult = nameSelector.CanBind(property); Assert.IsTrue(nameSelectorResult, string.Format("{0} should have been a valid match", property.Name)); } }