Beispiel #1
0
        public Task PostAsync_WithValidArgs_ShouldGenerateNewAddress()
        {
            return(AsynchronousTesting.WithCancellationTokenAsync(async cancellationToken =>
            {
                // Arrange.
                var address = new ReceivingAddress(
                    Guid.NewGuid(),
                    TestAddress.Regtest1,
                    false,
                    new Collection <ReceivingAddressReservation>());

                var request = new CreateReceivingAddressesRequest();

                this.pool
                .Setup(p => p.GenerateAddressAsync(It.IsAny <CancellationToken>()))
                .ReturnsAsync(address);

                // Act.
                var result = await this.subject.PostAsync(request, cancellationToken);

                // Assert.
                var ok = Assert.IsType <OkObjectResult>(result);
                var response = Assert.IsType <CreateReceivingAddressesResponse>(ok.Value);

                Assert.Equal(address.Address, response.Address);

                this.pool.Verify(p => p.GenerateAddressAsync(cancellationToken), Times.Once());
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> PostAsync(
            [FromBody] CreateReceivingAddressesRequest req,
            CancellationToken cancellationToken)
        {
            var address = await this.pool.GenerateAddressAsync(cancellationToken);

            return(Ok(new CreateReceivingAddressesResponse()
            {
                Address = address.Address,
            }));
        }