public static void CreateStaff(Staff staff) { if (!testing) { prov.CreateStaff(staff); } else { testprov.CreateStaff(staff); } }
public void UnitTest_CreateNewStaff() { var dummyData = new List <usp_GetStaffByEmail_Result> { new usp_GetStaffByEmail_Result() { StaffID = 1, FirstName = "ABC", LastName = "S", Email = "*****@*****.**", RoleID = 3 } }; var mockedObjectResult = new Mock <ObjectResult <usp_GetStaffByEmail_Result> >(); mockedObjectResult.Setup(x => x.GetEnumerator()).Returns(dummyData.GetEnumerator()); mockUnitOfWork.Setup(x => x.GetDB().usp_GetStaffByEmail("*****@*****.**")).Returns(mockedObjectResult.Object); mockUnitOfWork.Setup(x => x.GetDB().usp_InsertSingleStaff("ABC", "S", "*****@*****.**", "pass", 3, DateTime.Now, DateTime.Now)); StaffProvider provider = new StaffProvider(mockUnitOfWork.Object); var m = provider.CreateStaff(new Model.StaffDtoModel { FirstName = "ABC", LastName = "S", Email = "*****@*****.**", Password = "******", Role = 3 }); var result = provider.GetByEmail("*****@*****.**"); Assert.IsNotNull(result); }