Skip to content

Commit

Permalink
Merge pull request #5757 from Particular/remove-static-delivery-const…
Browse files Browse the repository at this point in the history
…raint73

Remove static delivery constraint
  • Loading branch information
Michał Wójcik committed Sep 16, 2020
2 parents 7cafffd + 1a90362 commit b6d2c8b
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace NServiceBus.Core.Tests.Transports
{
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Transport;

[TestFixture]
public class MulticastTransportOperationTest
{
[Test]
public void Should_not_share_constraints_when_not_provided()
{
var transportOperation = new MulticastTransportOperation(new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]), typeof(Guid));
var secondTransportOperation = new MulticastTransportOperation(new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]), typeof(Guid));

transportOperation.DeliveryConstraints.Add(new NonDurableDelivery());

Assert.IsEmpty(secondTransportOperation.DeliveryConstraints);
Assert.IsNotEmpty(transportOperation.DeliveryConstraints);
}
}
}
24 changes: 24 additions & 0 deletions src/NServiceBus.Core.Tests/Transports/TransportOperationTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace NServiceBus.Core.Tests.Transports
{
using System;
using System.Collections.Generic;
using NServiceBus.Routing;
using NUnit.Framework;
using Transport;

[TestFixture]
public class TransportOperationTest
{
[Test]
public void Should_not_share_constraints_when_not_provided()
{
var transportOperation = new TransportOperation(new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]), new UnicastAddressTag("destination"));
var secondTransportOperation = new TransportOperation(new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]), new UnicastAddressTag("destination2"));

transportOperation.DeliveryConstraints.Add(new NonDurableDelivery());

Assert.IsEmpty(secondTransportOperation.DeliveryConstraints);
Assert.IsNotEmpty(transportOperation.DeliveryConstraints);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace NServiceBus.Core.Tests.Transports
{
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Transport;

[TestFixture]
public class UnicastTransportOperationTest
{
[Test]
public void Should_not_share_constraints_when_not_provided()
{
var transportOperation = new UnicastTransportOperation(new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]), "destination");
var secondTransportOperation = new UnicastTransportOperation(new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]), "destination2");

transportOperation.DeliveryConstraints.Add(new NonDurableDelivery());

Assert.IsEmpty(secondTransportOperation.DeliveryConstraints);
Assert.IsNotEmpty(transportOperation.DeliveryConstraints);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
namespace NServiceBus.DeliveryConstraints
{
using System.Collections.Generic;

{
/// <summary>
/// Base class for delivery constraints.
/// </summary>
public abstract class DeliveryConstraint
{
internal static List<DeliveryConstraint> EmptyConstraints = new List<DeliveryConstraint>(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public MulticastTransportOperation(OutgoingMessage message, Type messageType, Di
{
Message = message;
MessageType = messageType;
DeliveryConstraints = deliveryConstraints ?? DeliveryConstraint.EmptyConstraints;
DeliveryConstraints = deliveryConstraints ?? new List<DeliveryConstraint>(0);
RequiredDispatchConsistency = requiredDispatchConsistency;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Core/Transports/TransportOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public TransportOperation(OutgoingMessage message, AddressTag addressTag, Dispat
Message = message;
AddressTag = addressTag;
RequiredDispatchConsistency = requiredDispatchConsistency;
DeliveryConstraints = deliveryConstraints ?? DeliveryConstraint.EmptyConstraints;
DeliveryConstraints = deliveryConstraints ?? new List<DeliveryConstraint>(0);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public UnicastTransportOperation(OutgoingMessage message, string destination, Di
{
Message = message;
Destination = destination;
DeliveryConstraints = deliveryConstraints ?? DeliveryConstraint.EmptyConstraints;
DeliveryConstraints = deliveryConstraints ?? new List<DeliveryConstraint>(0);
RequiredDispatchConsistency = requiredDispatchConsistency;
}

Expand Down

0 comments on commit b6d2c8b

Please sign in to comment.