public void EntryInvocationRestrictionHelper_WithForceInvocationByOriginatingInstanceOptionSetToFalse_ReturnsSameEntries() { _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.ForceInvocationByOriginatingInstance = false; var filteredEntries = EntryInvocationRestrictionHelper <ReportRequestEntry> .RestrictInvocationToOriginatingClientsIfEnabled(_reportRequestEntries, _options); CollectionAssert.AreEquivalent(_reportRequestEntries, filteredEntries); }
public void EntryInvocationRestrictionHelper_WithNonDefinedinvocationRestrictionOptions_ReturnsSameEntries() { _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance = null; var filteredEntries = EntryInvocationRestrictionHelper <ReportRequestEntry> .RestrictInvocationToOriginatingClientsIfEnabled(_reportRequestEntries, _options); CollectionAssert.AreEquivalent(_reportRequestEntries, filteredEntries); }
public void EntryInvocationRestrictionHelper_WithForceInvocationByOriginatingInstanceOptionSetToTrue_AndDefaultInstanceId_ReturnsCorrectEntries(bool allowInvocationByAnyInstance, int expectedNumberOfEntries) { _options = new EasyMwsOptions(useDefaultValues: true); _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.CustomInstanceId = null; _originatingInstanceHash = _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.HashedInstanceId; _reportRequestEntries = new List <ReportRequestEntry> { new ReportRequestEntry { Id = 1, InstanceId = _originatingInstanceHash, InvokeCallbackRetryCount = 0 }, new ReportRequestEntry { Id = 2, InstanceId = "non-originating-instance1-hash", InvokeCallbackRetryCount = 3 }, new ReportRequestEntry { Id = 3, InstanceId = "non-originating-instance2-hash", InvokeCallbackRetryCount = 0 }, new ReportRequestEntry { Id = 4, InstanceId = _originatingInstanceHash, InvokeCallbackRetryCount = 0 }, }; _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.ForceInvocationByOriginatingInstance = true; _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.AllowInvocationByAnyInstanceIfInvocationFailedLimitReached = allowInvocationByAnyInstance; var allowedFailures = 2; _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.InvocationFailuresLimit = allowedFailures; var filteredEntries = EntryInvocationRestrictionHelper <ReportRequestEntry> .RestrictInvocationToOriginatingClientsIfEnabled(_reportRequestEntries, _options); CollectionAssert.AreNotEquivalent(_reportRequestEntries, filteredEntries); Assert.IsTrue(filteredEntries.Count == expectedNumberOfEntries); if (!allowInvocationByAnyInstance) { Assert.IsTrue(filteredEntries.All(e => e.InstanceId == _originatingInstanceHash)); } else { Assert.IsTrue( filteredEntries.Count(e => e.InstanceId == _originatingInstanceHash) == 2 && filteredEntries.Count(e => e.InstanceId != _originatingInstanceHash && e.InvokeCallbackRetryCount > allowedFailures) == 1); } }
public void EntryInvocationRestrictionHelper_WithForceInvocationByOriginatingInstanceOptionSetToTrue_AndCustomInstanceId_ReturnsCorrectEntries(bool allowInvocationByAnyInstance, int expectedNumberOfEntries) { _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.ForceInvocationByOriginatingInstance = true; _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.AllowInvocationByAnyInstanceIfInvocationFailedLimitReached = allowInvocationByAnyInstance; var allowedFailures = 2; _options.EventPublishingOptions.RestrictInvocationToOriginatingInstance.InvocationFailuresLimit = allowedFailures; var filteredEntries = EntryInvocationRestrictionHelper <ReportRequestEntry> .RestrictInvocationToOriginatingClientsIfEnabled(_reportRequestEntries, _options); CollectionAssert.AreNotEquivalent(_reportRequestEntries, filteredEntries); Assert.IsTrue(filteredEntries.Count == expectedNumberOfEntries); if (!allowInvocationByAnyInstance) { Assert.IsTrue(filteredEntries.All(e => e.InstanceId == _originatingInstanceHash)); } else { Assert.IsTrue( filteredEntries.Count(e => e.InstanceId == _originatingInstanceHash) == 2 && filteredEntries.Count(e => e.InstanceId != _originatingInstanceHash && e.InvokeCallbackRetryCount > allowedFailures) == 1); } }