public void Source_Empty_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': ''
}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
        public void Id_Guid_Success()
        {
            var json = @"
{
  'id': '00717CE8-D29E-4C2E-84D4-A9E026575778',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext'
}
";
            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeTrue();
        }
        public void Source_Invalid_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '`~!@#$%^&*()-_=+[{]};:'"",<.>/?'
}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
        public void Basic_Success()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext'
}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeTrue();
        }
        public void Source_FullUri_Success()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': 'https://example.com/foo'
}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeTrue();
        }
        public void SpecVersion_Incorrect_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.1',
  'source': '/mycontext'
}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
        public void ContentType_Invalid_Fail(string contentType)
        {
            var json = $@"
{{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'contenttype': '{contentType}'
}}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
        public void Time_NoTimeZone_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'time': '2019-04-13T15:07:00.2031033'
}";

            var validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
Beispiel #9
0
        public void Type_Empty_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': '',
  'specversion': '0.2',
  'source': '/mycontext'
}";

            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
Beispiel #10
0
        public void Data_String_Basic_Success()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'data': 'This is some text...'
}";

            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeTrue();
        }
Beispiel #11
0
        public void Id_None_Fail()
        {
            var json = @"
{
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext'
}
";
            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
Beispiel #12
0
        public void ContentType_Invalid_Fail(string contentType)
        {
            var json = $@"
{{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'contenttype': '{contentType}'
}}";

            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
Beispiel #13
0
        public void Id_Guid_Success()
        {
            var json = @"
{
  'id': '00717CE8-D29E-4C2E-84D4-A9E026575778',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext'
}
";
            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeTrue();
        }
Beispiel #14
0
        public void SchemaUrl_Invalid_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'schemaurl': '`~!@#$%^&*()-_=+[{]};:'"",<.>/?'
}";

            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }
Beispiel #15
0
        public void SchemaUrl_FullUri_Success()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'schemaurl': 'https://example.com/foo'
}";

            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeTrue();
        }
Beispiel #16
0
        public void Time_NoTimeZone_Fail()
        {
            var json = @"
{
  'id': 'C234-1234-1234',
  'type': 'com.example.someevent',
  'specversion': '0.2',
  'source': '/mycontext',
  'time': '2019-04-13T15:07:00.2031033'
}";

            Tuple <bool, System.Collections.Generic.IReadOnlyList <string> > validationResults = CloudEventV0_2.ValidateJsonDetailed(json);

            validationResults.Item1.Should().BeFalse();
        }