Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help needed with "Unit Testing" to test a method!

dr_itondr_iton Posts: 4Member

I created a three layer windows based application. I'm trying to make a unit testing using NUINT, but the problem is that I don't know how to access the method. I created my application in this manner : I'll try to test the method Shto(Klasa obj) Business Object namespace "BO"

namespace BO { public class Klasa { private int k_ID_Klasa; private int k_KlasaViti; private int k_Paralelja;

    public Klasa()
    {
    }

    public int ID_Klasa
    {
        get { return k_ID_Klasa; }
        set { k_ID_Klasa = value; }
    }

    public int KlasaViti
    {
        get { return k_KlasaViti; }
        set { k_KlasaViti = value; }
    }

    public int Paralelja
    {
        get { return k_Paralelja; }
        set { k_Paralelja = value; }
    }
}

}

Data Access Layer "DAL"

Collapse | Copy Code namespace DAL { public class KlasaDB {
public KlasaDB() {

    }

    public static void Shto(Klasa obj)
    {
        SqlConnection sqlConn = new SqlConnection(StringKoneksioni.Stringu);
        SqlCommand sqlCmd = new SqlCommand("procShtoKlasa", sqlConn);
        sqlCmd.CommandType = CommandType.StoredProcedure;
        sqlCmd.Parameters.AddWithValue("@KlasaViti", obj.KlasaViti);
        sqlCmd.Parameters.AddWithValue("@Paralelja", obj.Paralelja);
        sqlConn.Open();
        sqlCmd.ExecuteNonQuery();
        sqlConn.Close();
    }
 }

}

Business Logic Layer "BLL"

namespace BLL { public class KlasaIURD { public KlasaIURD() {

        }

        public static void Shto(Klasa obj)
        {
            KlasaDB.Shto(obj);
        }
}

}

I created the references for the namespaces needed in the project and also I created a testing class but the problem is that I don't know how to access the class method, that means I'm stacked in the following class:

namespace ScoMan_TI.NUnit_Testing { [TestFixture] class Klasa_Testuese { Klasa klasa;

    [SetUp]
    public void initKlasa()
    {

        //int ID_Klasa = 15;
        //int KlasaViti = 12;
        //int Paralelja = 5;
        //KlasaDB = new KlasaDB()
        //KlasaDB.Shto()

//The problem is at the following line, I tryed //klasa = new Shto(Klasa obj); //And also // klasa = new Klasa(ID_Klasa, KlasaViti, Paralelja) // no such of method exists with three parameters.
}

}

}

Thank you in advance for your reply. Cheers

Tagged:
Sign In or Register to comment.