コード例 #1
0
        public async Task Then_Invalid_If_Not_Valid_Email(
            CreateCourseDemandCommand command,
            CreateCourseDemandCommandValidator validator)
        {
            command.CourseDemand.ContactEmailAddress = "test";

            var actual = await validator.ValidateAsync(command);

            actual.IsValid().Should().BeFalse();
        }
コード例 #2
0
        public async Task Then_Command_Is_Valid_If_All_Properties_Supplied(
            CreateCourseDemandCommand command,
            CreateCourseDemandCommandValidator validator)
        {
            command.CourseDemand.ContactEmailAddress = "*****@*****.**";

            var actual = await validator.ValidateAsync(command);

            actual.IsValid().Should().BeTrue();
        }
コード例 #3
0
        public async Task Then_Invalid_If_No_Organisation_Name(
            CreateCourseDemandCommand command,
            CreateCourseDemandCommandValidator validator)
        {
            command.CourseDemand.OrganisationName    = "";
            command.CourseDemand.ContactEmailAddress = "*****@*****.**";

            var actual = await validator.ValidateAsync(command);

            actual.IsValid().Should().BeFalse();
        }
コード例 #4
0
        public async Task Then_Invalid_If_No_Location(
            CreateCourseDemandCommand command,
            CreateCourseDemandCommandValidator validator)
        {
            command.CourseDemand.Location            = new Location();
            command.CourseDemand.ContactEmailAddress = "*****@*****.**";

            var actual = await validator.ValidateAsync(command);

            actual.IsValid().Should().BeFalse();
        }
コード例 #5
0
        public async Task Then_If_All_Fields_Are_Present_The_Command_Is_Valid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.ContactEmailAddress      = $"{command.ContactEmailAddress}@test.com";
            command.NumberOfApprenticesKnown = false;
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeTrue();
        }
コード例 #6
0
        public async Task Then_If_There_Is_Not_A_Valid_ContactEmailAddress_It_Is_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.ContactEmailAddress));
            actual.ValidationDictionary[nameof(command.ContactEmailAddress)].Should()
            .Be("Enter an email address in the correct format, like [email protected]");
        }
コード例 #7
0
        public async Task Then_If_There_Is_No_TrainingCourseId_It_Is_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.TrainingCourseId    = 0;
            command.ContactEmailAddress = $"{command.ContactEmailAddress}@test.com";
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.TrainingCourseId));
        }
コード例 #8
0
        public async Task Then_If_There_Is_No_Value_For_NumberOfApprenticesKnown_Then_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.NumberOfApprenticesKnown = null;
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.NumberOfApprenticesKnown));
            actual.ValidationDictionary[nameof(command.NumberOfApprenticesKnown)].Should()
            .Be("Select yes if you know how many apprentices will take this apprenticeship training");
        }
コード例 #9
0
        public async Task Then_If_There_Is_No_ContactEmailAddress_It_Is_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.ContactEmailAddress = string.Empty;
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.ContactEmailAddress));
            actual.ValidationDictionary[nameof(command.ContactEmailAddress)].Should()
            .Be("Enter an email address");
        }
コード例 #10
0
        public async Task Then_Invalid_If_No_Course_Title(
            CreateCourseDemandCommand command,
            CreateCourseDemandCommandValidator validator)
        {
            command.CourseDemand.Course = new Course
            {
                Id    = 1,
                Level = 1,
                Route = "test route"
            };
            command.CourseDemand.ContactEmailAddress = "*****@*****.**";

            var actual = await validator.ValidateAsync(command);

            actual.IsValid().Should().BeFalse();
        }
コード例 #11
0
        public async Task Then_If_There_Is_No_OrganisationName_It_Is_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.OrganisationName    = string.Empty;
            command.ContactEmailAddress = $"{command.ContactEmailAddress}@test.com";
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.OrganisationName));
            actual.ValidationDictionary[nameof(command.OrganisationName)].Should()
            .Be("Enter the name of the organisation");
        }
コード例 #12
0
        public async Task Then_If_No_Address_Marked_As_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.Location            = string.Empty;
            command.ContactEmailAddress = $"{command.ContactEmailAddress}@test.com";
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.Location));
            actual.ValidationDictionary[nameof(command.Location)].Should()
            .Be("Enter a town, city or postcode");
        }
コード例 #13
0
        public async Task Then_If_The_NumberOfApprenticesIsKnown_Is_True_Then_The_Number_Of_Apprentices_Is_Null_Then_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.NumberOfApprenticesKnown = true;
            command.NumberOfApprentices      = null;
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.NumberOfApprentices));
            actual.ValidationDictionary[nameof(command.NumberOfApprentices)].Should()
            .Be("Enter the number of apprentices");
        }
コード例 #14
0
        public async Task Then_If_The_NumberOfApprenticesIsKnown_Is_True_And_The_Number_Of_Apprentices_Is_Not_An_Int_Then_Invalid(CreateCachedCourseDemandCommand command)
        {
            //Arrange
            command.NumberOfApprenticesKnown = true;
            command.NumberOfApprentices      = $"{long.MaxValue}";
            var validator = new CreateCourseDemandCommandValidator();

            //Act
            var actual = await validator.ValidateAsync(command);

            //Assert
            actual.IsValid().Should().BeFalse();
            actual.ValidationDictionary.Should().ContainKey(nameof(command.NumberOfApprentices));
            actual.ValidationDictionary[nameof(command.NumberOfApprentices)].Should()
            .Be("Number of apprentices must be 9999 or less");
        }