Exemple #1
0
        public void Test_that_coins_to_receive_should_be_numbers_in_a_row_starting_from_zero(string coinsToReceiveNumbers, bool shouldThrow)
        {
            var coinToSpend = new CoinToSpend
                              (
                new CoinId("1", 1),
                new Asset("KIN"),
                UMoney.Create(100, 3),
                "A"
                              );
            var coinsToReceive = coinsToReceiveNumbers
                                 .Split(',')
                                 .Select(x => new CoinToReceive
                                         (
                                             int.Parse(x),
                                             new Asset("KIN"),
                                             UMoney.Create(1, 3),
                                             "B"
                                         ))
                                 .ToArray();

            if (shouldThrow)
            {
                Assert.Throws <RequestValidationException>(() => TransactionCoinsValidator.Validate(new[] { coinToSpend }, coinsToReceive));
            }
            else
            {
                Assert.DoesNotThrow(() => TransactionCoinsValidator.Validate(new[] { coinToSpend }, coinsToReceive));
            }
        }
Exemple #2
0
        public void Test_that_empty_collections_are_not_allowed()
        {
            // Arrange

            var coinToSpend = new CoinToSpend
                              (
                new CoinId("1", 1),
                new Asset("KIN"),
                UMoney.Create(100, 3),
                "A"
                              );
            var coinToReceive = new CoinToReceive
                                (
                0,
                new Asset("KIN"),
                UMoney.Create(100, 3),
                "A"
                                );

            // Act, Throw

            Assert.Throws <RequestValidationException>
            (
                () => TransactionCoinsValidator.Validate(null, new[] { coinToReceive })
            );

            Assert.Throws <RequestValidationException>
            (
                () => TransactionCoinsValidator.Validate(Array.Empty <CoinToSpend>(), new[] { coinToReceive })
            );

            Assert.Throws <RequestValidationException>
            (
                () => TransactionCoinsValidator.Validate(new[] { coinToSpend }, null)
            );

            Assert.Throws <RequestValidationException>
            (
                () => TransactionCoinsValidator.Validate(new[] { coinToSpend }, Array.Empty <CoinToReceive>())
            );
        }