Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

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");
}
}
}