public void TestConfirmationServiceReturnsNotOkResponse() { var guid = Guid.NewGuid(); var requestBody = new IntegrationLayerResponse { CorrelationId = guid.ToString(), SourceSystemEntityID = "entity id", SourceSystemStatusCode = HttpStatusCode.OK }; var confirmationService = A.Fake <IConfirmationService>(); A.CallTo(() => confirmationService.ProcessResponse(guid, requestBody)).Returns(new ConfirmationResponse() { StatusCode = HttpStatusCode.BadRequest, Message = "message" }); controller = new ConfirmationController(confirmationService); controller.Request = new System.Net.Http.HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var response = controller.Confirmations(guid.ToString(), requestBody); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.AreEqual("message", ((System.Net.Http.ObjectContent)response.Content).Value); }
public ConfirmationControllerTest() { confirmationSMSService = new Mock <AbstractConfirmationSMSService>(); confirmationEmailService = new Mock <AbstractConfirmationEmailService>(); List <IConfirmationService> services = new List <IConfirmationService> { confirmationSMSService.Object, confirmationEmailService.Object }; controller = new ConfirmationController(services); }
public void ConfirmationControllerTests_Index_InValidData() { var controller = new ConfirmationController(); var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); controller.TempData = tempData; var result = controller.Index(); result.Should().BeOfType(typeof(ViewResult)); var modelresult = ((ViewResult)result).Model; modelresult.Should().BeNull(); }
public ConfirmationControllerTests() { _cachedSurveyModel = _fixture.Create <SurveyModel>(); var sessionServiceMock = new Mock <ISessionService>(); var loggerMock = new Mock <ILogger <ConfirmationController> >(); var optionsMock = new Mock <IOptionsMonitor <MaPageConfiguration> >(); var linkGeneratorMock = new Mock <ILinkGenerator>(); var maPageConfiguration = new MaPageConfiguration { Routes = new MaRoutes { Accounts = new Dictionary <string, string>() } }; maPageConfiguration.Routes.Accounts.Add("AccountsHome", "http://AnAccountsLink/{0}"); optionsMock.Setup(s => s.CurrentValue).Returns(maPageConfiguration); linkGeneratorMock.Setup(s => s.AccountsLink(It.IsAny <string>())).Returns <string>(x => x); var config = new ProvideFeedbackEmployerWebConfiguration() { ExternalLinks = _externalLinks }; var urlBuilder = new UrlBuilder(Mock.Of <ILogger <UrlBuilder> >(), optionsMock.Object, linkGeneratorMock.Object); sessionServiceMock .Setup(mock => mock.Get <SurveyModel>(It.IsAny <string>())) .Returns(Task.FromResult(_cachedSurveyModel)); _controller = new ConfirmationController( sessionServiceMock.Object, config, urlBuilder, loggerMock.Object); var context = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "TestUserIdValue"), })) }; _controller.ControllerContext = new ControllerContext { HttpContext = context }; }
public ConfirmationControllerTests() { _cachedSurveyModel = Fixture.Create <SurveyModel>(); _sessionServiceMock = new Mock <ISessionService>(); _providerFeedbackRepoMock = new Mock <IGetProviderFeedback>(); _loggerMock = new Mock <ILogger <ConfirmationController> >(); _externalLinksOptions = Options.Create(_externalLinks); _sessionServiceMock .Setup(mock => mock.Get <SurveyModel>(It.IsAny <string>())) .Returns(Task.FromResult(_cachedSurveyModel)); _controller = new ConfirmationController( _sessionServiceMock.Object, _providerFeedbackRepoMock.Object, _externalLinksOptions, _loggerMock.Object); }
public void ConfirmationControllerTests_Index_ValidData() { var controller = new ConfirmationController(); var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); tempData["ilrSubmission"] = JsonConvert.SerializeObject(new IlrFileViewModel()); controller.TempData = tempData; var result = controller.Index(); result.Should().BeOfType(typeof(ViewResult)); var modelresult = ((ViewResult)result).Model; Assert.IsAssignableFrom <IlrFileViewModel>(modelresult); }
public void TestSetup() { controller = new ConfirmationController(null); controller.Request = new System.Net.Http.HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); }