How can I set the var IStation s to the parameter IStation toAdd?

  • Thread starter Thread starter BarbraFleg
  • Start date Start date
B

BarbraFleg

Guest
TI have to pass test checks that stations can be assigned to a line. The code of the test is:
public void T1()
{
ICity c = CityFactory.CreateCity("Paris");
ILine l1 = c.AddLine("RER A");
IStation s1 = c.AddStation("Opera", 0, 0);
IStation s2 = c.AddStation("Chatelet", 1, 1);
l1.Stations.Count().Should().Be(0);
s1.Lines.Count().Should().Be(0);
s2.Lines.Count().Should().Be(0);
Action action = (() => l1.AddBefore(null, null));
action.ShouldThrow<ArgumentException>();
action = (() => l1.AddBefore(s1, null));
action.ShouldNotThrow();
l1.Next(s1).Should().BeNull();
l1.Previous(s1).Should().BeNull();}
The code that I have tried pass this test by that I used return s from the method Next in the method toAdd.
public void AddBefore(IStation toAdd, IStation before = null)
{
l = s;
if (toAdd == null || s == null)
throw new ArgumentException();
}
public IStation Next(IStation s)
{
return s;
}
public IStation Previous(IStation s)
{
return s;
}

Continue reading...
 
Back
Top