public void Class_IsJsonSerializable() { var serviceCase = new ServiceCase( ServiceCase.SampleContent.Title, ServiceCase.SampleContent.Description, ServiceCase.Priority.Normal, ServiceCase.SampleContent.ResponsibleParty); var thread = serviceCase.StartCommunicationThread( ServiceCase.SampleContent.Topic, ServiceCase.SampleContent.TopicDescription, ServiceCase.SampleContent.ResponsibleParty); thread.RecordCommunication( CommunicationDirection.Incoming, ServiceCase.SampleContent.CommunicationContent, SystemClock.UtcNow, ServiceCase.SampleContent.CommunicationDuration, ServiceCase.SampleContent.ResponsibleParty); var memento = new AggregateMemento<ServiceCaseId>( typeof (ServiceCase), serviceCase.TakeSnapshot().ToMaybe(), serviceCase.GetEvents()); var serializer = JsonSerializerBuilder.Build(LogicalTypeRegistryBuilder.Build()); String json = serializer.Serialize(memento); var reconstituted = serializer.Deserialize<AggregateMemento<ServiceCaseId>>(json); reconstituted.Should().NotBeNull(); reconstituted.Should().NotBeSameAs(memento); }
public void UncommittedEventsRetreivable() { var serviceCase = new ServiceCase(ServiceCase.SampleContent.Title, ServiceCase.SampleContent.Description, ServiceCase.Priority.Normal, ServiceCase.SampleContent.ResponsibleParty); var thread = serviceCase.StartCommunicationThread(ServiceCase.SampleContent.Topic, ServiceCase.SampleContent.TopicDescription, ServiceCase.SampleContent.ResponsibleParty); thread.RecordCommunication(CommunicationDirection.Incoming, ServiceCase.SampleContent.CommunicationContent, SystemClock.UtcNow, ServiceCase.SampleContent.CommunicationDuration, ServiceCase.SampleContent.ResponsibleParty); serviceCase.GetEvents().Count().Should().Be(3); serviceCase.GetEvents() .Select(x => x.GetType()) .SequenceEqual(new[] { typeof (ServiceCase.Opened), typeof (ServiceCase.CommunicationThreadStarted), typeof (ServiceCase.CommunicationRecorded) }) .Should().BeTrue(); }