1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "components/payments/core/payment_response.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace payments {
10 
11 // Tests that two payment response objects are not equal if their property
12 // values differ or one is missing a value present in the other, and equal
13 // otherwise. Doesn't test all properties of child objects, relying instead on
14 // their respective tests.
TEST(PaymentRequestTest,PaymentResponseEquality)15 TEST(PaymentRequestTest, PaymentResponseEquality) {
16   PaymentResponse response1;
17   PaymentResponse response2;
18   EXPECT_EQ(response1, response2);
19 
20   response1.method_name = "Visa";
21   EXPECT_NE(response1, response2);
22   response2.method_name = "Mastercard";
23   EXPECT_NE(response1, response2);
24   response2.method_name = "Visa";
25   EXPECT_EQ(response1, response2);
26 
27   std::string stringified_card_response1 =
28       "{ \"cardNumber\": \"4111111111111111\", \"cardSecurityCode\": \"111\", "
29       "\"cardholderName\": \"John Doe\", \"expiryMonth\": \"12\", "
30       "\"expiryYear\": \"2020\" }";
31   std::string stringified_card_response2 =
32       "{ \"cardNumber\": \"4111111111111111\", \"cardSecurityCode\": \"333\", "
33       "\"cardholderName\": \"John Doe\", \"expiryMonth\": \"12\", "
34       "\"expiryYear\": \"2020\" }";
35   response1.details = stringified_card_response1;
36   EXPECT_NE(response1, response2);
37   response2.details = stringified_card_response2;
38   EXPECT_NE(response1, response2);
39   response2.details = stringified_card_response1;
40   EXPECT_EQ(response1, response2);
41 }
42 
43 }  // namespace payments
44