diff --git a/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/EmailBasedUserIdentityProviderTests.cs b/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/EmailBasedUserIdentityProviderTests.cs index 69c5eb68..97b7755b 100644 --- a/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/EmailBasedUserIdentityProviderTests.cs +++ b/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/EmailBasedUserIdentityProviderTests.cs @@ -34,6 +34,9 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests byte[] hash1 = await GetIdentityAsync(provider, context1); byte[] hash2 = await GetIdentityAsync(provider, context2); + context1.Request.Body.Close(); + context2.Request.Body.Close(); + CollectionAssert.AreNotEqual(hash1, hash2); HttpContext context3 = HttpContextHelper.GetContextWithEmail("Abc123@outlook.com"); @@ -41,6 +44,9 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests CollectionAssert.AreEqual(hash1, await GetIdentityAsync(provider, context3)); CollectionAssert.AreEqual(hash2, await GetIdentityAsync(provider, context4)); + + context3.Request.Body.Close(); + context4.Request.Body.Close(); } private async Task GetIdentityAsync(IUserIdentityProvider provider, HttpContext context) diff --git a/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/HttpContextHelper.cs b/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/HttpContextHelper.cs index 2e581f7f..f0bb0f69 100644 --- a/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/HttpContextHelper.cs +++ b/tests/Hosting.Services.Web.UnitTests/Middlewares/UserIdentity/HttpContextHelper.cs @@ -17,6 +17,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests { (HttpContext context, HttpConnectionFeature feature) = CreateHttpContext(); feature.RemoteIpAddress = IPAddress.Parse(address); + context.Request.Body.Close(); return context; } @@ -35,7 +36,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests FeatureCollection features = new(); features.Set(feature); - using Stream requestBody = new MemoryStream(); + Stream requestBody = new MemoryStream(); Mock contextMock = new(); contextMock.SetupGet(c => c.Features).Returns(features);