示例#1
0
        public async Task When_The_Message_Is_Already_In_The_Message_Store_Async()
        {
            await _sqlMessageStore.AddAsync(_messageEarliest);

            _exception = await Catch.ExceptionAsync(() => _sqlMessageStore.AddAsync(_messageEarliest));

            //_should_ignore_the_duplcate_key_and_still_succeed
            _exception.Should().BeNull();
        }
示例#2
0
        private async Task SetUpMessagesAsync()
        {
            _messageEarliest = new Message(new MessageHeader(Guid.NewGuid(), "Test", MessageType.MT_COMMAND, DateTime.UtcNow.AddHours(-3)), new MessageBody("Body"));
            await _sqlMessageStore.AddAsync(_messageEarliest);

            _message2 = new Message(new MessageHeader(Guid.NewGuid(), "Test2", MessageType.MT_COMMAND, DateTime.UtcNow.AddHours(-2)), new MessageBody("Body2"));
            await _sqlMessageStore.AddAsync(_message2);

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

            _sqlMessageStore = new MsSqlMessageStore(_msSqlTestHelper.MessageStoreConfiguration);
            _messageEarliest = new Message(new MessageHeader(Guid.NewGuid(), _TopicFirstMessage, MessageType.MT_DOCUMENT), new MessageBody("message body"));
            _message1        = new Message(new MessageHeader(Guid.NewGuid(), "test_topic2", MessageType.MT_DOCUMENT), new MessageBody("message body2"));
            _message2        = new Message(new MessageHeader(Guid.NewGuid(), _TopicLastMessage, MessageType.MT_DOCUMENT), new MessageBody("message body3"));

            AsyncContext.Run(async() => await _sqlMessageStore.AddAsync(_messageEarliest));
            AsyncContext.Run(async() => await _sqlMessageStore.AddAsync(_message1));
            AsyncContext.Run(async() => await _sqlMessageStore.AddAsync(_message2));
        }
        public void When_The_Message_Is_Already_In_The_Message_Store_Async()
        {
            _exception = Catch.Exception(() => AsyncContext.Run(async() => await _sqlMessageStore.AddAsync(_messageEarliest)));

            //_should_ignore_the_duplcate_key_and_still_succeed
            Assert.Null(_exception);
        }
        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"));
            AsyncContext.Run(async () => await _sqlMessageStore.AddAsync(_messageEarliest));

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

            _message2 = new Message(new MessageHeader(Guid.NewGuid(), "Test2", MessageType.MT_COMMAND), new MessageBody("Body2"));
            AsyncContext.Run(async () => await _sqlMessageStore.AddAsync(_message2));

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

            _messageLatest = new Message(new MessageHeader(Guid.NewGuid(), "Test3", MessageType.MT_COMMAND),new MessageBody("Body3"));
            AsyncContext.Run(async () => await _sqlMessageStore.AddAsync(_messageLatest));
        }
        public async Task When_There_Are_Multiple_Messages_In_The_Message_Store_And_A_Range_Is_Fetched_Async()
        {
            await _sqlMessageStore.AddAsync(_messageEarliest);

            await Task.Delay(100);

            await _sqlMessageStore.AddAsync(_message1);

            await Task.Delay(100);

            await _sqlMessageStore.AddAsync(_message2);

            _messages = await _sqlMessageStore.GetAsync(1, 3);

            //_should_fetch_1_message
            _messages.Should().HaveCount(1);
            //_should_fetch_expected_message
            _messages.First().Header.Topic.Should().Be(_TopicLastMessage);
            //_should_not_fetch_null_messages
            _messages.Should().NotBeNull();
        }
        public void Establish()
        {
            _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"));
            AsyncContext.Run(async() => await _sqlMessageStore.AddAsync(_messageEarliest));
        }
示例#8
0
        public async Task When_Writing_A_Message_To_The_Message_Store_Async()
        {
            await _sqlMessageStore.AddAsync(_messageEarliest);

            _storedMessage = await _sqlMessageStore.GetAsync(_messageEarliest.Id);

            //_should_read_the_message_from_the__sql_message_store =
            _storedMessage.Body.Value.Should().Be(_messageEarliest.Body.Value);
            //_should_read_the_message_header_first_bag_item_from_the__sql_message_store
            _storedMessage.Header.Bag.ContainsKey(_key1).Should().BeTrue();
            _storedMessage.Header.Bag[_key1].Should().Be(_value1);
            //_should_read_the_message_header_second_bag_item_from_the__sql_message_store
            _storedMessage.Header.Bag.ContainsKey(_key2).Should().BeTrue();
            _storedMessage.Header.Bag[_key2].Should().Be(_value2);
            //_should_read_the_message_header_timestamp_from_the__sql_message_store
            _storedMessage.Header.TimeStamp.Should().Be(_messageEarliest.Header.TimeStamp);
            //_should_read_the_message_header_topic_from_the__sql_message_store
            _storedMessage.Header.Topic.Should().Be(_messageEarliest.Header.Topic);
            //_should_read_the_message_header_type_from_the__sql_message_store
            _storedMessage.Header.MessageType.Should().Be(_messageEarliest.Header.MessageType);
        }