public InterestedInTeacherTraining()
 {
     _validator = new TeacherTrainingAdviserSignUpValidator(new Mock <IStore>().Object, new DateTimeProvider());
     _request   = new TeacherTrainingAdviserSignUp()
     {
         TypeId = (int)Candidate.Type.InterestedInTeacherTraining
     };
 }
示例#2
0
 public ReturningToTeacherTraining()
 {
     _validator = new TeacherTrainingAdviserSignUpValidator(new Mock <IStore>().Object);
     _request   = new TeacherTrainingAdviserSignUp()
     {
         TypeId = (int)Candidate.Type.ReturningToTeacherTraining
     };
 }
        public void Candidate_PhoneCallScheduledAtIsNull_NoPhoneCallIsCreated()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                PhoneCallScheduledAt = null
            };

            request.Candidate.PhoneCall.Should().BeNull();
        }
        public void Candidate_AddressPostcode_IsFormatted()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                AddressPostcode = "ky119yu"
            };

            request.Candidate.AddressPostcode.Should().Be("KY11 9YU");
        }
        public void Candidate_NullTelephone_PhoneCallDestinationIsCorrect()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                Telephone = null, PhoneCallScheduledAt = DateTime.UtcNow
            };

            request.Candidate.PhoneCall.DestinationId.Should().BeNull();
        }
        public void Candidate_QualificationFieldsAreNull_NoQualificationIsCreated()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                UkDegreeGradeId = null, DegreeStatusId = null, DegreeSubject = null, DegreeTypeId = null
            };

            request.Candidate.Qualifications.Should().BeEmpty();
        }
        public void Candidate_DegreeSubjectIdIsPresent_QualificationIsCreated()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                UkDegreeGradeId = null, DegreeStatusId = null, DegreeSubject = "Maths", DegreeTypeId = null
            };

            request.Candidate.Qualifications.Count.Should().Be(1);
        }
        public void Candidate_InternationalTelephone_PhoneCallDestinationIsCorrect(string telephone)
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                Telephone = telephone, PhoneCallScheduledAt = DateTime.UtcNow
            };

            request.Candidate.PhoneCall.DestinationId.Should().Be((int)PhoneCall.Destination.International);
        }
        public void Candidate_SubjectTaughtIdIsNull_NoPastTeachingPositionIsCreated()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                SubjectTaughtId = null
            };

            request.Candidate.PastTeachingPositions.Should().BeEmpty();
        }
        public void Candidate_PhoneCallScheduledAtIsNull_EligibilityRulesPassedIsFalse()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                PhoneCallScheduledAt = null
            };

            request.Candidate.EligibilityRulesPassed.Should().Be("false");
        }
        public void Candidate_ReturningToTeaching_PreferredEducationPhaseIdDefaultsToSecondary()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                TypeId = (int)Candidate.Type.ReturningToTeacherTraining
            };

            request.Candidate.PreferredEducationPhaseId.Should().Be((int)Candidate.PreferredEducationPhase.Secondary);
        }
        public void Candidate_ChannelIdWhenCandidateIdIsNull_IsTeacherTrainingAdviser()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                CandidateId = null
            };

            request.Candidate.ChannelId.Should().Be((int)Candidate.Channel.TeacherTrainingAdviser);
        }
        public void Candidate_ChannelIdWhenCandidateIdIsNotNull_IsNotChanged()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                CandidateId = Guid.NewGuid()
            };

            request.Candidate.ChannelId.Should().BeNull();
            request.Candidate.ChangedPropertyNames.Should().NotContain("ChannelId");
        }
        public void Candidate_DegreeTypeDegreeEquivalent_IsNotEligibleForAdviser()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                DegreeTypeId = (int)CandidateQualification.DegreeType.DegreeEquivalent
            };

            request.Candidate.AssignmentStatusId.Should().BeNull();
            request.Candidate.AdviserEligibilityId.Should().BeNull();
            request.Candidate.AdviserRequirementId.Should().BeNull();
        }
        public void Candidate_DegreeTypeDegree_IsEligibleForAdviser()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                DegreeTypeId = (int)CandidateQualification.DegreeType.Degree
            };

            request.Candidate.AssignmentStatusId.Should().Be((int)Candidate.AssignmentStatus.WaitingToBeAssigned);
            request.Candidate.AdviserEligibilityId.Should().Be((int)Candidate.AdviserEligibility.Yes);
            request.Candidate.AdviserRequirementId.Should().Be((int)Candidate.AdviserRequirement.Yes);
        }
        public void Candidate_EducationPhaseIsPrimary_SetsPreferredTeachingSubjectIdToPrimary()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                PreferredEducationPhaseId = (int)Candidate.PreferredEducationPhase.Primary,
            };

            var candidate = request.Candidate;

            candidate.PreferredTeachingSubjectId.Should().Be(LookupItem.PrimaryTeachingSubjectId);
        }
        public void Candidate_InterestedInTeaching_CorrectConsent()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                TypeId = (int)Candidate.Type.InterestedInTeacherTraining
            };

            var candidate = request.Candidate;

            candidate.DoNotBulkEmail.Should().BeFalse();
            candidate.DoNotSendMm.Should().BeFalse();
        }
        public void Candidate_ReturningToTeaching_CorrectConsent()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                TypeId = (int)Candidate.Type.ReturningToTeacherTraining
            };

            var candidate = request.Candidate;

            candidate.DoNotBulkEmail.Should().BeTrue();
            candidate.DoNotSendMm.Should().BeTrue();
        }
        public void Candidate_ReturningToTeaching_IsEligibleForAdviser()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                TypeId = (int)Candidate.Type.ReturningToTeacherTraining
            };

            request.Candidate.IsReturningToTeaching().Should().BeTrue();
            request.Candidate.AssignmentStatusId.Should().Be((int)Candidate.AssignmentStatus.WaitingToBeAssigned);
            request.Candidate.AdviserEligibilityId.Should().Be((int)Candidate.AdviserEligibility.Yes);
            request.Candidate.AdviserRequirementId.Should().Be((int)Candidate.AdviserRequirement.Yes);
        }
        public void Candidate_InterestedInTeaching_IsNotEligibleForAdviser()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                TypeId = (int)Candidate.Type.InterestedInTeacherTraining
            };

            request.Candidate.IsReturningToTeaching().Should().BeFalse();
            request.Candidate.AssignmentStatusId.Should().BeNull();
            request.Candidate.AdviserEligibilityId.Should().BeNull();
            request.Candidate.AdviserRequirementId.Should().BeNull();
        }
