I am attempting to use JustMocks to unit test our BLL and DAL layer classes, but I am having trouble getting it to work. I suspect that the issue is that I am not setting up the tests properly for the code. Here is a simple example that follows the pattern of the code under test.
First the object
Then the DAL
Then the BLL
And finally the test
Am I doing these right?
First the object
//BOpublic class Person{ public int ID {get; set;} public string name {get; set;} public int age {get; set;} public bool isMale {get; set;}}Then the DAL
//DALpublic class PersonDbo{ public static BO.Person GetPersonByID(int ID) { BO.Person result = new BO.Person(); //Helper method our project uses Database db = Helper.CreateDbConnection(); using (DbCommand dbCommand = db.GetStoredProcCommand("dbo.Select_Person_ByID")) { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, ID); using (IDataReader r = db.ExecuteReader(dbCommand)) { if (r.Read()) { result.ID = r.GetInt32(r.GetOrdinal("PersonID")); result.name = r.GetString(r.GetOrdinal("Name")); result.age = r.GetInt32(r.GetOrdinal("Age")); result.isMale = r.GetBoolean(r.GetOrdinal("Is_Male")); } else return null; return result; } } }}Then the BLL
//BLLpublic class PersonManager{ public static BO.Person GetPerson(int ID) { BO.Person result = PersonDbo.GetPersonByID(ID); return result; }}And finally the test
//Test[TestClass()]public class PersonManagerTest{ [TestMethod()] public void GetPersonTest() //Arrange Person tom = new Person() { ID = 7, name = "Tom", age = 34, isMale = true}; Mock.SetupStatic<PersonManager>(Behavior.Strict); Mock.Arrange(() => PersonManager.GetPerson(7)).Returns(tom).MustBeCalled(); //Act + Assert Assert.AreEqual(PersonManager.GetPerson(7), tom);}Am I doing these right?