Example #1
0
 public void SetUp()
 {
     _fakeBeerService  = A.Fake <IBeerService>();
     _dependentService = new DependentService(_fakeBeerService);
     _beers            = new List <Beer>()
     {
         new()
         {
             Id          = 1,
             Name        = "Beer 1",
             Description = "Beer 1",
             Tagline     = "Beer 1",
             Abv         = 1
         },
         new()
         {
             Id          = 1,
             Name        = "Beer 2",
             Description = "Beer 2",
             Tagline     = "Beer 2",
             Abv         = 2
         },
         new()
         {
             Id          = 1,
             Name        = "Beer 3",
             Description = "Beer 3",
             Tagline     = "Beer 3",
             Abv         = 1
         }
     };
 }
        public void ValidateDependent()
        {
            AddDependentRequest            addDependentRequest = SetupMockInput();
            IDependentService              service             = SetupMockDependentService(addDependentRequest);
            RequestResult <DependentModel> actualResult        = service.AddDependent(mockParentHdId, addDependentRequest);

            Assert.Equal(Common.Constants.ResultType.Success, actualResult.ResultStatus);
        }
 public TenantService(IDependentService dependentService, IGlobalService globalService,
                      Func <IRequestScopedService> requestServiceFactory, Func <ITransientService> transientServiceFactory)
 {
     DependentService         = dependentService;
     _requestServiceFactory   = requestServiceFactory;
     _transientServiceFactory = transientServiceFactory;
     GlobalService            = globalService;
     InstanceNumber           = Interlocked.Increment(ref _counter);
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DependentController"/> class.
 /// </summary>
 /// <param name="logger">The service Logger.</param>
 /// <param name="dependentService">The injected user feedback service.</param>
 /// <param name="httpContextAccessor">The injected http context accessor provider.</param>
 public DependentController(
     ILogger <UserProfileController> logger,
     IDependentService dependentService,
     IHttpContextAccessor httpContextAccessor)
 {
     this.logger              = logger;
     this.dependentService    = dependentService;
     this.httpContextAccessor = httpContextAccessor;
 }
        public void GetDependentsWithEmptyPatientResPayloadError()
        {
            RequestResult <PatientModel> patientResult = new RequestResult <PatientModel>();

            IDependentService service = SetupMockForGetDependents(patientResult);
            RequestResult <IEnumerable <DependentModel> > actualResult = service.GetDependents(mockParentHdId, 0, 500);

            Assert.Equal(Common.Constants.ResultType.Error, actualResult.ResultStatus);
            Assert.Equal("testhostServer-CE-PAT", actualResult.ResultError.ErrorCode);
            Assert.Equal("Communication Exception when trying to retrieve Dependent(s) - HdId: MockHdId-0; HdId: MockHdId-1; HdId: MockHdId-2; HdId: MockHdId-3; HdId: MockHdId-4; HdId: MockHdId-5; HdId: MockHdId-6; HdId: MockHdId-7; HdId: MockHdId-8; HdId: MockHdId-9;", actualResult.ResultError.ResultMessage);
        }
        public void ValidateDependentWithEmptyPatientResPayloadError()
        {
            AddDependentRequest          addDependentRequest = SetupMockInput();
            RequestResult <PatientModel> patientResult       = new RequestResult <PatientModel>();
            // Test Scenario - Happy Path: Found HdId for the PHN, Found Patient.
            IDependentService service = SetupMockDependentService(addDependentRequest, null, patientResult);
            RequestResult <DependentModel> actualResult = service.AddDependent(mockParentHdId, addDependentRequest);

            Assert.Equal(Common.Constants.ResultType.Error, actualResult.ResultStatus);
            Assert.Equal("testhostServer-CE-PAT", actualResult.ResultError.ErrorCode);
        }
        public void GetDependents()
        {
            IDependentService service = SetupMockForGetDependents();
            RequestResult <IEnumerable <DependentModel> > actualResult = service.GetDependents(mockParentHdId, 0, 500);

            Assert.Equal(Common.Constants.ResultType.Success, actualResult.ResultStatus);
            Assert.Equal(10, actualResult.TotalResultCount);

            // Validate masked PHN
            foreach (DependentModel model in actualResult.ResourcePayload)
            {
                Assert.Equal(model.DependentInformation.PHN, mockPHN);
            }
        }
        public void ValidateDependentWithWrongFirstName()
        {
            AddDependentRequest addDependentRequest = SetupMockInput();

            addDependentRequest.FirstName = "wrong";
            IDependentService service = SetupMockDependentService(addDependentRequest);
            RequestResult <DependentModel> actualResult = service.AddDependent(mockParentHdId, addDependentRequest);

            Assert.Equal(Common.Constants.ResultType.Error, actualResult.ResultStatus);
            var serviceError = ErrorTranslator.ServiceError(ErrorType.InvalidState, ServiceType.Patient);

            Assert.Equal(serviceError, actualResult.ResultError.ErrorCode);
            Assert.Equal(mismatchedError, actualResult.ResultError.ResultMessage);
        }
        public void ValidateDependentWithWrongDateOfBirth()
        {
            AddDependentRequest addDependentRequest = SetupMockInput();

            addDependentRequest.DateOfBirth = DateTime.Now;
            IDependentService service = SetupMockDependentService(addDependentRequest);
            RequestResult <DependentModel> actualResult = service.AddDependent(mockParentHdId, addDependentRequest);

            var userError = ErrorTranslator.ActionRequired(ErrorMessages.DataMismatch, ActionType.DataMismatch);

            Assert.Equal(Common.Constants.ResultType.ActionRequired, actualResult.ResultStatus);
            Assert.Equal(userError.ErrorCode, actualResult.ResultError.ErrorCode);
            Assert.Equal(mismatchedError, actualResult.ResultError.ResultMessage);
        }
        public void ValidateDependentWithDbError()
        {
            DBResult <ResourceDelegate> insertResult = new DBResult <ResourceDelegate>
            {
                Payload = null,
                Status  = DBStatusCode.Error
            };
            AddDependentRequest            addDependentRequest = SetupMockInput();
            IDependentService              service             = SetupMockDependentService(addDependentRequest, insertResult);
            RequestResult <DependentModel> actualResult        = service.AddDependent(mockParentHdId, addDependentRequest);

            Assert.Equal(Common.Constants.ResultType.Error, actualResult.ResultStatus);
            var serviceError = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database);

            Assert.Equal(serviceError, actualResult.ResultError.ErrorCode);
        }
        private IDependentService SetupMockForGetDependents(RequestResult <PatientModel> patientResult = null)
        {
            // (1) Setup ResourceDelegateDelegate's mock
            IEnumerable <ResourceDelegate> expectedResourceDelegates = GenerateMockResourceDelegatesList();

            DBResult <IEnumerable <ResourceDelegate> > readResult = new DBResult <IEnumerable <ResourceDelegate> >
            {
                Status = DBStatusCode.Read,
            };

            readResult.Payload = expectedResourceDelegates;

            Mock <IResourceDelegateDelegate> mockDependentDelegate = new Mock <IResourceDelegateDelegate>();

            mockDependentDelegate.Setup(s => s.Get(mockParentHdId, 0, 500)).Returns(readResult);

            // (2) Setup PatientDelegate's mock
            var mockPatientService = new Mock <IPatientService>();

            RequestResult <string> patientHdIdResult = new RequestResult <string>()
            {
                ResultStatus    = Common.Constants.ResultType.Success,
                ResourcePayload = mockHdId
            };

            if (patientResult == null)
            {
                patientResult = new RequestResult <PatientModel>();
                patientResult.ResultStatus    = Common.Constants.ResultType.Success;
                patientResult.ResourcePayload = new PatientModel()
                {
                    HdId = mockHdId,
                    PersonalHealthNumber = mockPHN,
                    FirstName            = mockFirstName,
                    LastName             = mockLastName,
                    Birthdate            = mockDateOfBirth,
                    Gender = mockGender,
                };
            }
            mockPatientService.Setup(s => s.GetPatient(It.IsAny <string>(), It.IsAny <PatientIdentifierType>())).Returns(Task.FromResult(patientResult));

            // (3) Setup other common Mocks
            IDependentService dependentService = SetupCommonMocks(mockDependentDelegate, mockPatientService);

            return(dependentService);
        }
        public void ValidateDependentWithNoHdId()
        {
            RequestResult <PatientModel> patientResult = new RequestResult <PatientModel>();

            patientResult.ResultStatus    = Common.Constants.ResultType.Success;
            patientResult.ResourcePayload = new PatientModel()
            {
                HdId = string.Empty,
                PersonalHealthNumber = mockPHN,
                FirstName            = mockFirstName,
                LastName             = mockLastName,
                Birthdate            = mockDateOfBirth,
                Gender = mockGender,
            };
            AddDependentRequest            addDependentRequest = SetupMockInput();
            IDependentService              service             = SetupMockDependentService(addDependentRequest, patientResult: patientResult);
            RequestResult <DependentModel> actualResult        = service.AddDependent(mockParentHdId, addDependentRequest);

            var userError = ErrorTranslator.ActionRequired(ErrorMessages.InvalidServicesCard, ActionType.NoHdId);

            Assert.Equal(Common.Constants.ResultType.ActionRequired, actualResult.ResultStatus);
            Assert.Equal(userError.ErrorCode, actualResult.ResultError.ErrorCode);
            Assert.Equal(noHdIdError, actualResult.ResultError.ResultMessage);
        }
