public void GetDeliveryReportMessageTypesPaged_Success_Test() { // Arrange string searchTerm = ""; int pageIndex = 0; int pageSize = 10; // list IList <R_DeliveryReportMessageType> list = new List <R_DeliveryReportMessageType>(); for (int i = 1; i <= pageSize; i++) { list.Add(SampleDeliveryReportMessageType(i)); } // create mock for repository var mock = new Mock <IDeliveryReportMessageTypeRepository>(); mock.Setup(s => s.GetDeliveryReportMessageTypes(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list); // service DeliveryReportMessageTypeService deliveryReportMessageTypeService = new DeliveryReportMessageTypeService(); DeliveryReportMessageTypeService.Repository = mock.Object; // Act var resultList = deliveryReportMessageTypeService.GetDeliveryReportMessageTypes(searchTerm, pageIndex, pageSize); DeliveryReportMessageTypeDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.DeliveryReportMessageTypeId); Assert.AreEqual(10, resultList.Count); }
public void GetDeliveryReportMessageTypes_Success_Test() { // Arrange R_DeliveryReportMessageType deliveryReportMessageType = SampleDeliveryReportMessageType(1); IList <R_DeliveryReportMessageType> list = new List <R_DeliveryReportMessageType>(); list.Add(deliveryReportMessageType); // create mock for repository var mock = new Mock <IDeliveryReportMessageTypeRepository>(); mock.Setup(s => s.GetDeliveryReportMessageTypes()).Returns(list); // service DeliveryReportMessageTypeService deliveryReportMessageTypeService = new DeliveryReportMessageTypeService(); DeliveryReportMessageTypeService.Repository = mock.Object; // Act var resultList = deliveryReportMessageTypeService.GetDeliveryReportMessageTypes(); DeliveryReportMessageTypeDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.DeliveryReportMessageTypeId); }