public void Id_None_Fail() { var json = @" { 'type': 'com.example.someevent', 'specversion': '0.2', 'source': '/mycontext' } "; var validationResults = CloudEventV0_2.ValidateJsonDetailed(json); validationResults.Item1.Should().BeFalse(); }
public void Source_None_Fail() { var json = @" { 'id': 'C234-1234-1234', 'type': 'com.example.someevent', 'specversion': '0.2' }"; var validationResults = CloudEventV0_2.ValidateJsonDetailed(json); validationResults.Item1.Should().BeFalse(); }
public void Type_None_Fail() { var json = @" { 'id': 'C234-1234-1234', 'specversion': '0.2', 'source': '/mycontext' }"; var validationResults = CloudEventV0_2.ValidateJsonDetailed(json); validationResults.Item1.Should().BeFalse(); }
public void BinaryEvent_LargeData_Success(string fileName, string contentType) { var data = File.ReadAllBytes($@"./V02Tests/samples/binary/{fileName}"); BinaryCloudEventV0_2 evnt = CloudEventV0_2.CreateCloudEvent("test", new Uri("/", UriKind.RelativeOrAbsolute), data, contentType, null); evnt.Should().NotBeNull(); evnt.Should().BeOfType <BinaryCloudEventV0_2>(); evnt.ContentType.Should().Be(contentType); evnt.Data.Length.Should().Be(data.Length); var json = JsonConvert.SerializeObject(evnt, Formatting.Indented); }
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 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 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 Data_String_Empty_Fail() { var json = @" { 'id': 'C234-1234-1234', 'type': 'com.example.someevent', 'specversion': '0.2', 'source': '/mycontext', 'data': '' }"; 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(); }
public void BinaryEvent_ContainsData_Success(string data) { BinaryCloudEventV0_2 evnt = CloudEventV0_2.CreateCloudEvent("test", new Uri("/", UriKind.RelativeOrAbsolute), Encoding.UTF8.GetBytes(data)); CloudEventV0_2 newEvnt = JsonConvert.DeserializeObject <CloudEventV0_2>(JsonConvert.SerializeObject(evnt)); newEvnt.Should().NotBeNull(); newEvnt.Should().BeOfType <BinaryCloudEventV0_2>(); var jobj = JObject.FromObject(newEvnt); // Can explicitly deserialize to binary BinaryCloudEventV0_2 evnt2 = jobj.ToObject <BinaryCloudEventV0_2>(); evnt2.Should().NotBeNull(); evnt2.Data.Should().NotBeNull(); // Without a type provided this should deserialize to a binary event var evnt3 = CloudEventV0_2.Deserialize(jobj.ToString()); evnt3.Should().NotBeNull(); evnt3.Should().BeOfType <BinaryCloudEventV0_2>(); }
public void BinaryEvent_NoData_Success() { var evnt = CloudEventV0_2.CreateCloudEvent("test", new Uri("/", UriKind.RelativeOrAbsolute), (byte[])null); evnt.Should().NotBeNull(); evnt.Should().BeOfType <BinaryCloudEventV0_2>(); var jobj = JObject.FromObject(evnt); // // Can explicitly deserialize to binary even without data present var evnt2 = jobj.ToObject <BinaryCloudEventV0_2>(); evnt2.Should().NotBeNull(); evnt2.Data.Should().BeNull(); // // Without a type provided this should deserialize to a generic event var evnt3 = CloudEventV0_2.Deserialize(jobj.ToString()); evnt3.Should().NotBeNull(); evnt3.Should().BeOfType <CloudEventV0_2>(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }