public void SequencesOfSequencesAreFormatted() { var s = new SequenceValue(new[] { new SequenceValue(new[] { new ScalarValue("Hello") }) }); var f = Format(s); Assert.Equal("[[\"Hello\"]]", f); }
public void ASequencePropertySerializesAsArrayValue() { var name = Some.String(); var ints = new[]{ Some.Int(), Some.Int() }; var value = new SequenceValue(ints.Select(i => new ScalarValue(i))); var @event = Some.LogEvent(); @event.AddOrUpdateProperty(new LogEventProperty(name, value)); var formatted = FormatJson(@event); var result = new List<int>(); foreach (var el in formatted.Properties[name]) result.Add((int)el); CollectionAssert.AreEqual(ints, result); }
public void CreateEntityWithPropertiesShouldSupportAzureTableTypesForSequence() { var messageTemplate = "{Sequence}"; var sequence1 = new SequenceValue(new List<LogEventPropertyValue> { new ScalarValue(1), new ScalarValue(2), new ScalarValue(3), new ScalarValue(4), new ScalarValue(5) }); var sequence2 = new SequenceValue(new List<LogEventPropertyValue> { new ScalarValue("a"), new ScalarValue("b"), new ScalarValue("c"), new ScalarValue("d"), new ScalarValue("e") }); var sequence0 = new SequenceValue(new List<LogEventPropertyValue> { sequence1, sequence2 }); var properties = new List<LogEventProperty> { new LogEventProperty("Sequence", sequence0) }; var template = new MessageTemplateParser().Parse(messageTemplate); var logEvent = new Events.LogEvent(DateTime.Now, LogEventLevel.Information, null, template, properties); var entity = AzureTableStorageEntityFactory.CreateEntityWithProperties(logEvent, null, null); Assert.AreEqual(3 + properties.Count, entity.Properties.Count); Assert.AreEqual("[[1, 2, 3, 4, 5], [\"a\", \"b\", \"c\", \"d\", \"e\"]]", entity.Properties["Sequence"].StringValue); }