Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Added tests for FastHttpRequestIdentifierFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianEdwards committed Oct 5, 2015
1 parent 5cbb534 commit 9ffe49f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void HostingEngine_CreatesDefaultRequestIdentifierFeature_IfNotPresent()

// Assert
Assert.NotNull(httpContext);
Assert.IsType<HttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
Assert.IsType<FastHttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
}

[Fact]
Expand All @@ -328,7 +328,7 @@ public void Hosting_CreatesDefaultRequestIdentifierFeature_IfNotPresent_ForImmut

// Assert
Assert.NotNull(httpContext);
Assert.IsType<HttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
Assert.IsType<FastHttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNet.Hosting.Internal;
using Xunit;

namespace Microsoft.AspNet.Hosting.Tests.Internal
{
public class FastHttpRequestIdentifierFeatureTests
{
[Fact]
public void TraceIdentifier_ReturnsId()
{
var feature = new FastHttpRequestIdentifierFeature();

var id = feature.TraceIdentifier;

Assert.NotNull(id);
}

[Fact]
public void TraceIdentifier_ReturnsStableId()
{
var feature = new FastHttpRequestIdentifierFeature();

var id1 = feature.TraceIdentifier;
var id2 = feature.TraceIdentifier;

Assert.Equal(id1, id2);
}

[Fact]
public void TraceIdentifier_ReturnsUniqueIdForDifferentInstances()
{
var feature1 = new FastHttpRequestIdentifierFeature();
var feature2 = new FastHttpRequestIdentifierFeature();

var id1 = feature1.TraceIdentifier;
var id2 = feature2.TraceIdentifier;

Assert.NotEqual(id1, id2);
}
}
}

0 comments on commit 9ffe49f

Please sign in to comment.