jeudi 23 avril 2015

Can anyone tell me if my unit test to this function is correct?

The FillUpWater function i was to test is as follows?

public bool FillUpWater()
{ 
   WaterTap tap = new WaterTap();
    if (tap.FillUpContainer())
    { 
      Level = 5; 
      return true;
    } 
    else
    { 
      return false;
    }
}
public void FillUpWater()
{
   throw new NotImplementedException();
}

my unit test:

[TestClass()]
public class WaterContainer
{
    [TestMethod()]
    public void WhenWaterContainerIsEmpty_FillingItUp_CausesCorrectWaterLevel()    // Uppgift 4: Vattenbehållaren fylls av 
    {                                                                              // vattenkranen automatisk om den är tom
        // arrange
        WaterContainer waterC = new WaterContainer(0);
        WaterTap tap = new WaterTap();

        // act
        waterC= tap.FillUpContainer();
        // assert
        Assert.AreEqual(5, WaterC.Level);
        //Assert.IsTrue(tap.FillUpContainer());
    }
}

Aucun commentaire:

Enregistrer un commentaire