public void Envelope_attributes_should_be_present() { var dateTime = DateTime.UtcNow; var time = RoundToMs(dateTime); var builder = new EnvelopeBuilder("my-id"); builder.OverrideCreatedOnUtc(time); builder.AddString("Custom", "1"); var envelope = RoundtripViaSerializer(builder); Assert.AreEqual("1", envelope.GetAttribute("Custom")); Assert.GreaterOrEqual(RoundToMs(envelope.CreatedOnUtc), time, "start time"); var now = RoundToMs(dateTime); Assert.LessOrEqual(RoundToMs(envelope.CreatedOnUtc), now, "now"); }
public void Envelope_attributes_should_be_present() { var dateTime = DateTime.UtcNow; var time = RoundToMs(dateTime); var builder = new EnvelopeBuilder("my-id"); builder.OverrideCreatedOnUtc(time); builder.AddString("Custom", "1"); var envelope = RoundtripViaSerializer(builder); Assert.AreEqual("1", envelope.GetAttribute("Custom")); Assert.GreaterOrEqual(RoundToMs(envelope.CreatedOnUtc), time, "start time"); var now = RoundToMs(dateTime); Assert.LessOrEqual(RoundToMs(envelope.CreatedOnUtc), now, "now"); }
string HashContents(Action <EnvelopeBuilder> configure, object[] messageItems) { var builder = new EnvelopeBuilder("hash"); builder.OverrideCreatedOnUtc(DateTime.MinValue); foreach (var item in messageItems) { builder.AddItem(item); } configure(builder); var envelope = builder.Build(); var data = _streamer.SaveEnvelopeData(envelope); using (var sha1 = new SHA1Managed()) { var hash = sha1.ComputeHash(data); return(BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant()); } }
string HashContents(Action<EnvelopeBuilder> configure, object[] messageItems) { var builder = new EnvelopeBuilder("hash"); builder.OverrideCreatedOnUtc(DateTime.MinValue); foreach (var item in messageItems) { builder.AddItem(item); } configure(builder); var envelope = builder.Build(); var data = _streamer.SaveEnvelopeData(envelope); using (var sha1 = new SHA1Managed()) { var hash = sha1.ComputeHash(data); return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); } }