public void Establish()
        {
            _msSqlTestHelper = new MsSqlTestHelper();
            _msSqlTestHelper.SetupMessageDb();

            s_sqlMessageStore = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            s_messageEarliest = new Message(new MessageHeader(Guid.NewGuid(), _TopicFirstMessage, MessageType.MT_DOCUMENT), new MessageBody("message body"));
            s_message1        = new Message(new MessageHeader(Guid.NewGuid(), "test_topic2", MessageType.MT_DOCUMENT), new MessageBody("message body2"));
            s_message2        = new Message(new MessageHeader(Guid.NewGuid(), _TopicLastMessage, MessageType.MT_DOCUMENT), new MessageBody("message body3"));
            s_sqlMessageStore.Add(s_messageEarliest);
            s_sqlMessageStore.Add(s_message1);
            s_sqlMessageStore.Add(s_message2);
        }
        public void When_The_Message_Is_Already_In_The_Message_Store()
        {
            _exception = Catch.Exception(() => _sqlMessageStore.Add(_messageEarliest));

            //_should_ignore_the_duplcate_key_and_still_succeed
            _exception.Should().BeNull();
        }
        public MsSqlMessageStoreRangeRequestTests()
        {
            _msSqlTestHelper = new MsSqlTestHelper();
            _msSqlTestHelper.SetupMessageDb();

            _sqlMessageStore = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            var messageEarliest = new Message(new MessageHeader(Guid.NewGuid(), _TopicFirstMessage, MessageType.MT_DOCUMENT), new MessageBody("message body"));
            var message1        = new Message(new MessageHeader(Guid.NewGuid(), "test_topic2", MessageType.MT_DOCUMENT), new MessageBody("message body2"));
            var message2        = new Message(new MessageHeader(Guid.NewGuid(), _TopicLastMessage, MessageType.MT_DOCUMENT), new MessageBody("message body3"));

            _sqlMessageStore.Add(messageEarliest);
            Task.Delay(100);
            _sqlMessageStore.Add(message1);
            Task.Delay(100);
            _sqlMessageStore.Add(message2);
        }
Exemplo n.º 4
0
        public SqlMessageStoreWritngMessagesTests()
        {
            _msSqlTestHelper = new MsSqlTestHelper();
            _msSqlTestHelper.SetupMessageDb();

            _sqlMessageStore = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            _messageEarliest = new Message(new MessageHeader(Guid.NewGuid(), "Test", MessageType.MT_COMMAND, DateTime.UtcNow.AddHours(-3)), new MessageBody("Body"));
            _sqlMessageStore.Add(_messageEarliest);

            var message2 = new Message(new MessageHeader(Guid.NewGuid(), "Test2", MessageType.MT_COMMAND, DateTime.UtcNow.AddHours(-2)), new MessageBody("Body2"));

            _sqlMessageStore.Add(message2);

            _messageLatest = new Message(new MessageHeader(Guid.NewGuid(), "Test3", MessageType.MT_COMMAND, DateTime.UtcNow.AddHours(-1)), new MessageBody("Body3"));
            _sqlMessageStore.Add(_messageLatest);
        }
        public MsSqlMessageStoreMessageAlreadyExistsTests()
        {
            _msSqlTestHelper = new MsSqlTestHelper();
            _msSqlTestHelper.SetupMessageDb();

            _sqlMessageStore = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            _messageEarliest = new Message(new MessageHeader(Guid.NewGuid(), "test_topic", MessageType.MT_DOCUMENT), new MessageBody("message body"));
            _sqlMessageStore.Add(_messageEarliest);
        }
Exemplo n.º 6
0
        public void Writing_and_reading_a_message_from_the_store()
        {
            CleanupDb();
            CreateTestDb();

            var sqlMessageStore = new MsSqlMessageStore(new MsSqlMessageStoreConfiguration(ConnectionString, TableName, MsSqlMessageStoreConfiguration.DatabaseType.SqlCe), new NoOpLogger());
            var message         = new Message(new MessageHeader(Guid.NewGuid(), "test_topic", MessageType.MT_DOCUMENT), new MessageBody("message body"));

            sqlMessageStore.Add(message).Wait();
            var storedMessage = sqlMessageStore.Get(message.Id).Result;

            Assert.AreEqual(message.Body.Value, storedMessage.Body.Value);
        }
Exemplo n.º 7
0
        public SqlMessageStoreWritingMessageTests()
        {
            _msSqlTestHelper = new MsSqlTestHelper();
            _msSqlTestHelper.SetupMessageDb();

            _sqlMessageStore = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            var messageHeader = new MessageHeader(Guid.NewGuid(), "test_topic", MessageType.MT_DOCUMENT, DateTime.UtcNow.AddDays(-1), 5, 5);

            messageHeader.Bag.Add(_key1, _value1);
            messageHeader.Bag.Add(_key2, _value2);

            _messageEarliest = new Message(messageHeader, new MessageBody("message body"));
            _sqlMessageStore.Add(_messageEarliest);
        }
Exemplo n.º 8
0
        public void Establish()
        {
            _msSqlTestHelper = new MsSqlTestHelper();
            _msSqlTestHelper.SetupMessageDb();

            _sqlMessageStore   = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            Clock.OverrideTime = DateTime.UtcNow.AddHours(-3);
            _messageEarliest   = new Message(new MessageHeader(Guid.NewGuid(), "Test", MessageType.MT_COMMAND),
                                             new MessageBody("Body"));
            _sqlMessageStore.Add(_messageEarliest);

            Clock.OverrideTime = DateTime.UtcNow.AddHours(-2);

            _message2 = new Message(new MessageHeader(Guid.NewGuid(), "Test2", MessageType.MT_COMMAND),
                                    new MessageBody("Body2"));
            _sqlMessageStore.Add(_message2);

            Clock.OverrideTime = DateTime.UtcNow.AddHours(-1);

            _messageLatest = new Message(new MessageHeader(Guid.NewGuid(), "Test3", MessageType.MT_COMMAND),
                                         new MessageBody("Body3"));
            _sqlMessageStore.Add(_messageLatest);
        }