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

56 lines
1.6 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using Xunit;
namespace Microsoft.Web.Mvc.Test
{
public class DynamicViewPageTest
{
// DynamicViewPage
[Fact]
public void AnonymousObjectsAreWrapped()
{
// Arrange
DynamicViewPage page = new DynamicViewPage();
page.ViewData.Model = new { foo = "Hello world!" };
// Act & Assert
Assert.Equal("Microsoft.Web.Mvc.DynamicReflectionObject", page.Model.GetType().FullName);
}
[Fact]
public void NonAnonymousObjectsAreNotWrapped()
{
// Arrange
DynamicViewPage page = new DynamicViewPage();
page.ViewData.Model = "Hello world!";
// Act & Assert
Assert.Equal(typeof(string), page.Model.GetType());
}
[Fact]
public void ViewDataDictionaryIsWrapped()
{
// Arrange
DynamicViewPage page = new DynamicViewPage();
// Act & Assert
Assert.Equal("Microsoft.Web.Mvc.DynamicViewDataDictionary", page.ViewData.GetType().FullName);
}
// DynamicViewPage<T>
[Fact]
public void Generic_ViewDataDictionaryIsWrapped()
{
// Arrange
DynamicViewPage<object> page = new DynamicViewPage<object>();
// Act & Assert
Assert.Equal("Microsoft.Web.Mvc.DynamicViewDataDictionary", page.ViewData.GetType().FullName);
}
}
}