public async Task Should_not_add_error_if_schemas_is_null()
        {
            var trigger = new ContentChangedTriggerV2();

            var errors = await RuleTriggerValidator.ValidateAsync(appId.Id, trigger, appProvider);

            Assert.Empty(errors);
        }
Example #2
0
        public async Task Should_not_add_error_if_num_days_is_not_defined()
        {
            var trigger = new UsageTrigger();

            var errors = await RuleTriggerValidator.ValidateAsync(appId, trigger, appProvider);

            Assert.Empty(errors);
        }
        public async Task Should_not_add_error_if_schemas_is_empty()
        {
            var trigger = new ContentChangedTriggerV2
            {
                Schemas = ReadOnlyCollection.Empty <ContentChangedTriggerSchemaV2>()
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId.Id, trigger, appProvider);

            Assert.Empty(errors);
        }
        public async Task Should_not_add_error_if_schemas_is_empty()
        {
            var trigger = new ContentChangedTrigger
            {
                Schemas = ImmutableList <ContentChangedTriggerSchema> .Empty
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId, trigger, appProvider);

            Assert.Empty(errors);
        }
        public async Task Should_not_add_error_if_schemas_is_empty()
        {
            var trigger = new ContentChangedTrigger
            {
                Schemas = new List <ContentChangedTriggerSchema>()
            };

            var errors = await RuleTriggerValidator.ValidateAsync(trigger, schemas);

            Assert.Empty(errors);
        }
Example #6
0
        public async Task Should_add_error_if_num_days_greater_than_30()
        {
            var trigger = new UsageTrigger {
                NumDays = 32
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId, trigger, appProvider);

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Num days must be between 1 and 30.", "NumDays")
            });
        }
        public async Task Should_not_add_error_if_schemas_ids_are_valid()
        {
            A.CallTo(() => appProvider.GetSchemaAsync(appId.Id, A <DomainId> ._, false, false))
            .Returns(Mocks.Schema(appId, schemaId));

            var trigger = new ContentChangedTriggerV2
            {
                Schemas = ReadOnlyCollection.Create(new ContentChangedTriggerSchemaV2 {
                    SchemaId = schemaId.Id
                })
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId.Id, trigger, appProvider);

            Assert.Empty(errors);
        }
        public async Task Should_not_add_error_if_schemas_ids_are_valid()
        {
            A.CallTo(() => appProvider.GetSchemaAsync(appId, A <Guid> .Ignored, false))
            .Returns(A.Fake <ISchemaEntity>());

            var trigger = new ContentChangedTrigger
            {
                Schemas = ImmutableList.Create(
                    new ContentChangedTriggerSchema()
                    )
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId, trigger, appProvider);

            Assert.Empty(errors);
        }
        public async Task Should_add_error_if_schemas_ids_are_not_valid()
        {
            A.CallTo(() => appProvider.GetSchemaAsync(appId, A <Guid> .Ignored, false))
            .Returns(Task.FromResult <ISchemaEntity>(null));

            var trigger = new ContentChangedTrigger
            {
                Schemas = ReadOnlyCollection.Create(
                    new ContentChangedTriggerSchema()
                    )
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId, trigger, appProvider);

            Assert.NotEmpty(errors);
        }
        public async Task Should_not_add_error_if_schemas_ids_are_valid()
        {
            A.CallTo(() => schemas.FindSchemaByIdAsync(A <Guid> .Ignored, false))
            .Returns(A.Fake <ISchemaEntity>());

            var trigger = new ContentChangedTrigger
            {
                Schemas = new List <ContentChangedTriggerSchema>
                {
                    new ContentChangedTriggerSchema()
                }
            };

            var errors = await RuleTriggerValidator.ValidateAsync(trigger, schemas);

            Assert.Empty(errors);
        }
        public async Task Should_add_error_if_schema_id_is_not_defined()
        {
            var trigger = new ContentChangedTriggerV2
            {
                Schemas = ReadOnlyCollection.Create(new ContentChangedTriggerSchemaV2())
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId.Id, trigger, appProvider);

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Schema id is required.", "Schemas")
            });

            A.CallTo(() => appProvider.GetSchemaAsync(appId.Id, A <DomainId> ._, false, false))
            .MustNotHaveHappened();
        }
        public async Task Should_add_error_if_schemas_ids_are_not_valid()
        {
            A.CallTo(() => appProvider.GetSchemaAsync(appId.Id, schemaId.Id, false, false))
            .Returns(Task.FromResult <ISchemaEntity?>(null));

            var trigger = new ContentChangedTriggerV2
            {
                Schemas = ReadOnlyCollection.Create(new ContentChangedTriggerSchemaV2 {
                    SchemaId = schemaId.Id
                })
            };

            var errors = await RuleTriggerValidator.ValidateAsync(appId.Id, trigger, appProvider);

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError($"Schema {schemaId.Id} does not exist.", "Schemas")
            });
        }