public void Serializer_can_serialize_and_deserialize_polymorphic_types() { var withType = new ExecutionOptions(DateTime.MaxValue, typeof(ScheduledCommandSuccessfullyProcessed), Guid.NewGuid().ToString(), TimeSpan.FromMinutes(1)); var serializer = new DomainSerializer(); var bytes = serializer.ToBinary(withType); var deserialized = (ExecutionOptions)serializer.FromBinary(bytes, typeof(ExecutionOptions)); Assert.True(deserialized.SuccesEventType == withType.SuccesEventType); }
public void Test() { _original = (SampleDomainEvent) new SampleDomainEvent(1223, Guid.NewGuid().ToString()).CloneForProcess(Guid.NewGuid().ToString()); var ser = new DomainSerializer(); var bytes = ser.ToBinary(_original); _restored = (SampleDomainEvent)ser.FromBinary(bytes, typeof(SampleDomainEvent)); //processId_should_be_equal() Assert.Equal(_original.ProcessId, _restored.ProcessId); //CreatedTime_should_be_equal() Assert.Equal(_original.CreatedTime, _restored.CreatedTime); //SourceId_should_be_equal() Assert.Equal(_original.SourceId, _restored.SourceId); //Parameter_should_be_equal() Assert.Equal(_original.Parameter, _restored.Parameter); }
//Event order matter!! public async Task Save(string id, params DomainEvent[] messages) { long counter = 0; var journalEntries = messages.Select( m => new JournalItem(id, ++counter, false, m.GetType().AssemblyQualifiedShortName(), m.CreatedTime, "", _serializer.ToBinary(m))); await _rawDataRepo.Save(id, journalEntries.ToArray()); }