using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Web.Mvc; namespace Admin.UnitTests.Controllers.Suspense.Journal { [TestClass] [ExcludeFromCodeCoverage] public class Get : TestBase { public Get() { SetupController(); } private MethodInfo GetMethod() { return GetMethod(typeof(HttpGetAttribute), nameof(Controller._Journal)); } private ActionResult GetResult() { return Controller._Journal(); } [TestMethod] public void HasCorrectNumberOfCustomAttributes() { Assert.AreEqual(3, GetMethod().CustomAttributes.Count()); } [TestMethod] public void ReturnsAPartialView() { var result = GetResult(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(PartialViewResult)); } [TestMethod] public void ReturnsCorrectViewName() { var result = GetResult() as PartialViewResult; Assert.IsNotNull(result); Assert.IsTrue(string.IsNullOrEmpty(result.ViewName) || result.ViewName == nameof(Controller._Journal)); } } }