public void TestEuclidJsonSerialization()
		{
			var r = new Random((int)DateTime.Now.Ticks);
			var m = new FakeMessage
				{
					Identifier = Guid.NewGuid(),
					Field1 = new List<string> { r.Next().ToString(), r.Next().ToString(), r.Next().ToString() },
					Field2 = r.Next()
				};

			var serializer = new JsonMessageSerializer();

			var s = serializer.Serialize(m);

			Assert.NotNull(s);

			var m2 = serializer.Deserialize(s);

			Assert.NotNull(m2);

			Assert.True(m2 is FakeMessage);

			Assert.AreEqual(m.GetType(), m2.GetType());

			Assert.AreEqual(m.Identifier, m2.Identifier);

			Assert.AreEqual(m.Field1, (m2 as FakeMessage).Field1);

			Assert.AreEqual(m.Field2, (m2 as FakeMessage).Field2);
		}
Exemple #2
0
		public void Publishes()
		{
			var repository = new InMemoryRecordMapper<FakePublicationRecord>();
			var blobStorage = new InMemoryBlobStorage();
			var serializer = new JsonMessageSerializer();
			var transport = new InMemoryMessageChannel();
			var registry = new PublicationRegistry<FakePublicationRecord, FakePublicationRecord>(
				repository, blobStorage, serializer);

			var publisher = new DefaultPublisher(registry, transport);

			var start = DateTime.Now;
			var createdBy = new Guid("C60696AF-F2F8-44EB-B9A1-7967693AC466");
			var identifier = new Guid("EF994892-F442-4681-AD1C-217BB11A6D38");
			var message = new FakeMessage { Created = start, CreatedBy = createdBy, Identifier = identifier };

			var recordId = publisher.PublishMessage(message);
			Assert.NotNull(recordId);
			Assert.AreNotEqual(Guid.Empty, recordId);

			var record = registry.GetPublicationRecord(recordId);
			Assert.NotNull(record);
			Assert.AreEqual(typeof(FakeMessage), record.MessageType);

			var retrieved = registry.GetMessage(record.MessageLocation, record.MessageType);
			Assert.NotNull(retrieved);
			Assert.AreEqual(message.Identifier, retrieved.Identifier);
			Assert.AreEqual(message.Created.ToString(), retrieved.Created.ToString());
			Assert.AreEqual(message.Identifier, retrieved.Identifier);
		}
		public void SetupTest()
		{
			var storage = new InMemoryBlobStorage();
			var serializer = new JsonMessageSerializer();
			var repository = new InMemoryRecordMapper<FakePublicationRecord>();
			_registryTester =
				new RegistryTester<PublicationRegistry<FakePublicationRecord, FakePublicationRecord>>(
					new PublicationRegistry<FakePublicationRecord, FakePublicationRecord>(repository, storage, serializer));
		}
		public void Setup()
		{
			if (_session == null)
			{
				ConfigureDatabase();
			}

			var storage = new InMemoryBlobStorage();
			var serializer = new JsonMessageSerializer();
			var repo = new NhRecordMapper<FakePublicationRecord>(_session);

			_tester = new RecordMapperTester<NhRecordMapper<FakePublicationRecord>>(repo);
		}
Exemple #5
0
		private void ConfigureContainer()
		{
			_container = new WindsorContainer();

			var recordMapper = new InMemoryRecordMapper<CommandPublicationRecord>();
			var blobStorage = new InMemoryBlobStorage();
			var messageSerializer = new JsonMessageSerializer();

			_container.Register(Component.For<IRecordMapper<CommandPublicationRecord>>().Instance(recordMapper));

			_container.Register(Component.For<IBlobStorage>().Instance(blobStorage));

			_container.Register(Component.For<IMessageSerializer>().Instance(messageSerializer));

			_container.Register(Component.For<IMessageChannel>().Instance(new InMemoryMessageChannel()).Named("input"));

			_container.Register(Component.For<IMessageChannel>().Instance(new InMemoryMessageChannel()).Named("invalid"));

			_container.Register(Component.For<FakeCommandProcessor>().ImplementedBy(typeof(FakeCommandProcessor)));

			_container.Register(Component.For<ICommandRegistry>().Instance(new CommandRegistry(recordMapper, blobStorage, messageSerializer)).Forward<IPublicationRegistry<IPublicationRecord, IPublicationRecord>>());
		}