Example #13
0
 public DependentOnServiceClass(IDependentService <IBasicService> dependentService)
 {
     DependentService = dependentService;
 }
Example #14
0
 public DecoratorDependentService(IDependentService <T> dependentService)
 {
     _dependentService = dependentService;
 }
Example #15
0
 public DecoratorDependentService(IDependentService <T> service)
 {
     _service = service;
 }
 public DependentsController(IDependentService dependentService, IMapper mapper)
 {
     _dependentService = dependentService;
     _mapper           = mapper;
 }
 public DependentClassB(IDependentService <IBasicService> service)
 {
     Service = service;
 }
Example #18
0
 public TransientService(IDependentService dependentService)
 {
     DependentService = dependentService;
     InstanceNumber   = Interlocked.Increment(ref _counter);
 }
 public ControlWithServiceInAspNamespace(IDependentService dependentService1, IDependentService dependentService2, IDependentService dependentService3)
 {
     throw new InvalidOperationException("Must not be called !");
 }
Example #20
0
 public void TearDown()
 {
     _dependentService = null;
     _fakeBeerService  = null;
 }
 public ControlWithServiceInAspNamespace(IDependentService dependentService)
 {
     this.DependentService = dependentService;
 }
 public ControlWithService(IDependentService dependentService)
 {
     this.DependentService = dependentService;
 }
 public Service(IDependentService dependentService)
 {
     this.DependentService = dependentService;
 }
 public PrimeService(IDependentService dependentService
                     )
 {
     _dependentService = dependentService;
 }
Example #25
0
 public DependentController(IDependentService service)
 {
     _service = service;
 }
Example #26
0
 public DependentController(IDependentService dependentService, ITenantService tenantService)
 {
     _dependentService = dependentService;
     _tenantService    = tenantService;
 }
Example #27
0
 public Service(IDependentService dependentService)
 {
 }