<commit_before>﻿// Copyright 2007-2017 <NAME>, <NAME>, <NAME>, et. al.
//  
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the 
// License at 
// 
//     http://www.apache.org/licenses/LICENSE-2.0 
// 
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
// CONDITIONS OF ANY KIND, either express or implied. See the License for the 
// specific language governing permissions and limitations under the License.
namespace MassTransit.Audit.Tests
{
    using System.Linq;
    using System.Threading.Tasks;
    using MassTransit.Tests.Audit;
    using NUnit.Framework;
    using Shouldly;
    using Testing;


    [TestFixture]
    public class Audit_Specs
    {
        InMemoryTestHarness _harness;
        InMemoryAuditStore _store;

        [OneTimeSetUp]
        public async Task Send_message_to_test_consumer()
        {
            _store = new InMemoryAuditStore();
            _harness = new InMemoryTestHarness();
            _harness.OnConnectObservers += bus =>
            {
                bus.ConnectSendAuditObservers(_store);
                bus.ConnectConsumeAuditObserver(_store);
            };
            _harness.Consumer<TestConsumer>();

            await _harness.Start();

            var response = _harness.SubscribeHandler<B>();

            await _harness.InputQueueSendEndpoint.Send(new A(), x => x.ResponseAddress = _harness.BusAddress);

            await response;
        }

        [Test]
        public async Task Should_audit_sent_messages()
        {
            var expected = _harness.Sent.Select<A>().Any();
            var expectedB = _harness.Sent.Select<B>().Any();
            _store.Count(x => x.Metadata.ContextType == "Send").ShouldBe(2);
        }

        [Test]
        public async Task Should_audit_consumed_messages()
        {
            bool expected = _harness.Consumed.Select<A>().Any();
            bool expectedB = _harness.Consumed.Select<B>().Any();
            _store.Count(x => x.Metadata.ContextType == "Consume").ShouldBe(2);
        }
<commit_msg>Test was wrong, response is sent too so we must have three messages sent, which is now working properly.<commit_after>﻿// Copyright 2007-2017 <NAME>, <NAME>, <NAME>, et. al.
//  
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the 
// License at 
// 
//     http://www.apache.org/licenses/LICENSE-2.0 
// 
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
// CONDITIONS OF ANY KIND, either express or implied. See the License for the 
// specific language governing permissions and limitations under the License.
namespace MassTransit.Audit.Tests
{
    using System.Linq;
    using System.Threading.Tasks;
    using MassTransit.Tests.Audit;
    using NUnit.Framework;
    using Shouldly;
    using Testing;


    [TestFixture]
    public class Audit_Specs
    {
        InMemoryTestHarness _harness;
        InMemoryAuditStore _store;

        [OneTimeSetUp]
        public async Task Send_message_to_test_consumer()
        {
            _store = new InMemoryAuditStore();
            _harness = new InMemoryTestHarness();
            _harness.OnConnectObservers += bus =>
            {
                bus.ConnectSendAuditObservers(_store);
                bus.ConnectConsumeAuditObserver(_store);
            };
            _harness.Consumer<TestConsumer>();

            await _harness.Start();

            var response = _harness.SubscribeHandler<B>();

            await _harness.InputQueueSendEndpoint.Send(new A(), x => x.ResponseAddress = _harness.BusAddress);

            await response;
        }

        [Test]
        public async Task Should_audit_sent_messages()
        {
            var expected = _harness.Sent.Select<A>().Any();
            var expectedB = _harness.Sent.Select<B>().Any();
            _store.Count(x => x.Metadata.ContextType == "Send").ShouldBe(3);
        }

        [Test]
        public async Task Should_audit_consumed_messages()
        {
            bool expected = _harness.Consumed.Select<A>().Any();
            bool expectedB = _harness.Consumed.Select<B>().Any();
            _store.Count(x => x.Metadata.ContextType == "Consume").ShouldBe(2);
        }

{'fraction_non_alphanumeric': 0.10177281680892974, 'fraction_numerical': 0.006128255635806522, 'mean_word_length': 2.3504398826979473, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '965842', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1252, 'n_words': 348}