public void GetIntersectionNodeTest() { var headA = new ListNode(4); headA.next = new ListNode(1); headA.next.next = new ListNode(8); headA.next.next.next = new ListNode(4); headA.next.next.next.next = new ListNode(5); var headB = new ListNode(5); headB.next = new ListNode(6); headB.next.next = new ListNode(1); headB.next.next.next = new ListNode(8); headB.next.next.next.next = new ListNode(4); headB.next.next.next.next.next = new ListNode(5); // var headA = new ListNode(8); // var headB = new ListNode(4); // headB.next = new ListNode(1); // headB.next.next = new ListNode(8); // headB.next.next.next = new ListNode(4); // headB.next.next.next.next = new ListNode(5); // actual var actual = ListTest.GetIntersectionNode(headA, headB); // assert //Assert.AreEqual(actual, expected); }
public void AddTwoNumbersTest() { // var l1 = new ListNode (2); // l1.next = new ListNode (4); // l1.next.next = new ListNode (3); // var l2 = new ListNode (5); // l2.next = new ListNode (6); // l2.next.next = new ListNode (4); var l1 = new ListNode(9); l1.next = new ListNode(9); l1.next.next = new ListNode(9); l1.next.next.next = new ListNode(9); l1.next.next.next.next = new ListNode(9); l1.next.next.next.next.next = new ListNode(9); l1.next.next.next.next.next.next = new ListNode(9); var l2 = new ListNode(9); l2.next = new ListNode(9); l2.next.next = new ListNode(9); l2.next.next.next = new ListNode(9); // var l1 = new ListNode (0); // var l2 = new ListNode (0); // actual var actual = ListTest.AddTwoNumbers(l1, l2); // assert //Assert.AreEqual(actual, expected); }
static void Main(string[] args) { var t = new ListTest(); t.Test(); Console.ReadKey(); }
protected override void Run() { try { mDebugger.Send("Run"); // C# WhileLoopTests.Execute(); ForeachLoopTests.Execute(); // System ObjectTests.Execute(); ArrayTests.Execute(); StringTest.Execute(); ByteTest.Execute(); SByteTest.Execute(); Int16Test.Execute(); UInt16Test.Execute(); Int32Test.Execute(); UInt32Test.Execute(); Int64Test.Execute(); UInt64Test.Execute(); CharTest.Execute(); BooleanTest.Execute(); SingleTest.Execute(); DoubleTest.Execute(); MathTest.Execute(); ConvertTests.Execute(); //mDebugger.Send("Thread test start of 500 ms"); //ThreadTest.Execute(); //mDebugger.Send("Thread test end"); //DecimalTest.Execute(); BitConverterTest.Execute(); UnsafeCodeTest.Execute(); DelegatesTest.Execute(); RandomTests.Execute(); // System.Collections.Generic ListTest.Execute(); QueueTest.Execute(); DictionaryTest.Execute(); // System.Text EncodingTest.Execute(); TestController.Completed(); } catch (Exception e) { mDebugger.Send("Exception occurred: " + e.Message); mDebugger.Send(e.Message); Console.WriteLine("Exception occurred"); Console.WriteLine(e.Message); TestController.Failed(); } }
public void Dump_OutputsCorrectString_IEnumerableProps() { var test = new ListTest { ListProp = new List <string> { "foo", "bar" }, IntListProp = new[] { 1, 2, 3, 5 } }; const string expected = "ListProp: foo, bar\r\nIntListProp: 1, 2, 3, 5"; test.Dump().Should().Be(expected); }
public void ConvertsDouble_ToString_ConvertsInToString() { //arrange ListTest <double> list = new ListTest <double> { 1, 2.2, 3.3, 4.4444444444 }; string expectedString = "1 2.2 3.3 4.4444444444 "; //act string actualString = list.ToString(); //assert Assert.AreEqual(actualString, expectedString); }
public void Removing_LongNumbers_RemovesLong() { //arrange ListTest <long> list = new ListTest <long> { 1111111111, 2222222222, 3333333333, 4444444444 }; //act list.Remove(4444444444); //assert Assert.AreNotEqual(4444444444, list[3]); }
public void ReverseListTest() { var head = new ListNode(1); head.next = new ListNode(2); head.next.next = new ListNode(3); head.next.next.next = new ListNode(4); // actual var actual = ListTest.ReverseList(head); // assert //Assert.AreEqual(actual, expected); }
public void Add_DecimalNumbers_AddsToList() { // Arrange ListTest <decimal> List = new ListTest <decimal>(); decimal result = 199.81m; List.Add(199.81m); List.Add(391.00m); List.Add(0.33m); List.Add(33m); // Assert Assert.AreEqual(result, List[0]); }
public void RemoveAt_Decimal_RemovesDecimalAtSpecifiedIndex() { //arrange ListTest <decimal> list = new ListTest <decimal> { 1m, 2.22222m, 3333333.333333333m, 4444444444444.444444444m }; //act list.Remove(3333333.333333333m); //assert Assert.AreNotEqual(3333333.333333333m, list[2]); }
public void RemoveAt_Double_RemovesDoubleAtSpecifiedIndex() { //arrange ListTest <double> list = new ListTest <double> { 3, 4.44, 5, 6.6666, 77777777.7 }; //act list.Remove(6.6666); //assert Assert.AreNotEqual(6.6666, list[3]); }
public void ConvertsLarge_Int_ConvertsLargeInt() { //arrange ListTest <int> list = new ListTest <int> { 234552323 }; string expectedString = "234552323 "; //act string actualString = list.ToString(); //assert Assert.AreEqual(expectedString, actualString); }
public void ConvertsDecimal_ToString_ConvertsInToString() { //arrange ListTest <decimal> list = new ListTest <decimal> { 1.1m, 2.2m, 3.3m, 4.4m, 5.5m }; string expectedString = "1.1 2.2 3.3 4.4 5.5 "; //act string actualString = list.ToString(); //assert Assert.AreEqual(actualString, expectedString); }
public void Removing_String_Removes() { //arrange ListTest <string> list = new ListTest <string>() { "jack", "jill", "went", "up", "the", "hill", "to" }; //act list.Remove("jack"); //assert Assert.AreEqual("jill", list[0]); }
public void Removing_Int_RemovesInt() { //arrange ListTest <int> list = new ListTest <int>() { 0, 1, 2, 3, 4, 5, 6 }; //act list.Remove(3); //assert Assert.AreNotEqual(3, list[3]); }
public void Remove_String_RemovesAtIndexSpecified() { //arrange ListTest <string> list = new ListTest <string>() { "house", "appartment", "condo", "cabin", "duplex", "trailer" }; //act list.Remove("condo"); //assert Assert.AreNotEqual("condo", list[2]); }
public void Add_Long_AddsToList() { //arrange ListTest <long> list = new ListTest <long>(); long result = 1000000000000000000; list.Add(1234567890); list.Add(112233445566778899); list.Add(987654321); list.Add(1000000000000000000); //assert Assert.AreEqual(result, list[3]); }
public void Remove_Double_RemovesDouble() { //arrange ListTest <double> list = new ListTest <double>() { 20, 15.333, 83.1, 40000000, 21 }; //act list.Remove(40000000); //assert Assert.AreNotEqual(40000000, list[3]); }
public void Remove_Decimal_RemovesDecimal() { //arrange ListTest <decimal> list = new ListTest <decimal>() { 0.33m, 1.532m, 2.8642m, 3.55m, 4.123m, 5.989m }; // act list.Remove(2.8642m); //assert Assert.AreNotEqual(2.8642m, list[2]); }
public void RemoveAt_Int_RemovesIntAtSpecifiedIndex() { //arrange ListTest <int> list = new ListTest <int>() { 2, 6, 3, 99, 5, 3, 11 }; // act list.Remove(99); //assert Assert.AreNotEqual(99, list[3]); }
public void Add_DoubleNumber_AddsDouble() { // Arrange ListTest <double> List = new ListTest <double>(); double result = 10.33; List.Add(3.5); List.Add(99); List.Add(32.4521); List.Add(97.44); List.Add(10.33); // Assert Assert.AreEqual(result, List[4]); }
public void Dump_OutputsCorrectString_IEnumerableProps() { var test = new ListTest { ListProp = new List <string> { "foo", "bar" }, IntListProp = new[] { 1, 2, 3, 5 } }; const string expected = "\tListProp:\t[ \"foo\", \"bar\" ]\r\n\tIntListProp:\t[ \"1\", \"2\", \"3\", \"5\" ]\r\n"; var dump = test.Dump(); dump.Should().Be(expected.Replace("\r\n", Environment.NewLine)); }
public void IsPalindromeTest() { var head = new ListNode(1); head.next = new ListNode(2); head.next.next = new ListNode(3); head.next.next.next = new ListNode(2); // head.next.next.next.next = new ListNode(1); // actual var actual = ListTest.IsPalindrome(head); // assert //Assert.AreEqual(actual, expected); }
public void ConvertStrings_ToString_ConvertsInToString() { //arrange ListTest <string> list = new ListTest <string>() { "The", "vanadium", "students", "are", "all", "rock", "stars" }; string expectedString = "The vanadium students are all rock stars "; //act string actualString = list.ToString(); //assert Assert.AreEqual(expectedString, actualString); }
public void Count_Strings_CountsStrings() { //arrange ListTest <string> list = new ListTest <string>() { "teacher", "student", "mentor", "assistant", "teacher aid" }; int expectedCount = 5; //act int actualCount = list.Count; //assert Assert.AreEqual(expectedCount, actualCount); }
public void Count_Decimals_CountsDecimals() { //arrange ListTest <decimal> list = new ListTest <decimal>() { 32.11m, 431.25m, 32m, 124.2m, 120.99m, 84.3m }; int expectedCount = 6; //act int actualCount = list.Count; //assert Assert.AreEqual(expectedCount, actualCount); }
public void Count_Int_CountsInt() { //arrange ListTest <int> list = new ListTest <int>() { 99, 3, 256, 8888, 9011, 54321 }; int expectedCount = 6; //act int actualCount = list.Count; //assert Assert.AreEqual(expectedCount, actualCount); }
public void Count_long_CountsLongNumbers() { //arrange ListTest <long> list = new ListTest <long>() { 1111111111, 22222222222, 333333333333, 44444444444444, 555555555 }; long expectedCount = 5; //act long actualCount = list.Count; //assert Assert.AreEqual(expectedCount, actualCount); }
public void ConvertsInt_ToString_ConvertsInToString() { //arrange ListTest <int> list = new ListTest <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; string expectedString = "1 2 3 4 5 6 7 8 9 "; //act string actualString = list.ToString(); //assert Assert.AreEqual(expectedString, actualString); }
public void Add_LargeNumbers_AddsToList() { //Arrange ListTest <int> List = new ListTest <int>(); int result = 123456789; List.Add(123456789); List.Add(444444444); List.Add(999999999); List.Add(987654321); List.Add(666666666); //Assert Assert.AreEqual(result, List[0]); }