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 void Init()
            {
                Logger = Substitute.For <ILogger <DssService> >();
                var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulUpdateActionPlan(),
                                                                   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",
                    ActionPlansApiUrl        = "https://this.is.anApi.org.uk",
                    ActionPlansApiVersion    = "v2",
                    AdviserDetailsApiUrl     = "https://this.is.anApi.org.uk",
                    TouchpointId             = "9000000001"
                });
                _dssWriter       = new DssService(RestClient, DssSettings, Logger);
                updateActionPlan = new ActionPlans.Services.DSS.Models.UpdateActionPlan()
                {
                    CustomerId    = new Guid(),
                    InteractionId = new Guid(),
                    ActionPlanId  = new Guid(),
                    DateActionPlanAcknowledged = DateTime.Now
                };
            }
        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 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 Setup()
        {
            _logger = Substitute.For <ILogger <DssService> >();
            var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDssCustomerCreation(), statusToReturn: HttpStatusCode.Created);

            _restClient = new RestClient(mockHandler.Object);
            _dssService = new DssService(_restClient, Options.Create(new DssSettings()
            {
                ApiKey               = "9238dfjsjdsidfs83fds",
                CustomerApiUrl       = "https://this.is.anApi.org.uk",
                AccountsTouchpointId = "9000000001",
                CustomerApiVersion   = "V1"
            }), _logger);
        }
        public void When_DeleteCustomerRequestEmptyGuid_ThrowException()
        {
            var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDssCustomerCreation(), statusToReturn: HttpStatusCode.InternalServerError);

            _restClient = new RestClient(mockHandler.Object);
            _dssService = new DssService(_restClient, Options.Create(new DssSettings()
            {
                ApiKey               = "9238dfjsjdsidfs83fds",
                CustomerApiUrl       = "https://this.is.anApi.org.uk",
                AccountsTouchpointId = "9000000001",
                CustomerApiVersion   = "V1"
            }), _logger);

            _dssService.Invoking(x => x.DeleteCustomer(Guid.Empty)).Should()
            .Throw <UnableToUpdateCustomerDetailsException>();
        }
        public async Task When_DeleteCustomerSuccess_ReturnOk()
        {
            var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDssCustomerCreation(), statusToReturn: HttpStatusCode.OK);

            _restClient = new RestClient(mockHandler.Object);
            _dssService = new DssService(_restClient, Options.Create(new DssSettings()
            {
                ApiKey               = "9238dfjsjdsidfs83fds",
                CustomerApiUrl       = "https://this.is.anApi.org.uk",
                AccountsTouchpointId = "9000000001",
                CustomerApiVersion   = "V1",
                DigitalIdentitiesPatchByCustomerIdApiVersion = "https://this.is.anApi.org.uk",
                DigitalIdentitiesPatchByCustomerIdApiUrl     = "https://this.is.anApi.org.uk",
            }), _logger);
            await _dssService.DeleteCustomer(Guid.NewGuid());
        }
        public async Task IfApiCallIsUnSuccessful_ReturnNull()
        {
            var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDssCustomerCreation(), statusToReturn: HttpStatusCode.InternalServerError);

            _restClient = new RestClient(mockHandler.Object);
            _dssService = new DssService(_restClient, Options.Create(new DssSettings()
            {
                ApiKey               = "9238dfjsjdsidfs83fds",
                CustomerApiUrl       = "https://this.is.anApi.org.uk",
                AccountsTouchpointId = "9000000001",
                CustomerApiVersion   = "V1"
            }), _logger);

            var result = await _dssService.CreateCustomerData(new Customer());

            result.Should().BeNull();
        }
        public void Setup()
        {
            _logger = Substitute.For <ILogger <DssService> >();
            var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDssCustomerCreation(), statusToReturn: HttpStatusCode.Created);

            _restClient  = new RestClient(mockHandler.Object);
            _dssSettings = Options.Create(new DssSettings()
            {
                ApiKey                           = "0000dfjsjdsidfs83fds",
                CustomerApiUrl                   = "https://this.is.anApi.org.uk/api/Customers/",
                AccountsTouchpointId             = "9000000000",
                CustomerApiVersion               = "V2",
                CustomerAddressDetailsApiUrl     = "https://this.is.anApi.org.uk/api/Customers/{customerId}/Addresses",
                CustomerAddressDetailsApiVersion = "V2",
                CustomerContactDetailsApiUrl     = "https://this.is.anApi.org.uk/customers/{customerId}/ContactDetails/",
                CustomerContactDetailsApiVersion = "V2"
            });
        }
        public void Setup()
        {
            _logger = Substitute.For <ILogger <DssService> >();
            var mockHandler = DssHelpers.GetMockMessageHandler(DssHelpers.SuccessfulDigitalIdentitiesCustomerUpdateDetails(), statusToReturn: HttpStatusCode.Created);

            _restClient  = new RestClient(mockHandler.Object);
            _dssSettings = Options.Create(new DssSettings()
            {
                ApiKey                                       = "0000dfjsjdsidfs83fds",
                CustomerApiUrl                               = "https://this.is.anApi.org.uk/api/Customers/",
                AccountsTouchpointId                         = "9000000000",
                CustomerApiVersion                           = "V2",
                CustomerAddressDetailsApiUrl                 = "https://this.is.anApi.org.uk/api/Customers/{customerId}/Addresses",
                CustomerAddressDetailsApiVersion             = "V2",
                CustomerContactDetailsApiUrl                 = "https://this.is.anApi.org.uk/customers/{customerId}/ContactDetails/",
                CustomerContactDetailsApiVersion             = "V2",
                ActionPlansApiUrl                            = "SomeAPI",
                ActionPlansApiVersion                        = "V2",
                DigitalIdentitiesPatchByCustomerIdApiUrl     = "https://at.api.nationalcareersservice.org.uk/digitalidentities/api/customer/{customerId}",
                DigitalIdentitiesPatchByCustomerIdApiVersion = "v2"
            });
        }