コード例 #1
0
        public void SubmitEnquiryValidationTests()
        {
            //Arrange

            //setup Empty addressViewModel
            var addressViewModelBuilder =
                new AddressViewModelBuilder().Build();
            //setup empty employerEnquiryViewModel
            var employerEnquiryViewModel = new EmployerEnquiryViewModelBuilder()
                                           .Address(addressViewModelBuilder)
                                           .Build();

            Mock <IReferenceDataMediator> referenceDataMediator = new Mock <IReferenceDataMediator>();

            referenceDataMediator.Setup(c => c.GetReferenceData(It.IsAny <ReferenceDataTypes>()))
            .Returns(new MediatorResponse <ReferenceDataListViewModel>()
            {
                ViewModel = new ReferenceDataListViewModel()
            });

            var mediator = new EmployerEnquiryMediatorBuilder().With(referenceDataMediator).Build();

            //Act
            var response = mediator.SubmitEnquiry(employerEnquiryViewModel);

            //Assert
            response.Code.Should().Be(EmployerEnquiryMediatorCodes.SubmitEnquiry.ValidationError);
            response.ViewModel.Should().Be(employerEnquiryViewModel);
            response.ValidationResult.Should().NotBeNull();
        }
コード例 #2
0
        public void SubmitEnquiryTests(SubmitQueryStatus submitQueryStatus, string mediatorCode, string pageMessage, UserMessageLevel userMessageLevel)
        {
            //Arrange
            string firstname          = "First",
                   lastname           = "Last",
                   companyname        = "companyName",
                   email              = "*****@*****.**",
                   employeeCount      = "100",
                   enquiryDescription = "test query",
                   enquirySource      = "Telephone Call",
                   title              = "Mr",
                   prevExp            = "Yes",
                   position           = "Position",
                   workSector         = "retail",
                   phoneNumber        = "0987654321",
                   mobile             = "1234567890",
                   address1           = "Line1",
                   city                 = "City",
                   postcode             = "Postcode";
            var addressViewModelBuilder =
                new AddressViewModelBuilder().AddressLine1(address1).City(city).Postcode(postcode).Build();

            var employerEnquiryViewModel = new EmployerEnquiryViewModelBuilder().Firstname(firstname).Lastname(lastname).MobileNumber(mobile)
                                           .PhoneNumber(phoneNumber).Position(position).PrevExp(prevExp).Title(title)
                                           .WorkSector(workSector)
                                           .EnquirySource(enquirySource).EnquiryDescription(enquiryDescription).EmployeeCount(employeeCount)
                                           .Email(email).Companyname(companyname)
                                           .Address(addressViewModelBuilder)
                                           .Build();

            var employerProviderMock = new Mock <IEmployerEnquiryProvider>();

            employerProviderMock.Setup(x => x.SubmitEnquiry(It.IsAny <EmployerEnquiryViewModel>())).Returns(submitQueryStatus);

            Mock <IReferenceDataMediator> referenceDataMediator = new Mock <IReferenceDataMediator>();

            referenceDataMediator.Setup(c => c.GetReferenceData(It.IsAny <ReferenceDataTypes>()))
            .Returns(new MediatorResponse <ReferenceDataListViewModel>()
            {
                ViewModel = new ReferenceDataListViewModel()
            });

            var mediator = new EmployerEnquiryMediatorBuilder().With(employerProviderMock).With(referenceDataMediator).Build();

            //Act
            var response = mediator.SubmitEnquiry(employerEnquiryViewModel);

            //Assert
            response.Code.Should().Be(mediatorCode);
            response.Message.Text.Should().Be(pageMessage);
            response.Message.Level.Should().Be(userMessageLevel);
        }