Ejemplo n.º 1
0
        public TriceratopsApiClient(IPlatformHttpClient httpClient)
        {
            httpClient.SetBaseUrl(Constants.InternalApiUrl);

            Servers = new ServerApiClient(httpClient);
            Storage = new StorageApiClient(httpClient);
        }
 public async Task ThrowArgumentNullExceptionWhenNoUrlIsPresentAsync()
 {
     // Arrange
     IStorageApiClient      storageApiClient = A.Fake <IStorageApiClient>();
     IRelayApiClient        relayApiClient   = A.Fake <IRelayApiClient>();
     IProxyRelayCallService sut = new ProxyRelayCallService(storageApiClient, relayApiClient);
     // Act & Assert
     await Assert.ThrowsAsync <ArgumentNullException>(() => sut.ProxyRelayCallAsync(TestHelper.TenantId.ToString(), "body", new HttpMethod(HttpMethods.Post), null, ""));
 }
 public async Task ThrowArgumentNullExceptionWhenNoTenantIdAsync()
 {
     // Arrange
     IStorageApiClient      storageApiClient = A.Fake <IStorageApiClient>();
     IRelayApiClient        relayApiClient   = A.Fake <IRelayApiClient>();
     IProxyRelayCallService sut = new ProxyRelayCallService(storageApiClient, relayApiClient);
     // Act & Assert
     await Assert.ThrowsAsync <ArgumentNullException>(() => sut.ProxyRelayCallAsync("", "body", new HttpMethod(HttpMethods.Post), null, "test/endpoint"));
 }
        public async Task ThrowInvalidOperationExceptionWhenCloudProviderDidNotReturnHybridConnectionAsync()
        {
            // Arrange
            IStorageApiClient storageApiClient = A.Fake <IStorageApiClient>();
            ICloudProviderHandlerApiClient cloudProviderHandlerApiClient = A.Fake <ICloudProviderHandlerApiClient>();
            IRelayManagementService        sut = new RelayManagementService(storageApiClient, cloudProviderHandlerApiClient);

            A.CallTo(() => cloudProviderHandlerApiClient.CreateRelayHybridConnection(TestHelper.TenantId.ToString())).WithAnyArguments().Returns <HybridConnectionDto>(null);
            // Act & Assert
            await Assert.ThrowsAsync <InvalidOperationException>(() => sut.StoreRelayAsync(TestHelper.GetCreateRelayStorageDto()));
        }
        public async Task ReturnHybridConnectionDtoWhenGetRelayIsCalledAsync()
        {
            // Arrange
            IStorageApiClient storageApiClient = A.Fake <IStorageApiClient>();
            ICloudProviderHandlerApiClient cloudProviderHandlerApiClient = A.Fake <ICloudProviderHandlerApiClient>();
            IRelayManagementService        sut = new RelayManagementService(storageApiClient, cloudProviderHandlerApiClient);

            A.CallTo(() => storageApiClient.GetRelayFromIdAsync(TestHelper.TenantId.ToString())).Returns(TestHelper.GetHybridConnectionDto());
            // Act
            HybridConnectionDto actual = await sut.GetRelayAsync(TestHelper.TenantId.ToString());

            // Assert
            Assert.Equal(TestHelper.GetHybridConnectionDto().HybridConnectionUrl, actual.HybridConnectionUrl);
        }
        public async Task ReturnStatusCodeOkayWhenProxyRelayWasSuccessfulAsync()
        {
            // Arrange
            IStorageApiClient      storageApiClient = A.Fake <IStorageApiClient>();
            IRelayApiClient        relayApiClient   = A.Fake <IRelayApiClient>();
            IProxyRelayCallService sut = new ProxyRelayCallService(storageApiClient, relayApiClient);

            A.CallTo(() => relayApiClient.RelayCallAsync(new RelayCallDto(TestHelper.GetHybridConnectionDto(), "body", new HttpMethod(HttpMethods.Post), null, "test/endpoint")))
            .Returns(new HttpResponseMessage(HttpStatusCode.OK));
            // Act
            HttpResponseMessage actual = await sut.ProxyRelayCallAsync(TestHelper.TenantId.ToString(), "body", new HttpMethod(HttpMethods.Post), null, "test/endpoint");

            // Assert
            Assert.Equal(HttpStatusCode.OK, actual.StatusCode);
        }
Ejemplo n.º 7
0
 public ProxyRelayCallService(IStorageApiClient storageApiClient, IRelayApiClient relayApiClient)
 {
     _storageApiClient = storageApiClient;
     _relayApiClient   = relayApiClient;
 }
Ejemplo n.º 8
0
 public OrdersController(Storage storage, IStorageApiClient client)
 {
     orders      = storage.data;
     _storage    = storage;
     this.client = client;
 }
 public RelayManagementService(IStorageApiClient storageApiClient, ICloudProviderHandlerApiClient cloudProviderHandlerApiClient)
 {
     _storageApiClient = storageApiClient;
     _cloudProviderHandlerApiClient = cloudProviderHandlerApiClient;
 }