using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Web.Mvc; using Controller = Admin.Controllers.PaymentController; namespace Admin.UnitTests.Controllers.Payment.Cheques { [ExcludeFromCodeCoverage] [TestClass] public class Get : TestBase { public Get() { SetupController(); } private MethodInfo GetMethod() { return GetMethod(typeof(HttpGetAttribute), nameof(Controller.Cheque)); } private ActionResult GetResult(bool useSession) { MockIndexViewModelBuilder.Setup(x => x.Build()).Returns(new Models.Payment.IndexViewModel()); return Controller.Cheque(); } [TestMethod] public void HasCorrectNumberOfCustomAttributes() { Assert.AreEqual(2, GetMethod().CustomAttributes.Count()); } [TestMethod] public void ReturnsANewView() { var result = GetResult(true); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ViewResult)); } [TestMethod] public void ReturnsCorrectViewName() { var result = GetResult(true) as ViewResult; Assert.IsNotNull(result); Assert.IsTrue(string.IsNullOrEmpty(result.ViewName) || result.ViewName == nameof(Controller.Cheque)); } [TestMethod] public void ReturnsCorrectViewModelType() { var result = GetResult(true) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(Models.Payment.Cheques)); } } }