Documentation Coverage Report
Current view: top level - Azure/Tests/Cqrs.Azure.ServiceBus.Tests.Integration - RoundTripTests.cs Hit Total Coverage
Version: 2.2 Artefacts: 3 3 100.0 %
Date: 2017-09-22

          Line data    Source code
       1             : using System;
       2             : using System.Collections.Generic;
       3             : using System.Threading;
       4             : using Cqrs.Azure.ServiceBus.Tests.Unit;
       5             : using Cqrs.Configuration;
       6             : using cdmdotnet.Logging;
       7             : using cdmdotnet.Logging.Configuration;
       8             : using Cqrs.Bus;
       9             : using Cqrs.Commands;
      10             : using Cqrs.Events;
      11             : using NUnit.Framework;
      12             : using TestClass = NUnit.Framework.TestFixtureAttribute;
      13             : using TestMethod = NUnit.Framework.TestAttribute;
      14             : using TestInitialize = NUnit.Framework.SetUpAttribute;
      15             : using TestCleanup = NUnit.Framework.TearDownAttribute;
      16             : using TestContext = System.Object;
      17             : 
      18             : namespace Cqrs.Azure.ServiceBus.Tests.Integration
      19             : {
      20             :         /// <summary>
      21             :         /// A series of tests publishing <see cref="IEvent{TAuthenticationToken}">events</see>.
      22             :         /// </summary>
      23             :         [TestClass]
      24             :         public class RoundTripTests
      25           1 :         {
      26             :                 /// <summary>
      27             :                 /// Tests a test <see cref="IEvent{TAuthenticationToken}"/> can be published via
      28             :                 /// <see cref="AzureEventBusPublisher{TAuthenticationToken}"/> and two <see cref="IEventHandler">event handlers</see>
      29             :                 /// Will fire updating test flags.
      30             :                 /// </summary>
      31             :                 [TestMethod]
      32           1 :                 public void Publish_TestEvent_NoExceptions()
      33             :                 {
      34             :                         // Arrange
      35             :                         IDictionary<Guid, Tuple<bool, Exception>> testResponse = new Dictionary<Guid, Tuple<bool, Exception>>();
      36             : 
      37             :                         Guid processId = Guid.NewGuid();
      38             :                         testResponse.Add(processId, new Tuple<bool, Exception>(false, null));
      39             :                         var @event = new TestEvent{Id = processId};
      40             : 
      41             :                         var azureEventBusReceiver = new AzureEventBusReceiver<Guid>(new ConfigurationManager(), new MessageSerialiser<Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper<Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser<Guid>(), new BusHelper(new ConfigurationManager()), new ConfigurationManager(), null), new BusHelper(new ConfigurationManager()));
      42             :                         var handler = new TestEventSuccessHandler(testResponse);
      43             :                         azureEventBusReceiver.RegisterHandler<TestEvent>(handler.Handle, handler.GetType());
      44             :                         azureEventBusReceiver.Start();
      45             : 
      46             :                         var azureEventBusPublisher = new AzureEventBusPublisher<Guid>(new ConfigurationManager(), new MessageSerialiser<Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper<Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser<Guid>(), new BusHelper(new ConfigurationManager()), new ConfigurationManager(), null), new BusHelper(new ConfigurationManager()));
      47             : 
      48             :                         // Act
      49             :                         azureEventBusPublisher.Publish(@event);
      50             : 
      51             :                         // Assert
      52             :                         SpinWait.SpinUntil(() => testResponse[processId].Item1);
      53             :                         Assert.IsNull(testResponse[processId].Item2);
      54             :                 }
      55             : 
      56             :                 /// <summary>
      57             :                 /// Tests a test <see cref="ICommand{TAuthenticationToken}"/> can be published via
      58             :                 /// <see cref="AzureCommandBusPublisher{TAuthenticationToken}"/> and two <see cref="IEventHandler">event handlers</see>
      59             :                 /// Will fire updating test flags.
      60             :                 /// </summary>
      61             :                 [TestMethod]
      62           1 :                 public void Publish_TestCommand_NoExceptions()
      63             :                 {
      64             :                         // Arrange
      65             :                         IDictionary<Guid, Tuple<bool, Exception>> testResponse = new Dictionary<Guid, Tuple<bool, Exception>>();
      66             : 
      67             :                         Guid processId = Guid.NewGuid();
      68             :                         testResponse.Add(processId, new Tuple<bool, Exception>(false, null));
      69             :                         var command = new TestCommand { Id = processId };
      70             : 
      71             :                         var azureCommandBusReceiver = new AzureCommandBusReceiver<Guid>(new ConfigurationManager(), new MessageSerialiser<Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper<Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser<Guid>(), new BusHelper(new ConfigurationManager()), new ConfigurationManager(), null), new BusHelper(new ConfigurationManager()));
      72             :                         var handler = new TestCommandSuccessHandler(testResponse);
      73             :                         azureCommandBusReceiver.RegisterHandler<TestCommand>(handler.Handle, handler.GetType());
      74             :                         azureCommandBusReceiver.Start();
      75             : 
      76             :                         var azureCommandBusPublisher = new AzureCommandBusPublisher<Guid>(new ConfigurationManager(), new MessageSerialiser<Guid>(), new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new AzureBusHelper<Guid>(new GuidAuthenticationTokenHelper(), new NullCorrelationIdHelper(), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new MessageSerialiser<Guid>(), new BusHelper(new ConfigurationManager()), new ConfigurationManager(), null), new BusHelper(new ConfigurationManager()));
      77             : 
      78             :                         // Act
      79             :                         azureCommandBusPublisher.Publish(command);
      80             : 
      81             :                         // Assert
      82             :                         SpinWait.SpinUntil(() => testResponse[processId].Item1);
      83             :                         Assert.IsNull(testResponse[processId].Item2);
      84             :                 }
      85             :         }
      86             : }

Generated by: LCOV version 1.10