static void Main(string[] args) { var context = new DataContext(); var families = context.Families; var zip = "12345"; var zipWrong = "123456"; var zipWrong2 = "sd125"; var zipRight = "123456789"; Console.WriteLine(zip.IsValidZip()); Console.WriteLine(zipWrong.IsValidZip()); Console.WriteLine(zipWrong2.IsValidZip()); Console.WriteLine(zipRight.IsValidZip()); var myName = "Vasya"; Console.WriteLine(myName.SayHello()); var tester = new MyTester(families); //List<Family> familes = tester.GetFamilyWithNoKids(); //List<Family> familes = tester.GetFamilyWithMostKids(); //List<Family> familes = tester.GetFamilyByName("Ella"); //List<Family> familes = tester.GetFamilyWithYoungestChild(); //List<Family> familes = tester.GetFamilyWithOldestChild(); //List<Family> familes = tester.GetFamilyWithNameStartsWith("O"); List <Family> familes = tester.GetFamilyWithParentNameStartsWith("A"); // tester.GetFamilyWithFathersAge(); foreach (var item in familes) { PrintFamily(item); } //tester.Run(); //foreach (var item in families) //{ // Console.WriteLine(item); //} Console.ReadLine(); }
public static void AttributeDemo3() { Type tp = typeof(MyTester); MemberInfo memberInfo = tp.GetMethod("CannotRun"); var myAtt = (TestAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(TestAttribute)); myAtt.RunTest(); MyTester tester = new MyTester { Age = 10 }; Type type = tester.GetType(); PropertyInfo propertyInfo = type.GetProperty("Age"); ValidateAgeAttribute validateAgeAttribute = (ValidateAgeAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(ValidateAgeAttribute)); Console.WriteLine(validateAgeAttribute.MaxAge); validateAgeAttribute.IsRight(tester.Age); }
public void InitTest() { var context = new DataContext(); _stats = new MyTester(context.Families); }
static void Main(string[] args) { var myName = "Sveta"; Console.WriteLine(myName.SayHello()); var zip = "12345";// number that have it . it is the zip have the 5 digil. Console.WriteLine(zip.CheckZip()); //foreach (var family in families) //{ // Console.WriteLine(family); // Console.WriteLine("-------------"); //} var context = new DataContext(); var myTest = new MyTester(context.Families); //myTest.Run(); List <Family> f = myTest.GetFamilyWithNoKids(); Console.WriteLine("-----GetFamilyWithNoKids-------------"); PrintFamilies(f); f = myTest.GetFamilyWithMostKids(); Console.WriteLine("----GetFamilyWithMostKids-----"); PrintFamilies(f); f = myTest.GetFamilyByNameTest("jim"); Console.WriteLine("-----GetFamilyByNameTests---"); PrintFamilies(f); //Console.WriteLine("--------All Father's Names and Ages-----------"); //foreach (var family in context.Families) //{ // Console.WriteLine($"{family.Father.Name} - {family.Father.Age}"); //} //f = myTest.FamilyAgeTest(); Console.WriteLine("--------Average Age of Each Family -----------"); foreach (var family in context.Families) { Console.WriteLine(family.FamilyId + " " + family.AveregeAge); } Console.WriteLine("---- GetYoungestAgeFamily-----"); var youngestFamily = myTest.GetYoungestAgeFamily(); Console.WriteLine(youngestFamily.AveregeAge); Console.WriteLine(youngestFamily.Age); f = myTest.GetFamilyParentNameStartsWith("B"); Console.WriteLine("---- GetFamilyStartWithLetter-----"); PrintFamilies(f); Console.WriteLine("----GetYoungestChild-----"); var young = myTest.GetYoungestChild(); Console.WriteLine(young.YoungestAge); Console.WriteLine("--------Get Family With Oldest Child-----------"); f = myTest.GetOlderChild(); PrintFamilies(f); Console.ReadLine(); }
[TestInitialize] // it will be runed first of all public void Init() // in this method we will initialize our data and pass it to variable on a slass scope level stats { var context = new DataContext(); // it will run before any method runs stats = new MyTester(context.Families); }
static void Main(string[] args) { var context = new DataContext(); #region // this code can be done in two ways, just in one line instead of two //var families = context.Families; // var myTest = new MyTester(families); #endregion var myTest = new MyTester(context.Families); // ------------- Calling Extension Methodts ------------------- var myName = "Nelya"; // it's an extention Console.WriteLine(myName.SayHello()); // say hello extention method // Task: Create IsValidZipCode Extension Method string zip1 = "19115"; string zipCode = zip1.IsValidZipCode1(); Console.WriteLine(zip1.IsValidZipCode1()); var zip = "12345"; Console.WriteLine(zip.IsValidZipCode()); // ----------- My Tester Methods Caling ----------- Console.WriteLine("-----------Get Family With Most Kids-----------"); List <Family> f = myTest.GetFamilyWithMostKids(); PrintFamilies(f); Console.WriteLine("-----------Get Family With No Kids------------"); f = myTest.GetFamilyWithNoKids(); PrintFamilies(f); Console.WriteLine("-----------Get Family By Name ------------"); f = myTest.GetFamilyByName("Jim"); PrintFamilies(f); Console.WriteLine("--------All Father's Names and Ages-----------"); foreach (var family in context.Families) { Console.WriteLine($"{family.Father.Name} - {family.Father.Age}"); } Console.WriteLine("--------Average Age of Each Family -----------"); foreach (var family in context.Families) { Console.WriteLine(family.FamilyId + " " + family.AverageAge); } Console.WriteLine("--------Get Youngest Family -----------"); f = myTest.GetYoungestFamilyAge(); PrintFamilies(f); // var youngestFamily = myTest.GetYoungestFamily(); // Console.WriteLine(youngestFamily.Nickname); // Console.WriteLine(youngestFamily.FamilyId); //Console.WriteLine(youngestFamily.AverageAge); Console.WriteLine("--------Get Family With Youngest Child -----------"); f = myTest.GetFamilyWithYoungestChild(); PrintFamilies(f); Console.WriteLine("--------Get Family With Oldest Child-----------"); //var oldestChild = myTest.GetFamilyWithOldestChild(); //Console.WriteLine("Family " + oldestChild.Nickname+ " " + oldestChild.FamilyId); //Console.WriteLine(" Age " + oldestChild.OldestChildAge); f = myTest.GetFamilyWithOldestChild(); PrintFamilies(f); Console.WriteLine("------Get Family With Parent Name Starts With (N)------"); f = myTest.GetFamilyParentNameStartsWith("N"); PrintFamilies(f); #region //var myTest = new MyTester(); //myTest.Run(); //foreach (var family in collection) //{ // } #endregion Console.ReadLine(); }