Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 44 additions & 47 deletions Tests/GenericCollections/ListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,59 +1130,56 @@ public void List_GenericMethod_NewObj_Foreach_Int()
Assert.AreEqual(15, result);
}

//[TestMethod]
//public void List_GenericMethod_NewObj_Foreach_String()
//{
// string result = ConcatList(new string[] { "Hello", " ", "World" });
// Assert.AreEqual("Hello World", result);
//}
[TestMethod]
public void List_GenericMethod_NewObj_Foreach_String()
{
string result = ConcatList(new string[] { "Hello", " ", "World" });
Assert.AreEqual("Hello World", result);
}

//[TestMethod]
//public void List_GenericMethod_NewObj_Foreach_Class()
//{
// var items = new DummyClass[]
// {
// new(1, "One"),
// new(2, "Two"),
// new(3, "Three")
// };

// var result = CollectFromList(items);
// Assert.AreEqual(3, result.Length);
// Assert.AreEqual(1, result[0].Id);
// Assert.AreEqual("Two", result[1].Name);
// Assert.AreEqual(3, result[2].Id);
//}
[TestMethod]
public void List_GenericMethod_NewObj_Foreach_Class()
{
var items = new DummyClass[]
{
new(1, "One"),
new(2, "Two"),
new(3, "Three")
};

// TODO: fix parsing test result
//[TestMethod]
//public void List_GenericMethod_NewObj_Contains()
//{
// Assert.IsTrue(ListContains(new int[] { 1, 2, 3 }, 2));
// Assert.IsFalse(ListContains(new int[] { 1, 2, 3 }, 5));
var result = CollectFromList(items);
Assert.AreEqual(3, result.Length);
Assert.AreEqual(1, result[0].Id);
Assert.AreEqual("Two", result[1].Name);
Assert.AreEqual(3, result[2].Id);
}

// Assert.IsTrue(ListContains(new string[] { "A", "B", "C" }, "B"));
// Assert.IsFalse(ListContains(new string[] { "A", "B", "C" }, "Z"));
//}
[TestMethod]
public void List_GenericMethod_NewObj_Contains()
{
Assert.IsTrue(ListContains(new int[] { 1, 2, 3 }, 2));
Assert.IsFalse(ListContains(new int[] { 1, 2, 3 }, 5));

// TODO: requires fixing support for nested VAR token resolution
//[TestMethod]
//public void List_GenericMethod_NewObj_AddAndCount()
//{
// Assert.AreEqual(5, BuildListAndCount(1, 2, 3, 4, 5));
// Assert.AreEqual(3, BuildListAndCount("A", "B", "C"));
//}
Assert.IsTrue(ListContains(new string[] { "A", "B", "C" }, "B"));
Assert.IsFalse(ListContains(new string[] { "A", "B", "C" }, "Z"));
}

// TODO: fix parsing test result
//[TestMethod]
//public void List_GenericMethod_NewObj_IndexOf()
//{
// Assert.AreEqual(2, ListIndexOf(new int[] { 10, 20, 30, 40 }, 30));
// Assert.AreEqual(-1, ListIndexOf(new int[] { 10, 20, 30, 40 }, 99));
[TestMethod]
public void List_GenericMethod_NewObj_AddAndCount()
{
Assert.AreEqual(5, BuildListAndCount(1, 2, 3, 4, 5));
Assert.AreEqual(3, BuildListAndCount("A", "B", "C"));
}

// Assert.AreEqual(1, ListIndexOf(new string[] { "X", "Y", "Z" }, "Y"));
// Assert.AreEqual(-1, ListIndexOf(new string[] { "X", "Y", "Z" }, "W"));
//}
[TestMethod]
public void List_GenericMethod_NewObj_IndexOf()
{
Assert.AreEqual(2, ListIndexOf(new int[] { 10, 20, 30, 40 }, 30));
Assert.AreEqual(-1, ListIndexOf(new int[] { 10, 20, 30, 40 }, 99));

Assert.AreEqual(1, ListIndexOf(new string[] { "X", "Y", "Z" }, "Y"));
Assert.AreEqual(-1, ListIndexOf(new string[] { "X", "Y", "Z" }, "W"));
}

[TestMethod]
public void List_GenericMethod_NewObj_RemoveAndVerify()
Expand Down
Loading