Esempio n. 1
0
        public async Task TransactionSearch_EmptySearchResult_ShouldSucceed()
        {
            var mapper = new EthereumTransactionMapper();
            var ethereumServiceMock = new Mock <IEthereumService>();

            // mock returning an empty list
            ethereumServiceMock.Setup(s => s.GetTransactionsByBlockNumberAsync(It.IsAny <long>()))
            .ReturnsAsync(new List <EthereumTransaction>());

            var action = new EthereumTransactionSearchActionHandler(ethereumServiceMock.Object, mapper);

            var searchRequest = new EthereumTransactionSearchRequest
            {
                Address     = "0x12345",
                BlockNumber = "12345"
            };

            // act
            var actual = await action.Search(searchRequest);

            // assert
            Assert.NotNull(actual);
            Assert.Empty(actual.Transactions);
            Assert.False(actual.TransientError);
        }
Esempio n. 2
0
        public async Task TransactionSearch_ShouldMatchOneTransaction_UsingToField(string addressToMatch)
        {
            var mapper = new EthereumTransactionMapper();
            var ethereumServiceMock = new Mock <IEthereumService>();

            // mock returning a list of transactions
            var transactions = TestFactory.MakeMockTransactions();

            ethereumServiceMock.Setup(s => s.GetTransactionsByBlockNumberAsync(It.IsAny <long>()))
            .ReturnsAsync(transactions);

            var action = new EthereumTransactionSearchActionHandler(ethereumServiceMock.Object, mapper);

            var searchRequest = new EthereumTransactionSearchRequest
            {
                Address     = addressToMatch,
                BlockNumber = "0x8b99c9"
            };

            // act
            var actual = await action.Search(searchRequest);

            // assert
            Assert.NotNull(actual);
            Assert.Single(actual.Transactions);
            Assert.False(actual.TransientError);
        }
Esempio n. 3
0
        public async Task TransactionSearch_ThrowException_ShouldReturnEmpty()
        {
            var mapper = new EthereumTransactionMapper();
            var ethereumServiceMock = new Mock <IEthereumService>();

            // mock returning a list of transactions
            var transactions = TestFactory.MakeMockTransactions();

            ethereumServiceMock.Setup(s => s.GetTransactionsByBlockNumberAsync(It.IsAny <long>()))
            .ThrowsAsync(new HttpRequestException());

            var action = new EthereumTransactionSearchActionHandler(ethereumServiceMock.Object, mapper);

            var searchRequest = new EthereumTransactionSearchRequest
            {
                Address     = "invalidAddress",
                BlockNumber = "0x8b99c9"
            };

            // act
            var actual = await action.Search(searchRequest);

            // assert
            Assert.NotNull(actual);
            Assert.Empty(actual.Transactions);
            Assert.True(actual.TransientError);
        }