require File.dirname(__FILE__) + '/../../test_helper'

class OrdersServiceTestCase < Test::Unit::TestCase
  def test_add_product
    new_id = OrdersServiceClient.add_product("Produkt testowy", 50, 1000)
    assert new_id
  end

  def test_place_order
    p = OrdersServiceClient.add_product("Produkt testowy", 50, 1000)
    li = Logical::LineItem.new(
      :product_id => p,
      :quantity => 1
    )

    ad = Logical::Address.new(
      :line_1 => '123 Foobar Lane',
      :city => 'Cambridge',
      :state => 'MA',
      :zip_code => '02139'
    )

    cc = Logical::Creditcard.new(
      :card_number => '5555555555555555',
      :expiration_month => '12',
      :expiration_year => '2015',
      :type => Logical::CreditCard::AMERICAN_EXPRESS
    )

    payment = Logical::Payment.new(
      :address => ad,
      :type => Logical::Payment::CREDIT_CARD,
      :credit_card => cc
    )

    result = OrdersServiceClient.place_order(
      [li, li, li, li], payment
    )
    assert result.confirmation
    assert result.price == 4000
  end
end


