a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
|
|
|
using System.Collections;
|
|
using Moq;
|
|
using Xunit;
|
|
using Assert = Microsoft.TestCommon.AssertEx;
|
|
|
|
namespace System.Web.WebPages.Test
|
|
{
|
|
public class RequestResourceTrackerTest
|
|
{
|
|
[Fact]
|
|
public void RegisteringForDisposeDisposesObjects()
|
|
{
|
|
// Arrange
|
|
var context = new Mock<HttpContextBase>();
|
|
IDictionary items = new Hashtable();
|
|
context.Setup(m => m.Items).Returns(items);
|
|
var disposable = new Mock<IDisposable>();
|
|
disposable.Setup(m => m.Dispose()).Verifiable();
|
|
|
|
// Act
|
|
RequestResourceTracker.RegisterForDispose(context.Object, disposable.Object);
|
|
RequestResourceTracker.DisposeResources(context.Object);
|
|
|
|
// Assert
|
|
disposable.VerifyAll();
|
|
}
|
|
|
|
[Fact]
|
|
public void RegisteringForDisposeExtensionMethodNullContextThrows()
|
|
{
|
|
// Arrange
|
|
var disposable = new Mock<IDisposable>();
|
|
|
|
// Act
|
|
Assert.ThrowsArgumentNull(() => HttpContextExtensions.RegisterForDispose(null, disposable.Object), "context");
|
|
}
|
|
}
|
|
}
|