Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Nov 12, 2018
1 parent ecc8c99 commit b5180e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Stripe.net/Entities/Invoices/Invoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ internal object InternalDefaultSource
public long? EndingBalance { get; set; }

[JsonProperty("finalized_at")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? FinalizedAt { get; set; }

[JsonProperty("hosted_invoice_url")]
Expand Down
17 changes: 13 additions & 4 deletions src/StripeTests/Entities/Charges/ChargeTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
namespace StripeTests
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using Newtonsoft.Json;
using Stripe;
using Xunit;
Expand All @@ -19,6 +15,7 @@ public void Deserialize()
Assert.IsType<Charge>(charge);
Assert.NotNull(charge.Id);
Assert.Equal("charge", charge.Object);
Assert.NotNull(charge.Source);
}

[Fact]
Expand Down Expand Up @@ -83,5 +80,17 @@ public void DeserializeWithExpansions()
Assert.NotNull(charge.Transfer);
Assert.Equal("transfer", charge.Transfer.Object);
}

[Fact]
public void DeserializeWithJsonConvert()
{
string json = GetFixture("/v1/charges/ch_123");
var charge = JsonConvert.DeserializeObject<Charge>(json);
Assert.NotNull(charge);
Assert.IsType<Charge>(charge);
Assert.NotNull(charge.Id);
Assert.Equal("charge", charge.Object);
Assert.NotNull(charge.Source);
}
}
}
18 changes: 16 additions & 2 deletions src/StripeTests/Entities/Events/EventTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace StripeTests
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe;
using Xunit;

Expand Down Expand Up @@ -38,5 +37,20 @@ public void DeserializePreviousAttributes()
Assert.NotNull(evt.Data.PreviousAttributes.metadata["foo"]);
Assert.Equal("bar", (string)evt.Data.PreviousAttributes.metadata["foo"]);
}

[Fact]
public void DeserializeWithJsonConvert()
{
var json = GetResourceAsString("api_fixtures.events.event_plan.json");
var evt = JsonConvert.DeserializeObject<Event>(json);
Assert.NotNull(evt);
Assert.IsType<Event>(evt);
Assert.NotNull(evt.Id);
Assert.Equal("event", evt.Object);

Assert.NotNull(evt.Data);
Assert.NotNull(evt.Data.Object);
Assert.IsType<Plan>(evt.Data.Object);
}
}
}

0 comments on commit b5180e7

Please sign in to comment.