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 Email_Address_Variations_All_Match() { var emailSelector = new EmailSelector(); var emailTestClass = new EmailTestClass(); //Iterate over all of the properties in the EmailTestClass object... foreach (var property in emailTestClass.GetType().GetProperties()) { var emailSelectorResult = emailSelector.CanBind(property); Assert.IsTrue(emailSelectorResult, string.Format("{0} should have been a valid match", property.Name)); } }
public void Email_Address_Variations_All_Injected() { var emailSelector = new EmailSelector(); var emailTestClass = new EmailTestClass(); //Iterate over all of the properties in the fullNameClass object... foreach (var property in emailTestClass.GetType().GetProperties()) { //Inject the value into the property emailSelector.Generate(emailTestClass, property); } //Iterate over all of the properties again foreach (var property in emailTestClass.GetType().GetProperties()) { var fieldValue = property.GetValue(emailTestClass, null) as string; Assert.IsNotNullOrEmpty(fieldValue); Assert.IsAssignableFrom<string>(fieldValue, "Should be type of string..."); Assert.That(fieldValue.Length > 0); } }
public void Email_Address_Variations_All_Injected() { var emailSelector = new EmailSelector(); var emailTestClass = new EmailTestClass(); //Iterate over all of the properties in the fullNameClass object... foreach (var property in emailTestClass.GetType().GetProperties()) { //Inject the value into the property emailSelector.Generate(emailTestClass, property); } //Iterate over all of the properties again foreach (var property in emailTestClass.GetType().GetProperties()) { var fieldValue = property.GetValue(emailTestClass, null) as string; Assert.IsNotNullOrEmpty(fieldValue); Assert.IsAssignableFrom <string>(fieldValue, "Should be type of string..."); Assert.That(fieldValue.Length > 0); } }
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! }