private static ILaboratoryService GetLabServiceForLabOrdersTests(Common.Constants.ResultType expectedResultType)
        {
            List <LaboratoryOrder> labOrders = new List <LaboratoryOrder>()
            {
                new LaboratoryOrder()
                {
                    Id              = Guid.NewGuid(),
                    Location        = "Vancouver",
                    PHN             = "001",
                    MessageDateTime = DateTime.Now,
                    MessageID       = MockedMessageID + "1",
                    ReportAvailable = true,
                },
                new LaboratoryOrder()
                {
                    Id              = Guid.NewGuid(),
                    Location        = "Vancouver",
                    PHN             = "002",
                    MessageDateTime = DateTime.Now,
                    MessageID       = MockedMessageID + "2",
                    ReportAvailable = false,
                },
            };
            RequestResult <IEnumerable <LaboratoryOrder> > delegateResult = new RequestResult <IEnumerable <LaboratoryOrder> >()
            {
                ResultStatus    = expectedResultType,
                PageSize        = 100,
                PageIndex       = 1,
                ResourcePayload = labOrders,
            };

            var mockLaboratoryDelegate = new Mock <ILaboratoryDelegate>();

            mockLaboratoryDelegate.Setup(s => s.GetLaboratoryOrders(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())).Returns(Task.FromResult(delegateResult));

            var mockLaboratoryDelegateFactory = new Mock <ILaboratoryDelegateFactory>();

            mockLaboratoryDelegateFactory.Setup(s => s.CreateInstance()).Returns(mockLaboratoryDelegate.Object);

            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var context = new DefaultHttpContext()
            {
                Connection =
                {
                    RemoteIpAddress = IPAddress.Parse(IpAddress),
                },
            };

            context.Request.Headers.Add("Authorization", "MockJWTHeader");
            mockHttpContextAccessor.Setup(_ => _.HttpContext).Returns(context);

            ILaboratoryService service = new LaboratoryService(
                new Mock <ILogger <LaboratoryService> >().Object,
                mockHttpContextAccessor.Object,
                mockLaboratoryDelegateFactory.Object);

            return(service);
        }
        private void ShouldGetCommunicationsWithSpecifiedDBStatusCode(DBStatusCode dBStatusCode, Common.Constants.ResultType expectedResultType)
        {
            // Sample communication to test
            List <Communication> commsList = new List <Communication>();

            commsList.Add(new Communication()
            {
                Text              = "Test communication",
                Subject           = "Testing communication",
                EffectiveDateTime = new DateTime(2020, 04, 04),
                ExpiryDateTime    = new DateTime(2020, 05, 13)
            });

            commsList.Add(new Communication()
            {
                Text              = "Test communication 2",
                Subject           = "Testing communication 2",
                EffectiveDateTime = new DateTime(2021, 04, 04),
                ExpiryDateTime    = new DateTime(2021, 05, 13)
            });

            List <Communication> refCommsList = commsList;

            DBResult <IEnumerable <Communication> > commsDBResult = new DBResult <IEnumerable <Communication> >
            {
                Payload = commsList,
                Status  = dBStatusCode
            };

            Mock <ICommunicationDelegate> commsDelegateMock = new Mock <ICommunicationDelegate>();

            commsDelegateMock.Setup(s => s.GetAll()).Returns(commsDBResult);

            ICommunicationService service = new CommunicationService(
                new Mock <ILogger <CommunicationService> >().Object,
                commsDelegateMock.Object
                );

            RequestResult <IEnumerable <Communication> > actualResult = service.GetAll();

            Assert.Equal(expectedResultType, actualResult.ResultStatus);
            Assert.True(actualResult.ResourcePayload.IsDeepEqual(refCommsList));
        }
        private void ShouldAddCommunicationWithSpecifiedDBStatusCode(DBStatusCode dBStatusCode, Common.Constants.ResultType expectedResultType)
        {
            // Sample communication to test
            Communication comm = new Communication()
            {
                Text              = "Test communication",
                Subject           = "Testing communication",
                EffectiveDateTime = new DateTime(2020, 04, 04),
                ExpiryDateTime    = new DateTime(2020, 05, 13)
            };

            // Set up delegate
            DBResult <Communication> insertResult = new DBResult <Communication>
            {
                Payload = comm,
                Status  = dBStatusCode
            };

            Mock <ICommunicationDelegate> communicationDelegateMock = new Mock <ICommunicationDelegate>();

            communicationDelegateMock.Setup(s => s.Add(It.Is <Communication>(x => x.Text == comm.Text), true)).Returns(insertResult);

            // Set up service
            ICommunicationService service = new CommunicationService(
                new Mock <ILogger <CommunicationService> >().Object,
                communicationDelegateMock.Object
                );

            RequestResult <Communication> actualResult = service.Add(comm);

            // Check result
            Assert.Equal(expectedResultType, actualResult.ResultStatus);
            Assert.True(actualResult.ResourcePayload.IsDeepEqual(comm));
        }