示例#1
0
        public void test_callback()
        {
            var json = @"{
  ""order"": {
    ""id"": ""5RTQNACF"",
    ""created_at"": ""2012-12-09T21:23:41-08:00"",
    ""status"": ""completed"",
    ""total_btc"": {
      ""cents"": 100000000,
      ""currency_iso"": ""BTC""
    },
    ""total_native"": {
      ""cents"": 1253,
      ""currency_iso"": ""USD""
    },
    ""custom"": ""order1234"",
    ""receive_address"": ""1NhwPYPgoPwr5hynRAsto5ZgEcw1LzM3My"",
    ""button"": {
      ""type"": ""buy_now"",
      ""name"": ""Alpaca Socks"",
      ""description"": ""The ultimate in lightweight footwear"",
      ""id"": ""5d37a3b61914d6d0ad15b5135d80c19f""
    },
    ""transaction"": {
      ""id"": ""514f18b7a5ea3d630a00000f"",
      ""hash"": ""4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"",
      ""confirmations"": 0
    },
    ""customer"": {
      ""email"": ""[email protected]"",
      ""shipping_address"": [
        ""John Smith"",
        ""123 Main St."",
        ""Springfield, OR 97477"",
        ""United States""
      ]
    }
  }
}";
            var obj  = JsonConvert.DeserializeObject <Mvc.CoinbaseCallback>(json);

            obj.Should().NotBeNull();

            var truth = new Mvc.CoinbaseCallback
            {
                Order = new Order
                {
                    Button = new ButtonDesc
                    {
                        Type        = ButtonType.BuyNow,
                        Name        = "Alpaca Socks",
                        Description = "The ultimate in lightweight footwear",
                        Id          = "5d37a3b61914d6d0ad15b5135d80c19f"
                    },
                    CreatedAt = DateTime.Parse("2012-12-09T21:23:41-08:00"),
                    Status    = Status.Completed,
                    Id        = "5RTQNACF",
                    TotalBtc  = new Price
                    {
                        Cents    = 100000000,
                        Currency = Currency.BTC
                    },
                    TotalNative = new Price
                    {
                        Cents    = 1253,
                        Currency = Currency.USD
                    },
                    Custom         = "order1234",
                    ReceiveAddress = "1NhwPYPgoPwr5hynRAsto5ZgEcw1LzM3My",
                    Transaction    = new Transaction
                    {
                        Id            = "514f18b7a5ea3d630a00000f",
                        Hash          = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
                        Confirmations = 0
                    },
                    Customer = new Customer
                    {
                        Email           = "[email protected]",
                        ShippingAddress = new[]
                        {
                            "John Smith",
                            "123 Main St.",
                            "Springfield, OR 97477",
                            "United States"
                        }
                    }
                }
            };


            obj.ShouldBeEquivalentTo(truth);
        }
        public void test_callback()
        {
            var json = @"{
              ""order"": {
            ""id"": ""5RTQNACF"",
            ""created_at"": ""2012-12-09T21:23:41-08:00"",
            ""status"": ""completed"",
            ""total_btc"": {
              ""cents"": 100000000,
              ""currency_iso"": ""BTC""
            },
            ""total_native"": {
              ""cents"": 1253,
              ""currency_iso"": ""USD""
            },
            ""custom"": ""order1234"",
            ""receive_address"": ""1NhwPYPgoPwr5hynRAsto5ZgEcw1LzM3My"",
            ""button"": {
              ""type"": ""buy_now"",
              ""name"": ""Alpaca Socks"",
              ""description"": ""The ultimate in lightweight footwear"",
              ""id"": ""5d37a3b61914d6d0ad15b5135d80c19f""
            },
            ""transaction"": {
              ""id"": ""514f18b7a5ea3d630a00000f"",
              ""hash"": ""4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"",
              ""confirmations"": 0
            },
            ""customer"": {
              ""email"": ""[email protected]"",
              ""shipping_address"": [
            ""John Smith"",
            ""123 Main St."",
            ""Springfield, OR 97477"",
            ""United States""
              ]
            }
              }
            }";
            var obj = JsonConvert.DeserializeObject<Mvc.CoinbaseCallback>( json );

            obj.Should().NotBeNull();

            var truth = new Mvc.CoinbaseCallback
                {
                    Order = new Order
                        {
                            Button = new ButtonDesc
                                {
                                    Type = ButtonType.BuyNow,
                                    Name = "Alpaca Socks",
                                    Description = "The ultimate in lightweight footwear",
                                    Id = "5d37a3b61914d6d0ad15b5135d80c19f"
                                },
                            CreatedAt = DateTime.Parse( "2012-12-09T21:23:41-08:00" ),
                            Status = Status.Completed,
                            Id = "5RTQNACF",
                            TotalBtc = new Price
                                {
                                    Cents = 100000000,
                                    Currency = Currency.BTC
                                },
                            TotalNative = new Price
                                {
                                    Cents = 1253,
                                    Currency = Currency.USD
                                },
                            Custom = "order1234",
                            ReceiveAddress = "1NhwPYPgoPwr5hynRAsto5ZgEcw1LzM3My",
                            Transaction = new Transaction
                                {
                                    Id = "514f18b7a5ea3d630a00000f",
                                    Hash = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
                                    Confirmations = 0
                                },
                            Customer = new Customer
                                {
                                    Email = "[email protected]",
                                    ShippingAddress = new[]
                                        {
                                            "John Smith",
                                            "123 Main St.",
                                            "Springfield, OR 97477",
                                            "United States"
                                        }
                                }
                        }

                };

            obj.ShouldBeEquivalentTo( truth );
        }