public async Task When_UpdateGoalNoSuccess_Throw_Exception()
            {
                var restClient = Substitute.For <IRestClient>();

                restClient.LastResponse = new RestClient.APIResponse(new HttpResponseMessage(HttpStatusCode.NoContent))
                {
                    IsSuccess = false
                };
                _dssWriter = new DssService(restClient, DssSettings, Logger);

                _dssWriter.Invoking(sut => sut.UpdateAction(updateAction))
                .Should().Throw <DssException>();
            }
        public async Task When_UpdateLastLoginWithException_Return_Exception()
        {
            var restClient = Substitute.For <IRestClient>();

            restClient.LastResponse = new RestClient.APIResponse(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            var token = "test";

            restClient.GetAsync <string>(Arg.Any <string>(), Arg.Any <HttpRequestMessage>()).Returns <string>(x => { throw new DssException("Customer"); });

            _dssService = new DssService(restClient, _dssSettings, _logger);

            _dssService.Invoking(async sut => await sut.UpdateLastLogin(new Guid(), token))
            .Should().Throw <DssException>();
        }
        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_UpdateGoalErrors_Throw_Exception()
            {
                var restClient = Substitute.For <IRestClient>();

                restClient.LastResponse = new RestClient.APIResponse(new HttpResponseMessage(HttpStatusCode.NoContent))
                {
                    IsSuccess = false
                };
                _dssWriter = new DssService(restClient, DssSettings, Logger);

                restClient.PatchAsync <Goal>(Arg.Any <string>(), Arg.Any <HttpRequestMessage>())
                .ThrowsForAnyArgs <Exception>();

                _dssWriter.Invoking(sut => sut.UpdateAction(updateAction))
                .Should().Throw <DssException>();
                Logger.ReceivedCalls().Count().Equals(1);
            }