Esempio n. 1
0
        public async Task GetTransOnBlockNumAndAddr_ShouldReturnOKRequst_whenInputIsInvalid(string blockNum, string addr)
        {
            //arrange
            var mockTransactionsProcessor = new Mock <ITransactionsProcessor>();
            var mockLogger = new Mock <ILogger>();
            var mockTransactionsDetailsService = new Mock <ITransactionsDetailsService>();

            mockTransactionsProcessor.Setup(_ => _.GetTransactionsByAddress(It.IsAny <List <TransactionsByBlockNumber> >(), It.IsAny <string>()))
            .Returns(new List <GetTransactionsResponse>());
            var _testee = new EthereumQueryFunctions(mockTransactionsDetailsService.Object, mockTransactionsProcessor.Object);

            //act
            var result = await _testee.GetTransactionsByBlockNumAndAddress(null, blockNum, addr, mockLogger.Object);

            //assert
            result.Should().BeOfType(typeof(OkObjectResult));
        }
Esempio n. 2
0
        public async Task GetTransOnBlockNumAndAddr_ShouldReturnBadRequst_whenAddrIsInvalid(string blockNum, string addr)
        {
            //arrange
            var mockTransactionsProcessor = new Mock <ITransactionsProcessor>();
            var mockLogger = new Mock <ILogger>();
            var mockTransactionsDetailsService = new Mock <ITransactionsDetailsService>();
            var _testee = new EthereumQueryFunctions(mockTransactionsDetailsService.Object, mockTransactionsProcessor.Object);

            //act
            var result = await _testee.GetTransactionsByBlockNumAndAddress(null, blockNum, addr, mockLogger.Object);

            //assert
            result.Should().BeOfType(typeof(BadRequestObjectResult));
            var badResult = result as BadRequestObjectResult;

            badResult.Value.ToString().Should().Contain("Invalid Address");
        }