<commit_before>﻿using System;
using Moq;
using NUnit.Framework;
using SFA.DAS.ProviderApprenticeshipsService.Domain.Interfaces;
using SFA.DAS.ProviderApprenticeshipsService.Infrastructure.Services;
using SFA.DAS.ProviderApprenticeshipsService.Web.Models;
using SFA.DAS.ProviderApprenticeshipsService.Web.Models.BulkUpload;
using SFA.DAS.ProviderApprenticeshipsService.Web.Models.Types;
using SFA.DAS.ProviderApprenticeshipsService.Web.Orchestrators.BulkUpload;
using SFA.DAS.ProviderApprenticeshipsService.Web.Validation;
using SFA.DAS.ProviderApprenticeshipsService.Web.Validation.Text;
using SFA.DAS.Learners.Validators;

namespace SFA.DAS.ProviderApprenticeshipsService.Web.UnitTests.Validation.ApprenticeshipBulkUpload
{
    public abstract class ApprenticeshipBulkUploadValidationTestBase
    {
        protected ApprenticeshipUploadModelValidator Validator;
        protected ApprenticeshipUploadModel ValidModel;
        protected Mock<ICurrentDateTime> MockCurrentDateTime;
        protected Mock<IUlnValidator> MockUlnValidator;
        protected Mock<IAcademicYearDateProvider> MockAcademicYear;
        protected Mock<IAcademicYearValidator> MockAcademicYearValidator;

        [SetUp]
        public void BaseSetup()
        {
            MockCurrentDateTime = new Mock<ICurrentDateTime>();
            MockUlnValidator = new Mock<IUlnValidator>();
            MockAcademicYear = new Mock<IAcademicYearDateProvider>();
            MockAcademicYearValidator = new Mock<IAcademicYearValidator>();

            Validator = new ApprenticeshipUploadModelValidator(new BulkUploadApprenticeshipValidationText(MockAcademicYear.Object), MockCurrentDateTime.Object, MockUlnValidator.Object);

            ValidModel = new ApprenticeshipUploadModel
            {
                ApprenticeshipViewModel = new ApprenticeshipViewModel
                {
                    ULN = "1001234567",
                    FirstName = "TestFirstName",
                    LastName = "TestLastName",
                    TrainingCode = "12",
                    DateOfBirth = new DateTimeViewModel(DateTime.UtcNow.AddYears(-16)),
                    StartDate = new DateTimeViewModel(new DateTime(2017, 06, 20)),
                    EndDate = new DateTimeViewModel(new DateTime(2018, 05, 15)),
                    Cost = "1234"
                },
                CsvRecord = new CsvRecord { CohortRef = "abba123", ProgType = "25", StdCode = "123" }
            };
        }
    }
}<commit_msg>Fixes date-sensitive test (sets sample valid apprentice to be 18, not 16)<commit_after>﻿using System;
using Moq;
using NUnit.Framework;
using SFA.DAS.ProviderApprenticeshipsService.Domain.Interfaces;
using SFA.DAS.ProviderApprenticeshipsService.Infrastructure.Services;
using SFA.DAS.ProviderApprenticeshipsService.Web.Models;
using SFA.DAS.ProviderApprenticeshipsService.Web.Models.BulkUpload;
using SFA.DAS.ProviderApprenticeshipsService.Web.Models.Types;
using SFA.DAS.ProviderApprenticeshipsService.Web.Orchestrators.BulkUpload;
using SFA.DAS.ProviderApprenticeshipsService.Web.Validation;
using SFA.DAS.ProviderApprenticeshipsService.Web.Validation.Text;
using SFA.DAS.Learners.Validators;

namespace SFA.DAS.ProviderApprenticeshipsService.Web.UnitTests.Validation.ApprenticeshipBulkUpload
{
    public abstract class ApprenticeshipBulkUploadValidationTestBase
    {
        protected ApprenticeshipUploadModelValidator Validator;
        protected ApprenticeshipUploadModel ValidModel;
        protected Mock<ICurrentDateTime> MockCurrentDateTime;
        protected Mock<IUlnValidator> MockUlnValidator;
        protected Mock<IAcademicYearDateProvider> MockAcademicYear;
        protected Mock<IAcademicYearValidator> MockAcademicYearValidator;

        [SetUp]
        public void BaseSetup()
        {
            MockCurrentDateTime = new Mock<ICurrentDateTime>();
            MockUlnValidator = new Mock<IUlnValidator>();
            MockAcademicYear = new Mock<IAcademicYearDateProvider>();
            MockAcademicYearValidator = new Mock<IAcademicYearValidator>();

            Validator = new ApprenticeshipUploadModelValidator(new BulkUploadApprenticeshipValidationText(MockAcademicYear.Object), MockCurrentDateTime.Object, MockUlnValidator.Object);

            ValidModel = new ApprenticeshipUploadModel
            {
                ApprenticeshipViewModel = new ApprenticeshipViewModel
                {
                    ULN = "1001234567",
                    FirstName = "TestFirstName",
                    LastName = "TestLastName",
                    TrainingCode = "12",
                    DateOfBirth = new DateTimeViewModel(DateTime.UtcNow.AddYears(-18)),
                    StartDate = new DateTimeViewModel(new DateTime(2017, 06, 20)),
                    EndDate = new DateTimeViewModel(new DateTime(2018, 05, 15)),
                    Cost = "1234"
                },
                CsvRecord = new CsvRecord { CohortRef = "abba123", ProgType = "25", StdCode = "123" }
            };
        }
    }
}
{'fraction_non_alphanumeric': 0.0752988047808765, 'fraction_numerical': 0.01752988047808765, 'mean_word_length': 3.085435313262815, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '426275', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1322, 'n_words': 231}