public async Task Can_create_address_tag()
        {
            //ARRANGE
            var address        = Guid.NewGuid().ToString();
            var tag            = Guid.NewGuid().ToString();
            var addressContext = "AddressContext";

            var client = PrepareClient <AppSettings>((options) =>
            {
                Mock <IAddressGenerator> addressGenerator   = new Mock <IAddressGenerator>();
                Mock <ITransactionSigner> transactionSigner = new Mock <ITransactionSigner>();

                addressGenerator.Setup(x => x.CreateAddressTagAsync(It.IsAny <string>(), It.IsAny <CreateAddressTagRequest>()))
                .ReturnsAsync(new CreateAddressTagResponse(new AddressTag(tag),
                                                           Base64String.Encode(addressContext)));

                options.IntegrationName          = $"{nameof(SignServiceClientTests)}+{nameof(Can_create_address_tag)}";
                options.AddressGeneratorFactory  = (context) => addressGenerator.Object;
                options.TransactionSignerFactory = (context) => transactionSigner.Object;
            });

            //ACT
            var request = new CreateAddressTagRequest(Base64String.Encode(addressContext), AddressTagType.Text);
            CreateAddressTagResponse result = await client.CreateAddressTagAsync(address, request);

            //ASSERT
            Assert.True(result != null);
            Assert.True(result.Tag?.Value == tag);
            Assert.True(result.TagContext?.DecodeToString() == addressContext);
        }
        public void Check_timeout()
        {
            //ARRANGE
            var address        = Guid.NewGuid().ToString();
            var tag            = Guid.NewGuid().ToString();
            var addressContext = "AddressContext";
            var timeout        = TimeSpan.FromMilliseconds(100);

            var client = PrepareClient <AppSettings>((options) =>
            {
                var addressGenerator  = new Mock <IAddressGenerator>();
                var transactionSigner = new Mock <ITransactionSigner>();

                addressGenerator.Setup(x =>
                                       x.CreateAddressTagAsync(It.IsAny <string>(), It.IsAny <CreateAddressTagRequest>()))
                .ReturnsAsync(() =>
                {
                    Thread.Sleep(timeout);
                    return(new CreateAddressTagResponse(new AddressTag(tag),
                                                        Base64String.Encode(addressContext)));
                });

                options.IntegrationName          = $"{nameof(SignServiceClientTests)}+{nameof(Can_create_address_tag)}";
                options.AddressGeneratorFactory  = (context) => addressGenerator.Object;
                options.TransactionSignerFactory = (context) => transactionSigner.Object;
            }, timeout);

            //ACT && ASSERT
            Assert.ThrowsAsync <TimeoutException>(async() =>
            {
                var request = new CreateAddressTagRequest(Base64String.Encode(addressContext), AddressTagType.Text);
                await client.CreateAddressTagAsync(address, request);
            });
        }
        public void Not_supported_address_tag_creation()
        {
            //ARRANGE
            var address        = Guid.NewGuid().ToString();
            var addressContext = "AddressContext";

            var client = PrepareClient <AppSettings>((options) =>
            {
                var addressGenerator  = new Mock <IAddressGenerator>();
                var transactionSigner = new Mock <ITransactionSigner>();

                addressGenerator.Setup(x => x.CreateAddressTagAsync(It.IsAny <string>(), It.IsAny <CreateAddressTagRequest>()))
                .ThrowsAsync(new OperationNotSupportedException("Tag creation operation is not supported."));

                options.IntegrationName          = $"{nameof(SignServiceClientTests)}+{nameof(Can_create_address_tag)}";
                options.AddressGeneratorFactory  = (context) => addressGenerator.Object;
                options.TransactionSignerFactory = (context) => transactionSigner.Object;
            });

            //ACT && ASSERT

            Assert.ThrowsAsync <NotImplementedWebApiException>(async() =>
            {
                var request = new CreateAddressTagRequest(Base64String.Encode(addressContext), AddressTagType.Text);
                await client.CreateAddressTagAsync(address, request);
            });
        }
        public async Task <CreateAddressTagResponse> CreateAddressTagAsync(string address, CreateAddressTagRequest request)
        {
            // Create tag (new GUID, usually) for deposit wallet, if shared deposit wallet scheme is used.
            //
            // Throw
            // - Lykke.Bil2.Sdk.Exceptions.OperationNotSupportedException:
            //     if address tag creation is not supported by the blockchain.
            //
            // For example:
            //
            // return new CreateAddressTagResponse(Guid.NewGuid().ToString("N"));


            throw new System.NotImplementedException();
        }
        public async Task <ActionResult <CreateAddressTagResponse> > CreateAddressTag([FromRoute] Address address, [FromBody] CreateAddressTagRequest request)
        {
            if (address == null)
            {
                throw RequestValidationException.ShouldBeNotNull(nameof(address));
            }

            var response = await _addressGenerator.CreateAddressTagAsync(address, request);

            if (response == null)
            {
                throw new InvalidOperationException("Not null response object expected");
            }

            return(Ok(response));
        }
 public Task <CreateAddressTagResponse> CreateAddressTagAsync(string address, CreateAddressTagRequest request)
 {
     throw new OperationNotSupportedException("Address tag is not supported");
 }