示例#1
0
        public void Calling_GetFreePlanGwei_SafeLow_Exact_70Percent_Of_Average_As_of_100_HappyPath()
        {
            var ethGasStationPrice = new EthGasStationPrice {
                Fast = "36", FastWait = "1", Average = "100", AverageWait = "4", SafeLow = "70", SafeLowWait = "25"
            };

            ethClientMock.Setup(s => s.GetJsonResponseContent(It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(JsonConvert.SerializeObject(ethGasStationPrice)));

            var actualResult = etheHelper.GetFreePlanGwei("dummyEndPoint", default).GetAwaiter().GetResult();

            Assert.AreEqual(ethGasStationPrice.SafeLowGwei, actualResult.Gwei);
            Assert.AreEqual(new TimeSpan(0, ethGasStationPrice.SafeLowWait.AsInt(), 0), actualResult.WaitTime);
        }
示例#2
0
        public void Calling_GetFreePlanGwei_SafeLow_Below_70Percent_Of_Average_HappyPath()
        {
            var ethGasStationPrice = new EthGasStationPrice {
                Fast = "36", FastWait = "1", Average = "89", AverageWait = "4", SafeLow = "62", SafeLowWait = "25"
            };

            ethClientMock.Setup(s => s.GetJsonResponseContent(It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(JsonConvert.SerializeObject(ethGasStationPrice)));

            var actualResult = etheHelper.GetFreePlanGwei("dummyEndPoint", default).GetAwaiter().GetResult();

            Assert.AreEqual(Math.Ceiling(ethGasStationPrice.AverageGwei * .7), actualResult.Gwei);
            Assert.AreEqual(new TimeSpan(0, ethGasStationPrice.AverageWait.AsInt(), 0), actualResult.WaitTime);
            loggerMock.Verify(s => s.Information($"FastGwei: '{ethGasStationPrice.FastGwei}', AverageGwei: '{ethGasStationPrice.AverageGwei}', SafeLowGwei: '{ethGasStationPrice.SafeLowGwei}'"), Times.Once);
        }