private void SetupMockingListOverrides(UESOverrideListResponse response, OverridesListModel outModel,
                                        OverridesSearchCriteria inModel, UESOverrideListRequest request)
 {
     mockMappingEngine.Setup(x => x.Map <UESOverrideListRequest>(inModel)).Returns(request);
     mockOverridesWcf.Setup(x => x.ListOverrides(request)).Returns(response);
     mockMappingEngine.Setup(m => m.Map <OverridesListModel>(response)).Returns(outModel);
 }
        public void Overrides_Search_Request_Throws_Validation_Error_When_No_Criteria()
        {
            var model   = new OverridesSearchCriteria();
            var request = new UESOverrideListRequest();

            mockMappingEngine.Setup(x => x.Map <UESOverrideListRequest>(model)).Returns(request);
            SystemUnderTest().Search(model);
        }
        public void Overrides_Search_Request_Throws_Validation_Error_When_Fault_Exception()
        {
            var exception = new FaultException <SystemOverridesFault>(new SystemOverridesFault());
            var inModel   = new OverridesSearchCriteria();

            SetupSearchCriteriaModel(inModel);
            var request = MappingEngine.Map <UESOverrideListRequest>(inModel);

            mockMappingEngine.Setup(x => x.Map <UESOverrideListRequest>(inModel)).Returns(request);
            mockOverridesWcf.Setup(x => x.ListOverrides(request)).Throws(exception);
            SystemUnderTest().Search(inModel);
        }
 private void SetupSearchCriteriaModel(OverridesSearchCriteria modelIn)
 {
     modelIn.PlacementType     = "RFC";
     modelIn.OrganisationCode  = "ORG";
     modelIn.SiteCode          = "SITE";
     modelIn.Status            = string.Empty;
     modelIn.SpecificTypes     = new string[0];
     modelIn.Types             = new string[0];
     modelIn.ProgramType       = "RJCP";
     modelIn.SupervisingOffice = "BOB";
     modelIn.JobSeekerId       = 1233445;
 }
        public void Overrides_Search_Request_Valid_Criteria()
        {
            var inModel = new OverridesSearchCriteria();

            SetupSearchCriteriaModel(inModel);
            var request  = MappingEngine.Map <UESOverrideListRequest>(inModel);
            var response = new UESOverrideListResponse {
                OutGroup = new[] { new OutGroup {
                                       JobseekerId = 1233445
                                   } }
            };
            var outModel = MappingEngine.Map <OverridesListModel>(response);

            SetupMockingListOverrides(response, outModel, inModel, request);

            var result = SystemUnderTest().Search(inModel);

            Assert.IsNotNull(result);
            Assert.AreEqual(outModel.Overrides.Count(), result.Overrides.Count());
            Assert.AreEqual(outModel.Overrides.First().JobSeekerId, result.Overrides.First().JobSeekerId);
        }