I have a C# program that returns an empty collection and a Unit test that test to see if the name of an element in the empty returned collection is the same as an object I have.I'm asserting that that a string comparison of both elments should be 0 but the test never fails,what am i doing wrong?:
[Test]
public void testGetProjects ()
{
Project1 = new Project(1);
Project1.Name = "PHS";
string tester;
tester = "PHS";
ReturnedProject s = PAgent.SearchPr ojects(tester);
foreach (Project Proj in ReturnedProject s)
{
string nameOfProject;
string projectNameToCo mpare;
projectNameToCo mpare = Proj.Name;
nameOfProject = Project1.Name;
Assert.IsTrue(S tring.Compare(n ameOfProject, projectNameToCo mpare) == 0);
}
}
[Test]
public void testGetProjects ()
{
Project1 = new Project(1);
Project1.Name = "PHS";
string tester;
tester = "PHS";
ReturnedProject s = PAgent.SearchPr ojects(tester);
foreach (Project Proj in ReturnedProject s)
{
string nameOfProject;
string projectNameToCo mpare;
projectNameToCo mpare = Proj.Name;
nameOfProject = Project1.Name;
Assert.IsTrue(S tring.Compare(n ameOfProject, projectNameToCo mpare) == 0);
}
}
Comment