public void serializer_test()
 {
     var events = new List<object>();
     for(var i = 1; i< 1000000;i++)
     {
         object @event = null;
         if(i % 1 == 0)
         {
             @event = new Deposit {AccountId = "test", Amount = i, At = DateTime.Now};
         }else
         {
             @event = new WithDraw {AccountId = "test", Amount = i, At = DateTime.Now};
         }
         events.Add(@event);
     }
     var msJsonSerializer = new JsonSerializer();
     ShowTimeItTakes(events,msJsonSerializer);
     var protoBufSerializer = new ProtoBufSerializer();
     ShowTimeItTakes(events,protoBufSerializer);
 }
 public void setup()
 {
     _serializer = new ProtoBufSerializer();
 }
Exemple #3
0
        public void test_backward_compliance_of_new_version()
        {
            var v1Event = new ATestEvent {What = "Test"};
            var serializer = new ProtoBufSerializer();
            var bytes = serializer.Serialize(v1Event);
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(bytes));
            var prefix = "WhaleES.Integration.Test.TestAggrigateRoot";
            var putRequest = (PutObjectRequest)new PutObjectRequest()
                .WithBucketName("WhaleES_tests")
                .WithKey(prefix + "/BACKWARD_COMPATIBILITY_TEST")
                .WithInputStream(stream);

            _client.PutObject(putRequest);

            var aNewEvent = new ATestEvent {What = "THing"};
            var serialzed = serializer.Serialize(aNewEvent);
            var v2Stream = new MemoryStream(Encoding.UTF8.GetBytes(serialzed));

            var v2PutRequest = (PutObjectRequest)new PutObjectRequest()
                .WithBucketName("WhaleES_tests")
                .WithKey(prefix + "/BACKWARD_COMPATIBILITY_TEST/SOMEKEY")
                .WithInputStream(v2Stream);

            _client.PutObject(v2PutRequest);

            var repo = new StreamOfEventsFor<TestAggrigateRoot>(_client, "WhaleES_tests", serializer);
            var events = repo.GetEventStream("BACKWARD_COMPATIBILITY_TEST");
            Assert.AreEqual(2,events.Count());
        }