public void TestMethod1() { YieldExample ejemploYield = new YieldExample(); ejemploYield.Ejemplo(); Assert.IsTrue(true); }
public void SummariseWithYield() { // Arrange var classToTest = new YieldExample <int> { MyEnumerable = new int[] { 1, 2, 3, 4, 5, 6 } }; // Act var actualResult = new List <int>(); foreach (var item in classToTest.SummariseWithYield((x, y) => x + y)) { actualResult.Add(item); } // Assert //This is the comparison class var compareLogic = new CompareLogic(); var result = compareLogic.Compare(new List <int> { 1, 3, 6, 10, 15, 21 }, actualResult); Assert.IsTrue(result.AreEqual); }
public void TestYield() { YieldExample y = new YieldExample(); var res = y.FilterByLambda(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, x => x % 2 == 0); res = y.FilterByLambda(res, x => x % 3 == 0); foreach (int i in res) { Console.WriteLine(i); } Assert.Pass(); }
public void FilterWithoutYieldTest() { // Arrange var classToTest = new YieldExample <int> { MyEnumerable = new int[] { 1, 2, 3, 4, 5, 6 } }; var expectedResult = new int[] { 4, 5, 6 }; // Act var actualResult = classToTest.FilterWithoutYield(x => x > 3); // Assert //This is the comparison class var compareLogic = new CompareLogic(); var result = compareLogic.Compare(expectedResult, actualResult); Assert.IsTrue(result.AreEqual); }
public void TestYield2() { var yieldExample = new YieldExample(); // What's the output? // foreach (var i in yieldExample.WithNoYield()) // { // Console.WriteLine(i); // } // What's the output? IEnumerable<int> withYield = yieldExample.WithYield(); Console.Out.WriteLine(withYield.Count()); Console.Out.WriteLine("******"); foreach (int i in withYield) { Console.WriteLine(i); } }
public void TestYield1() { var yieldExample = new YieldExample(); // What's the out put? // yieldExample.WithNoYield(); // What's the out put? yieldExample.WithYield(); }
static void Main(string[] args) { Console.WriteLine("-- ArrayList --"); ArrayListDemo AlDemo = new ArrayListDemo(); AlDemo.AddNew(); AlDemo.Display(); AlDemo.Sort(); Console.WriteLine("Sorted List."); AlDemo.Display(); Console.WriteLine("-- Stack --"); StackDemo st = new StackDemo(); QueueDemo Q = new QueueDemo(); Console.WriteLine("-- Generic List --"); MyGeneric <string> gen = new MyGeneric <string>(); gen.AddItem("abc"); gen.AddItem("xyz"); Console.WriteLine(gen.GetItem()); Console.WriteLine(gen.GetItem(1)); Console.WriteLine("-- Exceptions --"); //UserDefinedException uexp = new UserDefinedException(); try { UserDefinedException.ThrowUserDefinedException(); } catch (UserDefinedException ex) { Console.WriteLine("Exception : " + ex.Message); } try { UserDefinedException.ThrowUserDefinedException("New Message"); } catch (UserDefinedException ex) { Console.WriteLine("Exception : " + ex.Message); } Console.WriteLine("\n-- Format Deemo --"); FormattingDemo.Display(); DisplayXMLContents(); MyList list = new MyList(); Console.WriteLine(list.ToString()); Console.WriteLine("-- AbstractClass static methos--"); Console.WriteLine(AbstractClass.Display("Hello")); Console.WriteLine("-- Yield Example --"); foreach (int i in YieldExample.Power(2, 8)) { Console.Write("{0} ", i); } //// Single Thread Example. Console.WriteLine("\n\nSingle Thread Example.\n"); ThreadDemo thread1 = new ThreadDemo(); ThreadDemo thread2 = new ThreadDemo("FromMain"); Console.WriteLine("Single Thread Ended"); //// Single Thread Example. Console.WriteLine("\n\nTwo Threads Example.\n"); TwoThreads twoThreads = new TwoThreads("Child#1", "Child#2"); Console.WriteLine("Two Threads Ended"); Console.ReadKey(); }