public void ListToStringTestMethod() { //arrange CList <CList <string> > storedList = new CList <CList <string> >(); CList <string> storedInts = new CList <string>(); CList <string> storedStrings = new CList <string>(); string testString; string resultString; storedInts.Add("1"); storedInts.Add("2"); storedInts.Add("3"); storedInts.Add("4"); storedInts.Add("5"); storedStrings.Add("This"); storedStrings.Add("Is"); storedStrings.Add("A"); storedStrings.Add("Test"); storedStrings.Add("."); storedList.Add(storedInts); storedList.Add(storedStrings); testString = "1,2,3,4,5,This,Is,A,Test,."; //act resultString = storedList.ToString(); //assert Assert.AreEqual(testString, resultString); }
public void Zip2Lines_PositiveZip_CorrectCount() { //arrange CList <int> list1 = new CList <int> { }; CList <int> list2 = new CList <int> { }; int new1Int = 1; int new2Int = 2; int new3Int = 3; int new4Int = 4; int new5Int = 5; int new6Int = 6; list1.Add(new1Int); list1.Add(new2Int); list1.Add(new3Int); list2.Add(new4Int); list2.Add(new5Int); list2.Add(new6Int); //act CList <int> list3 = list1.Zip(list2); string testString = list3.ToString(); //assert Assert.AreEqual(list3.Count, 6); }
static void Main(String[] args) { CList <CTest> l = new CList <CTest>(); l.Add(new CTest()); l.Add(new CTest()); l.Add(new CTest()); l.Remove(2); l.Remove(1); var i = l.Add(new CTest()); var v = i.Index; l.AddAt(1, new CTest()); l.AddAt(2, new CTest()); l.AddAt(0, new CTest()); l.Remove(1); var i0 = l.Get(0); var i1 = l.Get(1); if (i1) { Console.WriteLine("i1"); } var i2 = l.Get(2); var i3 = l.Get(3); Console.WriteLine("end"); }
public void Zip2Lines_PositiveZip_CorrectStringOrder() { //arrange CList <string> list1 = new CList <string> { }; CList <string> list2 = new CList <string> { }; string new1String = "1"; string new2String = "2"; string new3String = "3"; string new4String = "4"; string new5String = "5"; string new6String = "6"; list1.Add(new1String); list1.Add(new2String); list1.Add(new3String); list2.Add(new4String); list2.Add(new5String); list2.Add(new6String); //act CList <string> list3 = list1.Zip(list2); string testString = list3.ToString(); //assert Assert.AreEqual("142536", testString); }
public void Reduce2Lists_PositiveTest_Same1List() { //arrange CList <int> list1 = new CList <int> { }; CList <int> list2 = new CList <int> { }; int new1Int = 1; int new2Int = 2; int new3Int = 3; int new4Int = 4; int new5Int = 5; int new6Int = 6; list1.Add(new1Int); list1.Add(new2Int); list1.Add(new3Int); list2.Add(new4Int); list2.Add(new5Int); list2.Add(new6Int); //act string test1String = list1.ToString(); string test2String = list2.ToString(); CList <int> list3 = list1 - list2; string test3String = list3.ToString(); //assert Assert.AreEqual(test3String, test1String); }
public void IterableTestMethod() { //arrange CList <int> storedValues = new CList <int>(); int counter; counter = 0; storedValues.Add(1); storedValues.Add(2); storedValues.Add(3); storedValues.Add(4); storedValues.Add(5); storedValues.Add(6); storedValues.Add(7); storedValues.Add(8); storedValues.Add(9); storedValues.Add(0); //act foreach (int number in storedValues) { counter = counter + number; } //assert Assert.AreEqual(45, counter); }
public void PlusOperatorTestMethod() { //arrange CList <int> storedValues = new CList <int>(); CList <int> additionalValues = new CList <int>(); CList <int> combinedValues = new CList <int>(); CList <int> testValues = new CList <int>(); storedValues.Add(0); storedValues.Add(1); storedValues.Add(2); additionalValues.Add(3); additionalValues.Add(4); additionalValues.Add(5); testValues.Add(0); testValues.Add(1); testValues.Add(2); testValues.Add(3); testValues.Add(4); testValues.Add(5); //act combinedValues = storedValues + additionalValues; //assert Assert.AreEqual(testValues[0], combinedValues[0]); Assert.AreEqual(testValues[5], combinedValues[5]); Assert.AreEqual(testValues[9], combinedValues[9]); Assert.AreEqual(testValues.count, combinedValues.count); Assert.AreEqual(testValues.capacity, testValues.capacity); }
public void Reduce2ListsWIthInt_PositiveTest_Different1List() { //arrange CList <string> list1 = new CList <string> { }; CList <string> list2 = new CList <string> { }; string new1String = "1"; string new2String = "2"; string new3String = "3"; string new4String = "4"; string new5String = "5"; string new6String = "6"; list1.Add(new1String); list1.Add(new2String); list1.Add(new3String); list2.Add(new4String); list2.Add(new5String); list2.Add(new6String); //act string test1Int = list1.ToString(); string test2Int = list2.ToString(); CList <string> list3 = list1 - list2; string test3Int = list3.ToString(); //assert Assert.AreEqual(test3Int, test1Int); }
public void StoreListTestMethod() { //arrange CList <CList <string> > storeValueList = new CList <CList <string> >(); CList <string> stringList = new CList <string>(); stringList.Add("this"); stringList.Add("is"); stringList.Add("a"); stringList.Add("test"); CList <string> stringOfNumbers = new CList <string>(); stringOfNumbers.Add("1"); stringOfNumbers.Add("2"); stringOfNumbers.Add("3"); stringOfNumbers.Add("4"); //act storeValueList.Add(stringList); storeValueList.Add(stringOfNumbers); //assert Assert.AreSame(stringList, storeValueList[0]); Assert.AreSame(stringOfNumbers, storeValueList[1]); }
public void StoreValueTestMethod() { //arrange CList <int> storeValueList = new CList <int>(); //act storeValueList.Add(9); storeValueList.Add(8); storeValueList.Add(7); storeValueList.Add(6); storeValueList.Add(5); storeValueList.Add(4); storeValueList.Add(3); storeValueList.Add(2); storeValueList.Add(1); storeValueList.Add(0); //assert Assert.AreEqual(9, storeValueList[0]); Assert.AreEqual(8, storeValueList[1]); Assert.AreEqual(7, storeValueList[2]); Assert.AreEqual(6, storeValueList[3]); Assert.AreEqual(5, storeValueList[4]); Assert.AreEqual(4, storeValueList[5]); Assert.AreEqual(3, storeValueList[6]); Assert.AreEqual(2, storeValueList[7]); Assert.AreEqual(1, storeValueList[8]); Assert.AreEqual(0, storeValueList[9]); }
public async CTask Do() { Console.WriteLine("TRAVEL AGENT - Workflow Initialized"); var compensatingActions = new CList <Func <CTask> >(); try { var reservationId = await BankConnection.ReserveFunds(1_000, "1234-1234-1234-1234"); compensatingActions.Add(() => BankConnection.CancelReservation(reservationId)); var carBookingId = await AirlineConnection.Book("Mazda 2 Sport"); compensatingActions.Add(() => AirlineConnection.CancelBooking(carBookingId)); var hotelBookingId = await HotelConnection.Book("Hotel Dangleterre Suite"); compensatingActions.Add(() => HotelConnection.CancelBooking(hotelBookingId)); await BankConnection.DeductFunds(reservationId); } catch (Exception) { compensatingActions.ForEach(a => a()); throw; } Console.WriteLine("TRAVEL AGENT - Workflow completed!"); }
public static void Main() { var list2 = new CList <int>(); list2.Add(1000); list2.Add(2000); Console.WriteLine(list2.ToString()); }
public void AddAndRemoveNonReferencingElementsFromCList() { var storage = new InMemoryStorageEngine(); var os = ObjectStore2.New(storage); var cList = new CList <string>(); cList.Add("hello"); cList.Add("world"); cList.Add("from here"); os.Roots.Entangle(cList); os.Persist(); os = ObjectStore2.Load(storage); cList = os.Roots.Find <CList <string> >(); cList.Count.ShouldBe(3); cList[0].ShouldBe("hello"); cList[1].ShouldBe("world"); cList[2].ShouldBe("from here"); cList.Remove(0); os.Persist(); os = ObjectStore2.Load(storage); cList = os.Roots.Find <CList <string> >(); cList.Count.ShouldBe(2); cList[0].ShouldBe("world"); cList[1].ShouldBe("from here"); cList.Remove(1); os.Persist(); os = ObjectStore2.Load(storage); cList = os.Roots.Find <CList <string> >(); cList.Count.ShouldBe(1); cList[0].ShouldBe("world"); cList.Add("hello"); os.Persist(); os = ObjectStore2.Load(storage); cList = os.Roots.Find <CList <string> >(); cList.Count.ShouldBe(2); cList[0].ShouldBe("world"); cList[1].ShouldBe("hello"); cList.Remove(0); cList.Remove(0); os.Persist(); os = ObjectStore2.Load(storage); cList = os.Roots.Find <CList <string> >(); cList.Count.ShouldBe(0); }
// public void RemoveValue_Return_Expected_Count_8() { int count = 8; int ExpectedResult = count; //Arrange CList <int> customList = new CList <int>(); int value1 = 10; int value2 = 20; int value3 = 30; int value4 = 40; int value5 = 50; int value6 = 60; int value7 = 70; int value8 = 80; int value9 = 90; //Act customList.Add(value1); customList.Add(value2); customList.Add(value3); customList.Add(value4); customList.Add(value5); customList.Add(value6); customList.Add(value7); customList.Add(value8); customList.Add(value9); customList.Remove(value2); //Assert Assert.AreEqual(ExpectedResult, customList.Count); }
public void CapacityTestMethod() { //arrange CList <int> storeValueList = new CList <int>(); //act //storing 25 intregers storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); storeValueList.Add(9); //assert Assert.AreEqual(40, storeValueList.capacity); }
public _SServer(TPeerCnt PeerCounter_, CNamePort MasterNamePort_, string DataFile_) { PeerCounter = PeerCounter_; ParentNamePort = new COptionStream <CNamePort>(DataFile_, true); ConnectNamePorts.Add(MasterNamePort_); if (ParentNamePort.Data && !ParentNamePort.Data.Equals(MasterNamePort_)) { ConnectNamePorts.Add(ParentNamePort.Data); } }
public void MinusOperatorTestMethod() { //arrange CList <int> storedValues = new CList <int>(); CList <int> subtractingValues = new CList <int>(); CList <int> resultValues = new CList <int>(); CList <int> testValues = new CList <int>(); storedValues.Add(1); storedValues.Add(2); storedValues.Add(3); storedValues.Add(4); storedValues.Add(1); storedValues.Add(2); storedValues.Add(3); storedValues.Add(4); storedValues.Add(1); storedValues.Add(2); storedValues.Add(3); storedValues.Add(4); subtractingValues.Add(1); subtractingValues.Add(3); testValues.Add(2); testValues.Add(4); testValues.Add(2); testValues.Add(4); testValues.Add(2); testValues.Add(4); //act resultValues = storedValues - subtractingValues; //assert Assert.AreEqual(testValues[0], resultValues[0]); Assert.AreEqual(testValues[1], resultValues[1]); Assert.AreEqual(testValues[2], resultValues[2]); Assert.AreEqual(testValues[3], resultValues[3]); Assert.AreEqual(testValues[4], resultValues[4]); Assert.AreEqual(testValues[5], resultValues[5]); Assert.AreEqual(testValues[6], resultValues[6]); Assert.AreEqual(testValues.count, resultValues.count); Assert.AreNotEqual(storedValues[0], resultValues[0]); foreach (int item in resultValues) { Assert.AreNotEqual(1, item); Assert.AreNotEqual(3, item); } }
public void AddStrings_PositiveAddition_CheckSecondString() { //Arrange CList <string> list = new CList <string> { }; string new1String = "New Addition 1"; string new2String = "New Addition 2"; //Act list.Add(new1String); list.Add(new2String); //Assert Assert.AreEqual(list[1], new2String); }
public void AddInts_PositiveAddition_CheckSecondInt() { //Arrange CList <int> list = new CList <int> { }; int new1Int = 1; int new2Int = 2; //Act list.Add(new1Int); list.Add(new2Int); //Assert Assert.AreEqual(list[1], new2Int); }
public void Add_to_List_Returen_Index_0_Expected_Value_10() { //Arrange CList <int> customList = new CList <int>(); int value = 10; int value1 = 20; int ExpectedResult = value; //Act customList.Add(value); customList.Add(value1); //Assert Assert.AreEqual(ExpectedResult, customList[0]); }
public void RemoveString_NegativeRemoval_NextString() { //Arrange CList <string> list = new CList <string> { }; string new1String = "New Addition 1"; string new2String = "New Addition 2"; list.Add(new1String); list.Add(new2String); //Act list.Remove(new1String); //Assert Assert.AreNotEqual(list[0], new1String); }
public void RemoveInt_NegativeRemoval_NextInt() { //Arrange CList <int> list = new CList <int> { }; int new1Int = 1; int new2Int = 2; list.Add(new1Int); list.Add(new2Int); //Act list.Remove(new1Int); //Assert Assert.AreNotEqual(list[0], new1Int); }
public void Remove_IndexOF_Add_Methode() { //Arrange CList <int> customList = new CList <int>(); int value = 10; int value1 = 20; //Act customList.Add(value); customList.Add(value1); customList.Remove(value1); //Assert Assert.AreEqual(value, customList[0]); }
public void AddThreeInts_PositiveAddition_CheckThirdInt() { //Arrange CList <int> list = new CList <int> { }; int new1Int = 1; int new2Int = 2; int new3Int = 3; //Act list.Add(new1Int); list.Add(new2Int); list.Add(new3Int); //Assert Assert.AreEqual(list[2], new3Int); }
public void AddStrings_CheckCount_CorrectCount() { //Arrange CList <string> list = new CList <string> { }; string new1String = "New Addition 1"; string new2String = "New Addition 2"; string new3String = "New Addition 3"; //Act list.Add(new1String); list.Add(new2String); list.Add(new3String); //Assert Assert.AreEqual(list.Count, 3); }
public void RemoveFalseStringFrom2_PositiveRemoval_SameString() { //Arrange CList <string> list = new CList <string> { }; string new1String = "New Addition 1"; string new2String = "New Addition 2"; string new3String = "New Addition 3"; list.Add(new1String); list.Add(new2String); //Act list.Remove(new3String); //Assert Assert.AreEqual(list[1], new2String); }
public void RemoveFalseIntFrom2_PositiveRemoval_SameInt() { //Arrange CList <int> list = new CList <int> { }; int new1Int = 1; int new2Int = 2; int new3Int = 3; list.Add(new1Int); list.Add(new2Int); //Act list.Remove(new3Int); //Assert Assert.AreEqual(list[1], new2Int); }
public void StoreStringTestMethod() { //arrange CList <string> storeValueList = new CList <string>(); //act storeValueList.Add("this"); storeValueList.Add("is"); storeValueList.Add("a"); storeValueList.Add("test"); //assert Assert.AreEqual("this", storeValueList[0]); Assert.AreEqual("is", storeValueList[1]); Assert.AreEqual("a", storeValueList[2]); Assert.AreEqual("test", storeValueList[3]); }
public void TestByCount_Add_Methode_Return_Expected_Count_1() { //Arrange CList <int> customList = new CList <int>(); int value = 10; int value2 = 20; int CountValue = 1; //Act customList.Add(value); customList.Add(value2); customList.Remove(20); //Assert Assert.AreEqual(CountValue, customList.Count); }
public void RemoveStringFrom3_PositiveRemoval_CorrectCount() { //Arrange CList <string> list = new CList <string> { }; string new1String = "New Addition 1"; string new2String = "New Addition 2"; string new3String = "New Addition 3"; list.Add(new1String); list.Add(new2String); list.Add(new3String); //Act list.Remove(new2String); //Assert Assert.AreEqual(list.Count, 2); }
public static CList Car(CList l) { if (l.la.Count == 0) return new CList(); if (l.la[0] is CList) return (CList)l.la[0]; CList newlist = new CList(); newlist.Add(l.la[0]); return newlist; }
public static CList Init(String item) { CList newlist = new CList(); int index = 0; if (item.CompareTo(String.Empty) == 0) return newlist; //Empty CList is NIL if(item[0] == '('){ return InitMultiple(item, ref index); } else newlist.Add(item); return newlist; }
private static CList InitMultiple(String str, ref int index) { CList newList = new CList(); //String tempstr = str.SubString(1); //tempstr = str.SubString(0, str.Length - 1); String temp = null; bool InState = false; index++; while (index < str.Length){ if(Char.IsWhiteSpace(str[index])){ if (InState){ newList.Add(temp); temp = null; } index++; InState = false; } else if(str[index] == '('){ newList.Add(InitMultiple(str, ref index)); } else if(str[index] == ')'){ if(InState) newList.Add(temp); index++; return newList; } else{ InState = true; temp = temp + str[index]; index++; } } Console.WriteLine("IlFormed Parens"); return null; }