Skip to content

Commit

Permalink
fix unit tests by creating a new headers collection each time instad …
Browse files Browse the repository at this point in the history
…of sharing it
  • Loading branch information
lucaspimentel committed Nov 1, 2021
1 parent 5afcd69 commit efc1f98
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tracer/test/Datadog.Trace.Tests/HeadersCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,35 @@ public class HeadersCollectionTests

public static IEnumerable<object[]> GetHeaderCollectionImplementations()
{
yield return new object[] { WebRequest.CreateHttp("http://localhost").Headers.Wrap() };
yield return new object[] { new NameValueCollection().Wrap() };
yield return new object[] { new DictionaryHeadersCollection() };
return GetHeaderCollectionFactories().Select(factory => new object[] { factory() });
}

public static IEnumerable<object[]> GetHeadersInvalidIdsCartesianProduct()
{
return from header in GetHeaderCollectionImplementations().SelectMany(i => i)
return from headersFactory in GetHeaderCollectionFactories()
from invalidId in HeadersCollectionTestHelpers.GetInvalidIds().SelectMany(i => i)
select new[] { header, invalidId };
select new[] { headersFactory(), invalidId };
}

public static IEnumerable<object[]> GetHeadersInvalidIntegerSamplingPrioritiesCartesianProduct()
{
return from header in GetHeaderCollectionImplementations().SelectMany(i => i)
return from headersFactory in GetHeaderCollectionFactories()
from invalidSamplingPriority in HeadersCollectionTestHelpers.GetInvalidIntegerSamplingPriorities().SelectMany(i => i)
select new[] { header, invalidSamplingPriority };
select new[] { headersFactory(), invalidSamplingPriority };
}

public static IEnumerable<object[]> GetHeadersInvalidNonIntegerSamplingPrioritiesCartesianProduct()
{
return from header in GetHeaderCollectionImplementations().SelectMany(i => i)
return from headersFactory in GetHeaderCollectionFactories()
from invalidSamplingPriority in HeadersCollectionTestHelpers.GetInvalidNonIntegerSamplingPriorities().SelectMany(i => i)
select new[] { header, invalidSamplingPriority };
select new[] { headersFactory(), invalidSamplingPriority };
}

internal static IEnumerable<Func<IHeadersCollection>> GetHeaderCollectionFactories()
{
yield return () => WebRequest.CreateHttp("http://localhost").Headers.Wrap();
yield return () => new NameValueCollection().Wrap();
yield return () => new DictionaryHeadersCollection();
}

[Theory]
Expand Down

0 comments on commit efc1f98

Please sign in to comment.