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(); }
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); }
public void GivenSuccess_ThenSuccessStatusIsReturned() { //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 viewModel = 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(); Mock <ICommunciationService> serviceMock = new Mock <ICommunciationService>(); serviceMock.Setup(cs => cs.SendMessage(It.IsAny <MessageTypes>(), It.IsAny <IEnumerable <CommunicationToken> >())); Mock <IViewModelToDomainMapper <EmployerEnquiryViewModel, EmployerEnquiry> > employerEnquiryVtoDMapper = new Mock <IViewModelToDomainMapper <EmployerEnquiryViewModel, EmployerEnquiry> >(); employerEnquiryVtoDMapper.Setup(cs => cs.ConvertToDomain(It.IsAny <EmployerEnquiryViewModel>())) .Returns(new EmployerEnquiry() { Address = new Address() }); var provider = new EmployerEnquiryProviderBuilder().With(serviceMock).With(employerEnquiryVtoDMapper).Build(); //Act var result = provider.SubmitGlaEnquiry(viewModel); //Assert result.Should().Be(SubmitQueryStatus.Success); }
public void SubmitAccessRequestTests(AccessRequestSubmitStatus submitQueryStatus, string mediatorCode, string pageMessage, UserMessageLevel userMessageLevel) { //Arrange string firstname = "First", lastname = "Last", companyname = "companyName", email = "*****@*****.**", confirmEmail = "*****@*****.**", userType = "Employer", title = "Mr", position = "Position", phoneNumber = "0987654321", mobile = "1234567890", address1 = "Line1", city = "City", postcode = "Postcode"; var addressViewModelBuilder = new AddressViewModelBuilder().AddressLine1(address1).City(city).Postcode(postcode).Build(); var accessRequestViewModel = new AccessRequestViewModelBuilder().Firstname(firstname).Lastname(lastname).MobileNumber(mobile) .PhoneNumber(phoneNumber).Position(position).UserType(userType).ConfirmEmail(confirmEmail).Title(title) .Email(email).Companyname(companyname) .Address(addressViewModelBuilder) .Build(); var providerMock = new Mock <IAccessRequestProvider>(); providerMock.Setup(x => x.SubmitAccessRequest(It.IsAny <AccessRequestViewModel>())).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 AccessRequestMediatorBuilder().With(providerMock).With(referenceDataMediator).Build(); //Act var response = mediator.SubmitAccessRequest(accessRequestViewModel); //Assert response.Code.Should().Be(mediatorCode); response.Message.Text.Should().Be(pageMessage); response.Message.Level.Should().Be(userMessageLevel); }
public void GivenSuccess_ThenSuccessStatusIsReturned() { //Arrange string firstname = "First", lastname = "Last", companyname = "companyName", email = "*****@*****.**", confirmEmail = "*****@*****.**", userType = "Employer", title = "Mr", position = "Position", phoneNumber = "0987654321", mobile = "1234567890", address1 = "Line1", city = "City", postcode = "Postcode"; var addressViewModelBuilder = new AddressViewModelBuilder().AddressLine1(address1).City(city).Postcode(postcode).Build(); var accessRequestViewModel = new AccessRequestViewModelBuilder().Firstname(firstname).Lastname(lastname).MobileNumber(mobile) .PhoneNumber(phoneNumber).Position(position).UserType(userType).ConfirmEmail(confirmEmail).Title(title) .Email(email).Companyname(companyname) .Address(addressViewModelBuilder) .Build(); Mock <ICommunciationService> serviceMock = new Mock <ICommunciationService>(); serviceMock.Setup(cs => cs.SendMessage(It.IsAny <MessageTypes>(), It.IsAny <IEnumerable <CommunicationToken> >())); Mock <IViewModelToDomainMapper <AccessRequestViewModel, AccessRequest> > vtoDMapper = new Mock <IViewModelToDomainMapper <AccessRequestViewModel, AccessRequest> >(); vtoDMapper.Setup(cs => cs.ConvertToDomain(It.IsAny <AccessRequestViewModel>())) .Returns(new AccessRequest() { Address = new Address() }); var provider = new AccessRequestProviderBuilder().With(serviceMock).With(vtoDMapper).Build(); //Act var result = provider.SubmitAccessRequest(accessRequestViewModel); //Assert result.Should().Be(AccessRequestSubmitStatus.Success); }
public void SetUp() { _addressViewModelBuilder = new AddressViewModelBuilder(); }
public static string CreateContactForm() { 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 enquiryData = 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 builder = new StringBuilder(); builder.AppendLine(string.Format("Full name : {0} {1} {2}", enquiryData.Title, enquiryData.Firstname.ToFirstCharToUpper(), enquiryData.Lastname.ToFirstCharToUpper())); builder.AppendLine(string.Format("Email : {0}", enquiryData.Email)); builder.AppendLine(string.Format("Position at company : {0}", enquiryData.Position.ToFirstCharToUpper())); builder.AppendLine(string.Format("Phone number : {0}", enquiryData.WorkPhoneNumber)); if (!string.IsNullOrEmpty(enquiryData.MobileNumber)) { builder.AppendLine(string.Format("Mobile : {0}", enquiryData.MobileNumber)); } builder.AppendLine(string.Format("Company name : {0}", enquiryData.Companyname.ToFirstCharToUpper())); builder.AppendLine(string.Format("Address: line 1 - {0}", enquiryData.Address.AddressLine1)); if (!string.IsNullOrEmpty(enquiryData.Address.AddressLine2)) { builder.AppendLine(string.Format("Address : line 2 - {0}", enquiryData.Address.AddressLine2)); } if (!string.IsNullOrEmpty(enquiryData.Address.AddressLine3)) { builder.AppendLine(string.Format("Address : line 3 - {0}", enquiryData.Address.AddressLine3)); } if (!string.IsNullOrEmpty(enquiryData.Address.City)) { builder.AppendLine(string.Format("Address : city - {0}", enquiryData.Address.City.ToFirstCharToUpper())); } builder.AppendLine(string.Format("Address : postcode - {0}", enquiryData.Address.Postcode)); builder.AppendLine(string.Format("Total no of employees : {0}", enquiryData.EmployeesCount)); builder.AppendLine(string.Format("Industry sector : {0}", enquiryData.WorkSector)); builder.AppendLine(string.Format("Previous experience with Apprenticeships/Traineeships? : {0}", enquiryData.PreviousExperienceType)); builder.AppendLine(string.Format("What prompted to make enquiry : {0}", enquiryData.EnquirySource)); builder.AppendLine(string.Format("Nature of query : {0}", enquiryData.EnquiryDescription.ToFirstCharToUpper())); return(builder.ToString()); }