public void ShouldReturnCallLogObjectByJobIdAndCallLogId() { //Arrange FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>(); fakeCallLogList.AddObject(new CS_CallLog() { ID = 1, JobID = 1, Active = true }); fakeCallLogList.AddObject(new CS_CallLog() { ID = 2, JobID = 2, Active = true }); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); //Act CS_CallLog callLog = model.LoadCallLog(1, 1); //Assert Assert.AreEqual(1, callLog.ID); Assert.AreEqual(1, callLog.JobID); }
public void ShouldReturnNullObjectWhenLoadingByJobIdAndCallLogId() { //Arrange FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>(); fakeCallLogList.AddObject(new CS_CallLog() { ID = 1, JobID = 1, Active = true }); fakeCallLogList.AddObject(new CS_CallLog() { ID = 2, JobID = 2, Active = true }); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); //Act CS_CallLog callLog = model.LoadCallLog(1, 2); //Assert Assert.IsNull(callLog); }
/// <summary> /// Loads and existing call log /// </summary> public void LoadCallLog() { try { using (_callLogModel = new CallLogModel()) { if (_view.JobId.HasValue && _view.CallID.HasValue) { _view.CallEntryEntity = _callLogModel.LoadCallLog(_view.JobId.Value, _view.CallID.Value); } } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load call log.\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has ocurred while trying to load the Information. Please try again.", false); } }