示例#21
0
        public IActionResult SignUp(
            [FromBody, SwaggerRequestBody("Candidate to sign up for the Teacher Training Adviser service.", Required = true)] TeacherTrainingAdviserSignUp request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }

            string json = request.Candidate.SerializeChangeTracked();

            _jobClient.Enqueue <UpsertCandidateJob>((x) => x.Run(json, null));

            return(NoContent());
        }
示例#22
0
        public void SignUp_ValidRequest_EnqueuesJobAndRespondsWithSuccess()
        {
            var request = new TeacherTrainingAdviserSignUp {
                FirstName = "first"
            };

            var response = _controller.SignUp(request);

            response.Should().BeOfType <NoContentResult>();
            _mockJobClient.Verify(x => x.Create(
                                      It.Is <Job>(job => job.Type == typeof(UpsertCandidateJob) && job.Method.Name == "Run" &&
                                                  IsMatch(request.Candidate, (string)job.Args[0])),
                                      It.IsAny <EnqueuedState>()));
        }
示例#23
0
        public void SignUp_InvalidRequest_RespondsWithValidationErrors()
        {
            var request = new TeacherTrainingAdviserSignUp {
                Email = "invalid-email@"
            };

            _controller.ModelState.AddModelError("Email", "Email is invalid.");

            var response = _controller.SignUp(request);

            var badRequest = response.Should().BeOfType <BadRequestObjectResult>().Subject;
            var errors     = badRequest.Value.Should().BeOfType <SerializableError>().Subject;

            errors.Should().ContainKey("Email").WhichValue.Should().BeOfType <string[]>().Which.Should().Contain("Email is invalid.");
        }
        public IActionResult SignUp(
            [FromBody, SwaggerRequestBody("Candidate to sign up for the Teacher Training Adviser service.", Required = true)] TeacherTrainingAdviserSignUp request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }

            // This is the only way we can mock/freeze the current date/time
            // in contract tests (there's no other way to inject it into this class).
            request.DateTimeProvider = _dateTime;
            string json = request.Candidate.SerializeChangeTracked();

            _jobClient.Enqueue <UpsertCandidateJob>((x) => x.Run(json, null));

            return(NoContent());
        }
        public void Candidate_GcseIdIsNull_DefaultsToNotAnswered()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                HasGcseMathsAndEnglishId = null,
                HasGcseScienceId         = null,
                PlanningToRetakeGcseMathsAndEnglishId = null,
                PlanningToRetakeGcseScienceId         = null,
            };

            var candidate = request.Candidate;

            var gcses = new int?[]
            {
                candidate.HasGcseEnglishId,
                candidate.HasGcseMathsId,
                candidate.HasGcseScienceId,
                candidate.PlanningToRetakeGcseEnglishId,
                candidate.PlanningToRetakeGcseMathsId,
                candidate.PlanningToRetakeGcseScienceId
            };

            gcses.Should().AllBeEquivalentTo((int)Candidate.GcseStatus.NotAnswered);
        }
        public void Constructor_WithCandidate_MapsCorrectly()
        {
            var latestQualification = new CandidateQualification()
            {
                Id              = Guid.NewGuid(),
                CreatedAt       = DateTime.UtcNow.AddDays(10),
                DegreeStatusId  = 1,
                UkDegreeGradeId = 2,
                TypeId          = 3,
                DegreeSubject   = "English"
            };

            var qualifications = new List <CandidateQualification>()
            {
                new CandidateQualification()
                {
                    Id = Guid.NewGuid(), CreatedAt = DateTime.UtcNow.AddDays(3)
                },
                latestQualification,
                new CandidateQualification()
                {
                    Id = Guid.NewGuid(), CreatedAt = DateTime.UtcNow.AddDays(5)
                },
            };

            var latestPastTeachingPosition = new CandidatePastTeachingPosition()
            {
                Id              = Guid.NewGuid(),
                CreatedAt       = DateTime.UtcNow.AddDays(10),
                SubjectTaughtId = Guid.NewGuid(),
            };

            var pastTeachingPositions = new List <CandidatePastTeachingPosition>()
            {
                new CandidatePastTeachingPosition()
                {
                    Id = Guid.NewGuid(), CreatedAt = DateTime.UtcNow.AddDays(3)
                },
                latestPastTeachingPosition,
                new CandidatePastTeachingPosition()
                {
                    Id = Guid.NewGuid(), CreatedAt = DateTime.UtcNow.AddDays(5)
                },
            };

            var candidate = new Candidate()
            {
                Id = Guid.NewGuid(),
                PreferredTeachingSubjectId = Guid.NewGuid(),
                CountryId = Guid.NewGuid(),
                InitialTeacherTrainingYearId = 1,
                PreferredEducationPhaseId    = 2,
                TypeId           = (int)Candidate.Type.ReturningToTeacherTraining,
                HasGcseEnglishId = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                HasGcseMathsId   = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                HasGcseScienceId = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                PlanningToRetakeGcseEnglishId = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                PlanningToRetakeGcseMathsId   = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                PlanningToRetakeGcseScienceId = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                Email                 = "*****@*****.**",
                FirstName             = "John",
                LastName              = "Doe",
                DateOfBirth           = DateTime.UtcNow,
                Telephone             = "1234567",
                TeacherId             = "abc123",
                AddressLine1          = "Address 1",
                AddressLine2          = "Address 2",
                AddressCity           = "City",
                AddressPostcode       = "KY11 9YU",
                Qualifications        = qualifications,
                PastTeachingPositions = pastTeachingPositions,
                HasTeacherTrainingAdviserSubscription = true,
            };

            var response = new TeacherTrainingAdviserSignUp(candidate);

            response.CandidateId.Should().Be(candidate.Id);
            response.PreferredTeachingSubjectId.Should().Be(candidate.PreferredTeachingSubjectId);
            response.CountryId.Should().Be(candidate.CountryId);
            response.InitialTeacherTrainingYearId.Should().Be(candidate.InitialTeacherTrainingYearId);
            response.PreferredEducationPhaseId.Should().Be(candidate.PreferredEducationPhaseId);
            response.HasGcseMathsAndEnglishId.Should().Be((int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking);
            response.HasGcseScienceId.Should().Be(candidate.HasGcseScienceId);
            response.PlanningToRetakeGcseScienceId.Should().Be(candidate.PlanningToRetakeGcseScienceId);
            response.PlanningToRetakeGcseMathsAndEnglishId.Should().Be((int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking);
            response.TypeId.Should().Be((int)Candidate.Type.ReturningToTeacherTraining);
            response.Email.Should().Be(candidate.Email);
            response.FirstName.Should().Be(candidate.FirstName);
            response.LastName.Should().Be(candidate.LastName);
            response.TeacherId.Should().Be(candidate.TeacherId);
            response.Telephone.Should().Be(candidate.Telephone);
            response.AddressLine1.Should().Be(candidate.AddressLine1);
            response.AddressLine2.Should().Be(candidate.AddressLine2);
            response.AddressCity.Should().Be(candidate.AddressCity);
            response.AddressPostcode.Should().Be(candidate.AddressPostcode);

            response.QualificationId.Should().Be(latestQualification.Id);
            response.DegreeStatusId.Should().Be(latestQualification.DegreeStatusId);
            response.UkDegreeGradeId.Should().Be(latestQualification.UkDegreeGradeId);
            response.DegreeSubject.Should().Be(latestQualification.DegreeSubject);
            response.DegreeTypeId.Should().Be(latestQualification.TypeId);

            response.PastTeachingPositionId.Should().Be(latestPastTeachingPosition.Id);
            response.SubjectTaughtId.Should().Be(latestPastTeachingPosition.SubjectTaughtId);

            response.AlreadySubscribedToTeacherTrainingAdviser.Should().BeTrue();
        }
        public void Candidate_MapsCorrectly()
        {
            var request = new TeacherTrainingAdviserSignUp()
            {
                CandidateId                = Guid.NewGuid(),
                QualificationId            = Guid.NewGuid(),
                SubjectTaughtId            = Guid.NewGuid(),
                PastTeachingPositionId     = Guid.NewGuid(),
                PreferredTeachingSubjectId = Guid.NewGuid(),
                CountryId                             = Guid.NewGuid(),
                AcceptedPolicyId                      = Guid.NewGuid(),
                TypeId                                = (int)Candidate.Type.ReturningToTeacherTraining,
                UkDegreeGradeId                       = 0,
                DegreeStatusId                        = 1,
                DegreeTypeId                          = 2,
                InitialTeacherTrainingYearId          = 3,
                PreferredEducationPhaseId             = 4,
                HasGcseMathsAndEnglishId              = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                HasGcseScienceId                      = 7,
                PlanningToRetakeGcseMathsAndEnglishId = (int)Candidate.GcseStatus.HasOrIsPlanningOnRetaking,
                PlanningToRetakeGcseScienceId         = 9,
                Email                = "*****@*****.**",
                FirstName            = "John",
                LastName             = "Doe",
                DateOfBirth          = DateTime.UtcNow,
                Telephone            = "1234567",
                TeacherId            = "abc123",
                DegreeSubject        = "Maths",
                AddressLine1         = "Address 1",
                AddressLine2         = "Address 2",
                AddressCity          = "City",
                AddressPostcode      = "KY11 9YU",
                PhoneCallScheduledAt = DateTime.UtcNow,
            };

            var candidate = request.Candidate;

            candidate.Id.Should().Equals(request.CandidateId);
            candidate.PreferredTeachingSubjectId.Should().Equals(request.PreferredTeachingSubjectId);
            candidate.CountryId.Should().Equals(request.CountryId);
            candidate.InitialTeacherTrainingYearId.Should().Equals(request.InitialTeacherTrainingYearId);
            candidate.PreferredEducationPhaseId.Should().Equals(request.PreferredEducationPhaseId);
            candidate.HasGcseEnglishId.Should().Equals(request.HasGcseMathsAndEnglishId);
            candidate.HasGcseMathsId.Should().Equals(request.HasGcseMathsAndEnglishId);
            candidate.HasGcseScienceId.Should().Equals(request.HasGcseScienceId);
            candidate.PlanningToRetakeGcseEnglishId.Should().Equals(request.PlanningToRetakeGcseMathsAndEnglishId);
            candidate.PlanningToRetakeGcseMathsId.Should().Equals(request.PlanningToRetakeGcseMathsAndEnglishId);
            candidate.PlanningToRetakeGcseScienceId.Should().Equals(request.PlanningToRetakeGcseScienceId);
            candidate.AdviserRequirementId.Should().Be((int)Candidate.AdviserRequirement.Yes);
            candidate.AdviserEligibilityId.Should().Be((int)Candidate.AdviserEligibility.Yes);
            candidate.AssignmentStatusId.Should().Be((int)Candidate.AssignmentStatus.WaitingToBeAssigned);
            candidate.TypeId.Should().Be((int)Candidate.Type.ReturningToTeacherTraining);
            candidate.Email.Should().Be(request.Email);
            candidate.FirstName.Should().Be(request.FirstName);
            candidate.LastName.Should().Be(request.LastName);
            candidate.DateOfBirth.Should().Be(request.DateOfBirth);
            candidate.AddressPostcode.Should().Be(request.AddressPostcode);
            candidate.Telephone.Should().Be(request.Telephone);
            candidate.TeacherId.Should().Be(request.TeacherId);
            candidate.AddressLine1.Should().Be(request.AddressLine1);
            candidate.AddressLine2.Should().Be(request.AddressLine2);
            candidate.AddressCity.Should().Be(request.AddressCity);
            candidate.AddressPostcode.Should().Be(request.AddressPostcode);
            candidate.ChannelId.Should().BeNull();
            candidate.EligibilityRulesPassed.Should().Be("true");
            candidate.OptOutOfSms.Should().BeFalse();
            candidate.DoNotBulkEmail.Should().BeTrue();
            candidate.DoNotEmail.Should().BeFalse();
            candidate.DoNotBulkPostalMail.Should().BeTrue();
            candidate.DoNotPostalMail.Should().BeTrue();
            candidate.DoNotSendMm.Should().BeTrue();

            candidate.PrivacyPolicy.AcceptedPolicyId.Should().Be((Guid)request.AcceptedPolicyId);

            candidate.PhoneCall.ScheduledAt.Should().Be((DateTime)request.PhoneCallScheduledAt);
            candidate.PhoneCall.Telephone.Should().Be(request.Telephone);
            candidate.PhoneCall.ChannelId.Should().Be((int)PhoneCall.Channel.CallbackRequest);
            candidate.PhoneCall.DestinationId.Should().Be((int)PhoneCall.Destination.Uk);
            candidate.PhoneCall.Subject.Should().Be("Scheduled phone call requested by John Doe");

            candidate.PastTeachingPositions.First().Id.Should().Be(request.PastTeachingPositionId);
            candidate.PastTeachingPositions.First().SubjectTaughtId.Should().Be(request.SubjectTaughtId);
            candidate.PastTeachingPositions.First().EducationPhaseId.Should().Be((int)CandidatePastTeachingPosition.EducationPhase.Secondary);

            candidate.Qualifications.First().Id.Should().Be(request.QualificationId);
            candidate.Qualifications.First().UkDegreeGradeId.Should().Be(request.UkDegreeGradeId);
            candidate.Qualifications.First().DegreeStatusId.Should().Be(request.DegreeStatusId);
            candidate.Qualifications.First().DegreeSubject.Should().Be(request.DegreeSubject);
            candidate.Qualifications.First().TypeId.Should().Be(request.DegreeTypeId);

            candidate.HasTeacherTrainingAdviserSubscription.Should().BeTrue();
        }
示例#28
0
 public TeacherTrainingAdviserSignUpValidatorTests()
 {
     _request   = new TeacherTrainingAdviserSignUp();
     _validator = new TeacherTrainingAdviserSignUpValidator(new Mock <IStore>().Object);
 }
 public TeacherTrainingAdviserSignUpValidatorTests()
 {
     _request   = new TeacherTrainingAdviserSignUp();
     _validator = new TeacherTrainingAdviserSignUpValidator(new Mock <IStore>().Object, new DateTimeProvider());
 }