Exemple #1
0
        public void ShouldSetValueUsingProtobufFormatters()
        {
            // Given
            const int    id            = 1;
            const string expectedValue = "test";

            var client = new ValuesServiceClient(
                x => x.WithBaseUrl(Fixture.Server.BaseAddress.ToString())
                .WithTimeout(TimeSpan.FromMilliseconds(Fixture.TimeoutInMilliseconds))
                .WithHttpMessageHandler(Fixture.Server.CreateHandler())
                .WithSerializer(
                    new ProtobufSerializer(s => s.WithDefaultSettings())
                    )
                );

            // When
            client.Set(new ValuesModificationRequest {
                Values = new[] { new ConfigurationValue {
                                     Id = id, Value = expectedValue
                                 } }
            });
            var actualValue = client.Get(id);

            // Then
            Assert.Equal(expectedValue, actualValue);
            Fixture.MockLogger
            .VerifyNoErrorsWasLogged()
            .VerifyNoWarningsWasLogged();
        }
        public ApiClient(ClientConfiguration configuration)
        {
            _valuesServiceClient = new ValuesServiceClient(configuration);
            ServicesClients.Add(_valuesServiceClient);

            _accountControllerClient = new AccountControllerClient(configuration);
            ServicesClients.Add(_accountControllerClient);
        }
        public ApiClient(ClientConfiguration configuration, HttpMessageHandler messageHandler)
        {
            _valuesServiceClient = new ValuesServiceClient(messageHandler, configuration);
            ServicesClients.Add(_valuesServiceClient);

            _accountControllerClient = new AccountControllerClient(messageHandler, configuration);
            ServicesClients.Add(_accountControllerClient);
        }
Exemple #4
0
        public ApiClient(Func <ClientConfiguration, ClientConfiguration> configurationBuilder)
        {
            _valuesServiceClient = new ValuesServiceClient(configurationBuilder);
            ServicesClients.Add(_valuesServiceClient);

            _accountControllerClient = new AccountControllerClient(configurationBuilder);
            ServicesClients.Add(_accountControllerClient);
        }
Exemple #5
0
        public void ShouldReturnBadRequestIfOperationWasCancelled()
        {
            // Given
            var client = new ValuesServiceClient(
                x => x.WithBaseUrl(Fixture.Server.BaseAddress.ToString())
                .WithTimeout(TimeSpan.FromMilliseconds(100))
                .WithHttpMessageHandler(Fixture.Server.CreateHandler())
                .WithSerializer(new JsonNetSerializer(new JsonSerializerSettings().UseDefaultSettings()))
                );

            Assert.Throws <BadRequestException>(() => client.Get());
            Fixture.MockLogger
            .VerifyNoErrorsWasLogged()
            .VerifyWarningWasLogged();
        }
Exemple #6
0
        public ApiClient(HttpClient httpClient, IOptions <ApiClientOptions> clientOptions)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }
            if (clientOptions == null)
            {
                throw new ArgumentNullException(nameof(clientOptions));
            }

            var optionsValue = clientOptions.Value;

            _valuesServiceClient = new ValuesServiceClient(
                httpClient,
                Options.Create(
                    new ValuesServiceClientOptions
            {
                BaseUrl    = optionsValue.BaseUrl,
                Timeout    = optionsValue.Timeout,
                Serializer = optionsValue.Serializer
            }
                    )
                );
            ServicesClients.Add(_valuesServiceClient);

            _accountControllerClient = new AccountControllerClient(
                httpClient,
                Options.Create(
                    new AccountControllerClientOptions
            {
                BaseUrl    = optionsValue.BaseUrl,
                Timeout    = optionsValue.Timeout,
                Serializer = optionsValue.Serializer
            }
                    )
                );
            ServicesClients.Add(_accountControllerClient);
        }
Exemple #7
0
 public ValuesControllerTests(BaseApiTestsFixture <Startup> fixture) : base(fixture)
 {
     _defaultClient = CreateClient <ValuesServiceClient, ValuesServiceClientOptions>();
 }