PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/mvc3/test/MvcFuturesTest/Mvc/Test/DynamicViewPageTest.cs

https://github.com/jeanlyn/ASP.NET-Mvc-3
C# | 50 lines | 28 code | 12 blank | 10 comment | 0 complexity | 53d8185e856d14abfc6a460766f3da74 MD5 | raw file
  1. namespace Microsoft.Web.Mvc.Test {
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. [TestClass]
  4. public class DynamicViewPageTest {
  5. // DynamicViewPage
  6. [TestMethod]
  7. public void AnonymousObjectsAreWrapped() {
  8. // Arrange
  9. DynamicViewPage page = new DynamicViewPage();
  10. page.ViewData.Model = new { foo = "Hello world!" };
  11. // Act & Assert
  12. Assert.AreEqual("Microsoft.Web.Mvc.DynamicReflectionObject", page.Model.GetType().FullName);
  13. }
  14. [TestMethod]
  15. public void NonAnonymousObjectsAreNotWrapped() {
  16. // Arrange
  17. DynamicViewPage page = new DynamicViewPage();
  18. page.ViewData.Model = "Hello world!";
  19. // Act & Assert
  20. Assert.AreEqual(typeof(string), page.Model.GetType());
  21. }
  22. [TestMethod]
  23. public void ViewDataDictionaryIsWrapped() {
  24. // Arrange
  25. DynamicViewPage page = new DynamicViewPage();
  26. // Act & Assert
  27. Assert.AreEqual("Microsoft.Web.Mvc.DynamicViewDataDictionary", page.ViewData.GetType().FullName);
  28. }
  29. // DynamicViewPage<T>
  30. [TestMethod]
  31. public void Generic_ViewDataDictionaryIsWrapped() {
  32. // Arrange
  33. DynamicViewPage<object> page = new DynamicViewPage<object>();
  34. // Act & Assert
  35. Assert.AreEqual("Microsoft.Web.Mvc.DynamicViewDataDictionary", page.ViewData.GetType().FullName);
  36. }
  37. }
  38. }