<commit_before>﻿using System.Linq;

using NUnit.Framework;
using SFA.DAS.EAS.Web.Models;
using SFA.DAS.EAS.Web.Validators;

namespace SFA.DAS.EAS.Web.UnitTests.Validators
{
    [TestFixture]
    public sealed class WhenValidatingApprenticeshipViewModel
    {
        private ApprenticeshipViewModelValidator _validator = new ApprenticeshipViewModelValidator();

        [Test]
        public void ULNMustBeNumericAnd10DigitsInLength()
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", ULN = "1001234567" };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.True);
        }

        [TestCase("abc123")]
        [TestCase("123456789")]
        [TestCase(" ")]
        public void ULNThatIsNotNumericOr10DigitsInLengthIsIvalid(string uln)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", ULN = uln };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        public void ULNThatStartsWithAZeroIsInvalid()
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", ULN = "0123456789" };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        [TestCase("123")]
        [TestCase("1")]
        public void CostIsWholeNumberGreaterThanZeroIsValid(string cost)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", Cost = cost };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.True);
        }

        [TestCase("123.12")]
        [TestCase("123.1")]
        [TestCase("123.0")]
        [TestCase("fdsfdfd")]
        [TestCase("123.000")]
        public void CostNotNumericOrIsNotAWholeNumber(string cost)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", Cost = cost };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        [TestCase("0")]
        [TestCase("-0")]
        [TestCase("-123.12")]
        [TestCase("-123")]
        [TestCase("-123.1232")]
        [TestCase("-0.001")]
        public void CostThatIsZeroOrNegativeNumberIsInvalid(string cost)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", Cost = cost };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        [Test]
        public void FirstAndLastNameIsEmpty()
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "", LastName = "" };

            var result = _validator.Validate(viewModel);

            Assert.That(result.Errors.Any(m => m.ErrorMessage.Contains("Please enter first name")), Is.True);
            Assert.That(result.Errors.Any(m => m.ErrorMessage.Contains("Please enter last name")), Is.True);
            Assert.That(result.IsValid, Is.False);
        }<commit_msg>Fixed broken unit test<commit_after>﻿using System.Linq;

using NUnit.Framework;
using SFA.DAS.EAS.Web.Models;
using SFA.DAS.EAS.Web.Validators;

namespace SFA.DAS.EAS.Web.UnitTests.Validators
{
    [TestFixture]
    public sealed class WhenValidatingApprenticeshipViewModel
    {
        private ApprenticeshipViewModelValidator _validator = new ApprenticeshipViewModelValidator();

        [Test]
        public void ULNMustBeNumericAnd10DigitsInLength()
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", ULN = "1001234567" };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.True);
        }

        [TestCase("abc123")]
        [TestCase("123456789")]
        [TestCase(" ")]
        public void ULNThatIsNotNumericOr10DigitsInLengthIsIvalid(string uln)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", ULN = uln };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        public void ULNThatStartsWithAZeroIsInvalid()
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", ULN = "0123456789" };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        [TestCase("123")]
        [TestCase("1")]
        public void CostIsWholeNumberGreaterThanZeroIsValid(string cost)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", Cost = cost };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.True);
        }

        [TestCase("123.12")]
        [TestCase("123.1")]
        [TestCase("123.0")]
        [TestCase("fdsfdfd")]
        [TestCase("123.000")]
        public void CostNotNumericOrIsNotAWholeNumber(string cost)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", Cost = cost };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        [TestCase("0")]
        [TestCase("-0")]
        [TestCase("-123.12")]
        [TestCase("-123")]
        [TestCase("-123.1232")]
        [TestCase("-0.001")]
        public void CostThatIsZeroOrNegativeNumberIsInvalid(string cost)
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "FirstName", LastName = "LastName", Cost = cost };

            var result = _validator.Validate(viewModel);

            Assert.That(result.IsValid, Is.False);
        }

        [Test]
        public void FirstAndLastNameIsEmpty()
        {
            var viewModel = new ApprenticeshipViewModel { FirstName = "", LastName = "" };

            var result = _validator.Validate(viewModel);

            Assert.That(result.Errors.Any(m => m.ErrorMessage.Contains("Enter a first name")), Is.True);
            Assert.That(result.Errors.Any(m => m.ErrorMessage.Contains("Enter a last name")), Is.True);
            Assert.That(result.IsValid, Is.False);
        }
{'fraction_non_alphanumeric': 0.11777334764606655, 'fraction_numerical': 0.024536114092930533, 'mean_word_length': 2.450793650793651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5457528', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1846, 'n_words': 355}