示例#1
0
        public async Task FetchReceipts_500_LogsErrorReturnsNull()
        {
            // Arrange
            _httpTest.RespondWith(status: 500);
            _smartContractService = new SmartContractService(_nodeOptions.Object, _logger.Object);

            // Act
            var result = await _smartContractService.FetchReceiptsAsync <Ticket>();

            // Assert
            _logger.VerifyLog(LogLevel.Error);
            Assert.That(result, Is.Null);
        }
示例#2
0
        public async Task FetchReceipts_200_ReturnsResponse()
        {
            // Arrange
            var receipts = new Receipt <object, Ticket>[]
            {
                new Receipt <object, Ticket>
                {
                    Logs = new LogDto <Ticket>[]
                    {
                        new LogDto <Ticket>
                        {
                            Log = new Ticket
                            {
                                Address = Address.Zero,
                                Seat    = new Seat {
                                    Number = 2, Letter = 'D'
                                },
                                Price              = 249500000,
                                Secret             = new byte[16],
                                CustomerIdentifier = new byte[32]
                            }
                        }
                    }
                }
            };

            _httpTest.RespondWithJson(receipts, status: 200);
            _smartContractService = new SmartContractService(_nodeOptions.Object, _logger.Object);

            // Act
            var result = await _smartContractService.FetchReceiptsAsync <Ticket>();

            // Assert
            var expected = JsonConvert.SerializeObject(receipts);
            var actual   = JsonConvert.SerializeObject(result);

            Assert.That(actual, Is.EqualTo(expected));
        }