public void Init() { _compositeSettings = Options.Create(new CompositeSettings()); _dssService = Substitute.For <IDssReader>(); _authService = Substitute.For <IAuthService>(); _documentService = Substitute.For <IDocumentService <CmsApiSharedContentModel> >(); var inMemorySettings = new Dictionary <string, string> { { Constants.SharedContentGuidConfig, Guid.NewGuid().ToString() } }; _config = new ConfigurationBuilder() .AddInMemoryCollection(inMemorySettings) .Build(); _customer = new Customer() { Addresses = new [] { new Address() { Address1 = "Line 1" } }, Contact = new Contact() { ContactId = "id", EmailAddress = "email" }, OptInMarketResearch = true, OptInUserResearch = true, GivenName = "First Name", CustomerId = Guid.Parse("a9dacf19-d11f-45b6-a958-8a4cf24f1407"), FamilyName = "Surname" }; }
public void When_GetActionPlans_Return_ActionPlans() { _dssService = new DssService(_restClient, _dssSettings, _logger); var result = _dssService.GetActionPlans("somecustomerid"); result.Should().NotBe(null); }
public void Setup(string dssSuccess) { Logger = Substitute.For <ILogger <DssService> >(); var mockHandler = DssHelpers.GetMockMessageHandler(dssSuccess, statusToReturn: HttpStatusCode.Created); RestClient = new RestClient(mockHandler.Object); DssSettings = Options.Create(new DssSettings() { ApiKey = "9238dfjsjdsidfs83fds", SessionApiUrl = "https://this.is.anApi.org.uk", CustomerApiVersion = "V3", CustomerApiUrl = "https://this.is.anApi.org.uk", SessionApiVersion = "V3", GoalsApiUrl = "https://this.is.anApi.org.uk", GoalsApiVersion = "V2", ActionsApiUrl = "https://this.is.anApi.org.uk", ActionsApiVersion = "v3", InteractionsApiUrl = "https://this.is.anApi.org.uk", AdviserDetailsApiVersion = "v2", AdviserDetailsApiUrl = "https://this.is.anApi.org.uk", TouchpointId = "9000000001" }); DssService = new DssService(RestClient, DssSettings, Logger); }
public EditYourDetailsController(IOptions <CompositeSettings> compositeSettings, IAuthService authService, IDssReader dssReader, IDssWriter dssWriter, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, authService, documentService, config) { _dssReader = dssReader; _dssWriter = dssWriter; }
public void Init() { _documentService = Substitute.For <IDocumentService <CmsApiSharedContentModel> >(); var inMemorySettings = new Dictionary <string, string> { { Constants.SharedContentGuidConfig, Guid.NewGuid().ToString() } }; _config = new ConfigurationBuilder() .AddInMemoryCollection(inMemorySettings) .Build(); _logger = new Logger <HomeController>(new LoggerFactory()); _compositeSettings = Options.Create(new CompositeSettings()); _logger = Substitute.For <ILogger <HomeController> >(); _authService = Substitute.For <IAuthService>(); _skillsHealthCheckService = Substitute.For <ISkillsHealthCheckService>(); _dssReader = Substitute.For <IDssReader>(); _authSettings = Options.Create(new AuthSettings { RegisterUrl = "reg", SignInUrl = "signin", SignOutUrl = "signout" }); _actionPlansSettings = Options.Create(new ActionPlansSettings() { Url = "/actionj-plans" }); _controller = new HomeController(_logger, _compositeSettings, _authService, _dssReader, _skillsHealthCheckService, _authSettings, _actionPlansSettings, _documentService, _config); }
public ErrorController(ILogger <ErrorController> logger, IOptions <CompositeSettings> compositeSettings, IDssReader _dssReader, ICosmosService cosmosServiceService, IOptions <CompositeSettings> configuration, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, _dssReader, cosmosServiceService, documentService, config) { _configuration = configuration.Value; }
public ChangeGoalStatusController(ILogger <ChangeGoalStatusController> logger, IOptions <CompositeSettings> compositeSettings, IDssReader dssReader, IDssWriter dssWriter, ICosmosService cosmosServiceService, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, dssReader, cosmosServiceService, documentService, config) { _dssWriter = dssWriter; _dssReader = dssReader; ViewModel.GeneratePageTitle("Change goal status"); }
public async Task When_GetCustomerAddressDetails_Return_NullAddress() { var mockHandler = DssHelpers.GetMockMessageHandler("", statusToReturn: HttpStatusCode.NoContent); _restClient = new RestClient(mockHandler.Object); _dssService = new DssService(_restClient, _dssSettings, _logger); var result = await _dssService.GetCustomerAddressDetails("993cfb94-12b7-41c4-b32d-7be9331174f1", new HttpRequestMessage()); result.Should().BeNull(); }
public async Task When_GetCustomerDetail_Return_Customer() { var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDssCustomerCreation(), statusToReturn: HttpStatusCode.OK); _restClient = new RestClient(mockHandler.Object); _dssService = new DssService(_restClient, _dssSettings, _logger); var result = await _dssService.GetCustomerDetail("993cfb94-12b7-41c4-b32d-7be9331174f1", new HttpRequestMessage()); result.Should().NotBeNull(); }
public void When_GetActionPlansWithNoContent_Return_EmptyList() { var restClient = Substitute.For <IRestClient>(); restClient.LastResponse = new RestClient.APIResponse(new HttpResponseMessage(HttpStatusCode.NoContent)); _dssService = new DssService(restClient, _dssSettings, _logger); var result = _dssService.GetActionPlans("somecustomerid"); result.Result.Count.Should().Be(0); }
public HomeController(ILogger <HomeController> logger, IOptions <CompositeSettings> compositeSettings, IAuthService authService, IDssReader dssReader, ISkillsHealthCheckService skillsHealthCheckService, IOptions <AuthSettings> authSettings, IOptions <ActionPlansSettings> actionPlansSettings, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, authService, documentService, config) { Throw.IfNull(skillsHealthCheckService, nameof(skillsHealthCheckService)); _skillsHealthCheckService = skillsHealthCheckService; _authSettings = authSettings.Value; _dssReader = dssReader; _actionPlansSettings = actionPlansSettings.Value; _logger = logger; }
protected CompositeSessionController(IOptions <CompositeSettings> compositeSettings, IDssReader dssReader, ICosmosService cosmosServiceService, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(cosmosServiceService) { ViewModel = new TViewModel() { CompositeSettings = compositeSettings.Value, }; _dssReader = dssReader; _documentService = documentService; _sharedContent = config.GetValue <Guid>(DFC.APP.ActionPlans.Data.Common.Constants.SharedContentGuidConfig); }
public HomeController(ILogger <HomeController> logger, IOptions <CompositeSettings> compositeSettings, IDssReader dssReader, IDssWriter dssWriter, ICosmosService cosmosServiceService, IOptions <AuthSettings> authSettings, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, dssReader, cosmosServiceService, documentService, config) { _dssReader = dssReader; _dssWriter = dssWriter; _authSettings = authSettings; _logger = logger; _sharedContent = config.GetValue <Guid>(Constants.SharedContentGuidConfig); _documentService = documentService; }
public async Task When_GetCustomerDetailWithNoData_Throw_DSSException() { var mockHandler = DssHelpers.GetMockMessageHandler("&$a", statusToReturn: HttpStatusCode.NoContent); _restClient = new RestClient(mockHandler.Object); _dssService = new DssService(_restClient, _dssSettings, _logger); _dssService.Invoking(sut => sut.GetCustomerDetail("993cfb94-12b7-41c4-b32d-7be9331174f1", new HttpRequestMessage())) .Should().Throw <DssException>() .WithMessage("Failure Customer Details*"); }
public void When_GetActionPlansWithException_Return_Exception() { var restClient = Substitute.For <IRestClient>(); restClient.LastResponse = new RestClient.APIResponse(new HttpResponseMessage(HttpStatusCode.Unauthorized)); restClient.GetAsync <IList <ActionPlan> >(Arg.Any <string>(), Arg.Any <HttpRequestMessage>()).Returns <IList <ActionPlan> >(x => { throw new DssException("Failure Action Plans"); }); _dssService = new DssService(restClient, _dssSettings, _logger); _dssService.Invoking(sut => sut.GetActionPlans("993cfb94-12b7-41c4-b32d-7be9331174f1")) .Should().Throw <DssException>(); }
public void Init() { _documentService = Substitute.For <IDocumentService <CmsApiSharedContentModel> >(); var inMemorySettings = new Dictionary <string, string> { { Constants.SharedContentGuidConfig, Guid.NewGuid().ToString() } }; _config = new ConfigurationBuilder() .AddInMemoryCollection(inMemorySettings) .Build(); _compositeSettings = Options.Create(new CompositeSettings()); _authService = Substitute.For <IAuthService>(); _dssWriter = Substitute.For <IDssWriter>(); _dssReader = Substitute.For <IDssReader>(); }
public void SetupBase() { user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "example name"), new Claim(ClaimTypes.NameIdentifier, "1"), new Claim("CustomerId", new Guid().ToString()), }, "mock")); _compositeSettings = Options.Create(new CompositeSettings { Cdn = "cdn", Path = "Path" }); _dssReader = Substitute.For <IDssReader>(); _dssWriter = Substitute.For <IDssWriter>(); _cosmosService = Substitute.For <ICosmosService>(); _authSettings = Options.Create(new AuthSettings { }); var customer = new Customer { CustomerId = new Guid("c2e27821-cc60-4d3d-b4f0-cbe20867897c"), FamilyName = "familyName", GivenName = "givenName" }; var adviser = new Adviser { AdviserDetailId = new Guid().ToString(), AdviserName = null, AdviserEmailAddress = null, AdviserContactNumber = null, LastModifiedDate = default,
public StartController(ILogger <StartController> logger, IOptions <CompositeSettings> compositeSettings, IDssReader dssReader, ICosmosService cosmosServiceService) //: base(compositeSettings, dssReader, cosmosServiceService) { }
public ViewActionController(ILogger <ViewActionController> logger, IOptions <CompositeSettings> compositeSettings, IDssReader dssReader, ICosmosService cosmosServiceService, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, dssReader, cosmosServiceService, documentService, config) { _dssReader = dssReader; }
public YourDetailsController(ILogger <YourDetailsController> logger, IOptions <CompositeSettings> compositeSettings, IDssReader dssService, IAuthService authService, IDocumentService <CmsApiSharedContentModel> documentService, IConfiguration config) : base(compositeSettings, authService, documentService, config) { _dssService = dssService; }
public AuthServiceTests() { _dssService = Substitute.For <IDssReader>(); _httpContextAccessor = Substitute.For <IHttpContextAccessor>(); }
public AuthService(IDssReader dssReader, IHttpContextAccessor httpContextAccessor) { _dssReader = dssReader; _httpContextAccessor = httpContextAccessor; }