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


the fillupwater function test 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());     } } 

i can see few problems here. have placed each issue in comment...

[testclass()] public class watercontainer {     [testmethod()]     public void whenwatercontainerisempty_fillingitup_causescorrectwaterlevel() {          // there seems no relationship between container         // , tap - how tap cause change         // container?         watercontainer waterc = new watercontainer(0);         watertap tap = new watertap();          // method shared called:         // fillupwater, calling fillupcontainer         waterc= tap.fillupcontainer();          // create variable named:         // waterc, use waterc here (c# case sensitive)         assert.areequal(5, waterc.level);     } } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -