예제 #1
0
        public void GetSearch_WcfThrowsFaultExceptionValidationFault_TMandatoryCTYTypeMissing( )
        {
            var exception = new FaultException <ValidationFault>(new ValidationFault {
                Details = new List <ValidationDetail> {
                    new ValidationDetail {
                        Key = "Key", Message = "Message"
                    }
                }
            });

            var inModel = new ComplianceReportsListModel {
                DateFrom = new DateTime(2013, 04, 10), DateTo = new DateTime(2013, 06, 02), RecommendingSiteCode = "QM60"
            };
            var request  = MappingEngine.Map <SEARCHLISTRequest>(inModel);
            var response = new SEARCHLISTResponse
            {
                BreachSeqLast       = 0,
                CtyContractTypeLast = "RJCP",
                Flag                     = "N",
                JobseekerIdLast          = 0,
                RecommendingSiteCodeLast = "QM60",
                RecommendedDateLast      = new DateTime(2013, 03, 01),
                SearchListItems          = getMockSearhItems(10).ToArray(),
                ExecutionResult          = new ExecutionResult {
                    Status = ExecuteStatus.Success
                }
            };
            var outModel = MappingEngine.Map <ComplianceReportsListModel>(response);

            mockMappingEngine.Setup(m => m.Map <SEARCHLISTRequest>(inModel)).Throws(exception);
            mockMappingEngine.Setup(m => m.Map <ComplianceReportsListModel>(response)).Returns(outModel);
            var result = SystemUnderTest( ).Search(inModel, false);
        }
예제 #2
0
        public void GetSearch_Valid( )
        {
            var inModel = new ComplianceReportsListModel {
                DateFrom = new DateTime(2013, 02, 02), DateTo = new DateTime(2013, 04, 10), CtyContractType = "RJCP", RecommendingSiteCode = "QM60"
            };
            var request  = MappingEngine.Map <SEARCHLISTRequest>(inModel);
            var response = new SEARCHLISTResponse
            {
                BreachSeqLast       = 0,
                CtyContractTypeLast = "RJCP",
                Flag                     = "N",
                JobseekerIdLast          = 0,
                RecommendingSiteCodeLast = "QM60",
                RecommendedDateLast      = new DateTime(2013, 03, 01),
                SearchListItems          = getMockSearhItems(10).ToArray( ),
                ExecutionResult          = new ExecutionResult {
                    Status = ExecuteStatus.Success
                }
            };
            var outModel = MappingEngine.Map <ComplianceReportsListModel>(response);

            mockMappingEngine.Setup(m => m.Map <SEARCHLISTRequest>(inModel)).Returns(request);
            mockComplianceRetrievalWcf.Setup(m => m.Compliancesearch(request)).Returns(response);
            mockMappingEngine.Setup(m => m.Map <ComplianceReportsListModel>(response)).Returns(outModel);
            var result = SystemUnderTest( ).Search(inModel, false);

            mockMappingEngine.Verify(m => m.Map <SEARCHLISTRequest>(inModel), Times.Once( ));
            mockComplianceRetrievalWcf.Verify(m => m.Compliancesearch(request), Times.Once( ));
            mockMappingEngine.Verify(m => m.Map <IEnumerable <ComplianceReportsListItemModel> >(response.SearchListItems), Times.AtLeastOnce( ));
        }