Ejemplo n.º 1
0
        public async Task ValidateSectionAsync_DuplicateSectionRecipients_Error()
        {
            var database = GetDatabase().Build();
            var adminId  = database.Context
                           .ClassroomMemberships
                           .Single(cm => cm.User.UserName == "Admin1")
                           .Id;

            var errors    = new MockErrorCollection();
            var validator = new SectionValidator(database.Context);

            var section = new Section()
            {
                SectionRecipients = Collections.CreateList
                                    (
                    new SectionRecipient()
                {
                    ClassroomMembershipId = adminId,
                },
                    new SectionRecipient()
                {
                    ClassroomMembershipId = adminId,
                }
                                    )
            };

            var result = await validator.ValidateSectionAsync(section, errors);

            Assert.False(result);
            Assert.True(errors.VerifyErrors("SectionRecipients"));
        }
Ejemplo n.º 2
0
        public async Task ValidateSectionAsync_DuplicateSectionGradebooks_Error()
        {
            var database             = GetDatabase().Build();
            var classroomGradebookId = database.Context
                                       .ClassroomGradebooks
                                       .First()
                                       .Id;

            var errors    = new MockErrorCollection();
            var validator = new SectionValidator(database.Context);

            var section = new Section()
            {
                SectionGradebooks = Collections.CreateList
                                    (
                    new SectionGradebook()
                {
                    ClassroomGradebookId = classroomGradebookId,
                },
                    new SectionGradebook()
                {
                    ClassroomGradebookId = classroomGradebookId,
                }
                                    )
            };

            var result = await validator.ValidateSectionAsync(section, errors);

            Assert.False(result);
            Assert.True(errors.VerifyErrors("SectionGradebooks"));
        }