public void Setup() { var httpContext = new DefaultHttpContext(); var controllerContext = new ControllerContext() { HttpContext = httpContext, }; controllerContext.HttpContext.Connection.RemoteIpAddress = IPAddress.Parse("127.0.0.1"); mockController = new Mock <ContactUsController>() { CallBase = true }; var mockOpr = new Mock <IBusinessOperationManipulate <MContactUs> >(); mockContactUsOpr = mockOpr.Object; mockOpr.Setup(foo => foo.Apply(It.IsAny <MContactUs>())).Returns(0); mockController.Setup(foo => foo.GetSaveContactUsOperation()).Returns(mockContactUsOpr); var iCacheMock = new Mock <ICacheContext>(); mockController.Setup(foo => foo.GetContentCache()).Returns(iCacheMock.Object); var mockSmtp = new Mock <ISmtpContext>(); mockController.Setup(foo => foo.GetSmtpContext()).Returns(mockSmtp.Object); controller = mockController.Object; controller.ControllerContext = controllerContext; var values = new Dictionary <string, StringValues>() { { "g-recaptcha-response", new StringValues("ThisIsFakedToken") } }; var formValues = new FormCollection(values); var httpReqMocked = new Mock <HttpRequest>(); httpReqMocked.Setup(r => r.Form).Returns(formValues); var httpReq = httpReqMocked.Object; controller.SetHttpRequest(httpReq); }
public void GetEmailTo() { var cache = new ContactUsController().GetEmailTo(); }
public void GetContentCache() { var cache = new ContactUsController().GetContentCache(); Assert.NotNull(cache); }