public void ItShouldParseDateFormats()
        {
            var dataService          = new Mock <IDataService>();
            var establishmentService = new Mock <IEstablishmentService>();

            dataService.Setup(x => x.GetAnswerPotentials(It.IsAny <string>())).Returns(new List <AnswerPotential>());
            var admittedFromAbroadRules = new RemovePupilAdmittedFromAbroadRule(dataService.Object, null, establishmentService.Object);

            var outcome = admittedFromAbroadRules.Apply(new Amendment()
            {
                URN     = "100987",
                Answers = new List <UserAnswer>
                {
                    new UserAnswer {
                        Value = "2/1/2021", QuestionId = "ArrivalDateQuestion"
                    }
                }
            });

            Assert.True(outcome.ValidationErrors == null);
            Assert.True(outcome.IsComplete == false);

            outcome = admittedFromAbroadRules.Apply(new Amendment()
            {
                URN     = "100987",
                Answers = new List <UserAnswer>
                {
                    new UserAnswer {
                        Value = "2-1-2021", QuestionId = "ArrivalDateQuestion"
                    }
                }
            });

            Assert.True(outcome.ValidationErrors == null);
            Assert.True(outcome.IsComplete == false);

            outcome = admittedFromAbroadRules.Apply(new Amendment()
            {
                URN     = "100987",
                Answers = new List <UserAnswer>
                {
                    new UserAnswer {
                        Value = "2-1-21", QuestionId = "ArrivalDateQuestion"
                    }
                }
            });

            Assert.True(outcome.ValidationErrors != null);
            Assert.True(outcome.IsComplete == false);
        }
        public void ItShouldPresentExpectedQuestionsForAdmittedFromAboard()
        {
            var dataService          = new Mock <IDataService>();
            var establishmentService = new Mock <IEstablishmentService>();

            dataService.Setup(x => x.GetAnswerPotentials(It.IsAny <string>())).Returns(new List <AnswerPotential>());
            var admittedFromAbroadRules = new RemovePupilAdmittedFromAbroadRule(dataService.Object, null, establishmentService.Object);

            var outcome = admittedFromAbroadRules.Apply(new Amendment
            {
                URN = "100987"
            });

            Assert.True(outcome.IsComplete == false);
            Assert.True(outcome.FurtherQuestions != null);
            Assert.True(outcome.FurtherQuestions.Count == 3);
        }
        public void ItShouldShowErrorIfAnswerIsNotEntered()
        {
            var dataService          = new Mock <IDataService>();
            var establishmentService = new Mock <IEstablishmentService>();

            dataService.Setup(x => x.GetAnswerPotentials(It.IsAny <string>())).Returns(new List <AnswerPotential>());
            var admittedFromAbroadRules = new RemovePupilAdmittedFromAbroadRule(dataService.Object, null, establishmentService.Object);

            var outcome = admittedFromAbroadRules.Apply(new Amendment()
            {
                URN     = "100987",
                Answers = new List <UserAnswer>
                {
                    new UserAnswer {
                        Value = "", QuestionId = nameof(PupilCountryQuestion)
                    }
                }
            });

            Assert.True(outcome.ValidationErrors.Count == 1);
            Assert.True(outcome.ValidationErrors.First().Key == nameof(PupilCountryQuestion));
            Assert.True(outcome.IsComplete == false);
        }
        public void ItShouldShowErrorIfDateIsNotHistorical()
        {
            var dataService          = new Mock <IDataService>();
            var establishmentService = new Mock <IEstablishmentService>();

            dataService.Setup(x => x.GetAnswerPotentials(It.IsAny <string>())).Returns(new List <AnswerPotential>());
            var admittedFromAbroadRules = new RemovePupilAdmittedFromAbroadRule(dataService.Object, null, establishmentService.Object);

            var outcome = admittedFromAbroadRules.Apply(new Amendment()
            {
                URN     = "100987",
                Answers = new List <UserAnswer>
                {
                    new UserAnswer {
                        Value = DateTime.Now.AddDays(1).ToString("dd/MM/yyyy"), QuestionId = "ArrivalDateQuestion"
                    }
                }
            });

            Assert.True(outcome.ValidationErrors.Count == 1);
            Assert.True(outcome.ValidationErrors.First().Key == nameof(ArrivalDateQuestion));
            Assert.True(outcome.IsComplete == false);
        }
        public void ItShouldShowErrorIfAnswerIsNull()
        {
            var dataService          = new Mock <IDataService>();
            var establishmentService = new Mock <IEstablishmentService>();

            dataService.Setup(x => x.GetAnswerPotentials(It.IsAny <string>())).Returns(new List <AnswerPotential>());
            var admittedFromAbroadRules = new RemovePupilAdmittedFromAbroadRule(dataService.Object, null, establishmentService.Object);

            var outcome = admittedFromAbroadRules.Apply(new Amendment()
            {
                URN     = "100987",
                Answers = new List <UserAnswer>
                {
                    new UserAnswer {
                        Value = string.Empty, QuestionId = "PupilNativeLanguageQuestion"
                    },
                    new UserAnswer {
                        Value = string.Empty, QuestionId = "PupilNativeLanguageQuestion.Other"
                    },
                    new UserAnswer {
                        Value = string.Empty, QuestionId = "PupilCountryQuestion"
                    },
                    new UserAnswer {
                        Value = string.Empty, QuestionId = "PupilCountryQuestion.Other"
                    },
                    new UserAnswer {
                        Value = string.Empty, QuestionId = "ArrivalDateQuestion"
                    },
                    new UserAnswer {
                        Value = string.Empty, QuestionId = "PupilDateOnRollQuestion"
                    }
                }
            });

            Assert.True(outcome.ValidationErrors.Count == 4);
            Assert.True(outcome.IsComplete == false);
        }