Skip to content

Commit

Permalink
Merge pull request #65 from nozzlegear/3.0
Browse files Browse the repository at this point in the history
3.0 remove enums and replace them with strings.
  • Loading branch information
nozzlegear authored Sep 21, 2016
2 parents 35a199c + 8df13df commit 13dd883
Show file tree
Hide file tree
Showing 84 changed files with 163 additions and 918 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class When_activating_a_charge
Charge = Service.GetAsync(Charge.Id.Value).Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_activate_a_charge = () =>
{
// NOTE: This test will require you to set a break point after creating the charge but before activating it,
// grab the confirmation url and manually accept it, then continue the test.
Charge.Status.ShouldEqual(Enums.ShopifyChargeStatus.Active);
Charge.Status.ShouldEqual("active");
};

Cleanup after = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class When_creating_a_charge
Charge = Service.CreateAsync(Charge).Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_create_a_charge = () =>
{
Charge.ConfirmationUrl.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class When_listing_charges
Charges = Service.ListAsync().Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_retrieve_a_list_of_charges = () =>
{
Charges.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class When_retrieving_a_charge
Charge = Service.GetAsync(ChargeId).Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_retrieve_a_charge = () =>
{
Charge.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class When_publishing_a_custom_collection
It should_publish_a_custom_collection = () =>
{
Collection.ShouldNotBeNull();
Collection.PublishedAt.ShouldNotBeNull();
};

Cleanup after = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class When_getting_an_event
Event.Author.ShouldNotBeNull();
Event.CreatedAt.HasValue.ShouldBeTrue();
Event.Message.ShouldNotBeNull();
Event.Path.ShouldNotBeNull();
Event.SubjectId.ShouldBeGreaterThan(0);
Event.SubjectType.ShouldNotBeNull();
Event.Verb.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_cancelling_a_fulfillment
var fulfillment = FulfillmentCreation.GenerateFulfillment();

Id = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_completing_a_fulfillment
var fulfillment = FulfillmentCreation.GenerateFulfillment();

Id = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class When_counting_fulfillments
var items = Order.LineItems.Skip(i).Take(1);
var fulfillment = FulfillmentCreation.GenerateFulfillment(items: items);

Service.CreateAsync(Order.Id.Value, fulfillment, true).Await();
Service.CreateAsync(Order.Id.Value, fulfillment, false).Await();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class When_counting_fulfillments_with_a_filter
var items = Order.LineItems.Skip(i).Take(1);
var fulfillment = FulfillmentCreation.GenerateFulfillment(items: items);

Created.Add(Service.CreateAsync(Order.Id.Value, fulfillment, true).Await().AsTask.Result);
Created.Add(Service.CreateAsync(Order.Id.Value, fulfillment, false).Await().AsTask.Result);

//Wait 1 second so created fulfillments have differing times.
Thread.Sleep(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_creating_a_fulfillment
Because of = () =>
{
Fulfillment = Service
.CreateAsync(Order.Id.Value, FulfillmentCreation.GenerateFulfillment(), true)
.CreateAsync(Order.Id.Value, FulfillmentCreation.GenerateFulfillment(), false)
.Await()
.AsTask
.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class When_creating_a_fulfillment_with_multiple_tracking_numbers
var fulfillment = FulfillmentCreation.GenerateFulfillment(true);

Fulfillment = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class When_creating_a_partial_fulfillment
var fulfillment = FulfillmentCreation.GenerateFulfillment(false, Order.LineItems.Take(1));

Fulfillment = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result;
Expand All @@ -33,11 +33,6 @@ class When_creating_a_partial_fulfillment
Fulfillment.ShouldNotBeNull();
Fulfillment.Id.HasValue.ShouldBeTrue();
Fulfillment.Status.Equals("success", System.StringComparison.OrdinalIgnoreCase).ShouldBeTrue();

Fulfillment
.LineItems
.Count(f => f.FulfillmentStatus == Enums.ShopifyFulfillmentStatus.Partial)
.ShouldEqual(1);
};

Cleanup after = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class When_creating_a_single_fulfillment
var fulfillment = FulfillmentCreation.GenerateFulfillment(false, Order.LineItems.Take(1));

Fulfillment = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result;
Expand All @@ -29,11 +29,6 @@ class When_creating_a_single_fulfillment
Fulfillment.ShouldNotBeNull();
Fulfillment.Id.HasValue.ShouldBeTrue();
Fulfillment.Status.Equals("success", System.StringComparison.OrdinalIgnoreCase).ShouldBeTrue();

Fulfillment
.LineItems
.Count(f => f.FulfillmentStatus == Enums.ShopifyFulfillmentStatus.Fulfilled)
.ShouldEqual(1);
};

Cleanup after = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_getting_a_fulfillment
var fulfillment = FulfillmentCreation.GenerateFulfillment();

Id = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class When_listing_fulfillments
var items = Order.LineItems.Skip(i).Take(1);
var fulfillment = FulfillmentCreation.GenerateFulfillment(items: items);

Service.CreateAsync(Order.Id.Value, fulfillment, true).Await();
Service.CreateAsync(Order.Id.Value, fulfillment, false).Await();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class When_listing_fulfillments_with_a_filter
var items = Order.LineItems.Skip(i).Take(1);
var fulfillment = FulfillmentCreation.GenerateFulfillment(items: items);

Created.Add(Service.CreateAsync(Order.Id.Value, fulfillment, true).Await().AsTask.Result);
Created.Add(Service.CreateAsync(Order.Id.Value, fulfillment, false).Await().AsTask.Result);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_updating_a_fulfillment
var fulfillment = FulfillmentCreation.GenerateFulfillment();

Created = Service
.CreateAsync(Order.Id.Value, fulfillment, true)
.CreateAsync(Order.Id.Value, fulfillment, false)
.Await()
.AsTask
.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public static ShopifyOrder GenerateOrder()
Price = 5
}
},
FinancialStatus = Enums.ShopifyOrderFinancialStatus.Paid,
FinancialStatus = "paid",
TotalPrice = 5.00,
Transactions = new List<ShopifyTransaction>()
{
new ShopifyTransaction()
{
Amount = 20.00,
Status = "success",
Kind = Enums.ShopifyTransactionKind.Authorization,
Kind = "authorization",
Test = true,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ class When_activating_a_recurring_charge
Charge = Service.GetAsync(Charge.Id.Value).Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_activate_a_recurring_charge = () =>
{
// NOTE: This test will require you to set a break point after creating the charge but before activating it,
// grab the confirmation url and manually accept it, then continue the test.
Charge.Status.ShouldEqual(Enums.ShopifyChargeStatus.Active);
Charge.Status.ShouldEqual("active");
Charge.ActivatedOn.ShouldNotBeNull();
Charge.TrialEndsOn.ShouldNotBeNull();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class When_creating_a_recurring_charge
Charge = Service.CreateAsync(Charge).Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_create_a_recurring_charge = () =>
{
Charge.ConfirmationUrl.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class When_deleting_a_recurring_charge
}
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_delete_a_recurring_charge = () =>
{
// A charge cannot be deleted unless it has been activated. This test will fail unless you manually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class When_listing_recurring_charges
Charges = Service.ListAsync().Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_retrieve_a_list_of_recurring_charges = () =>
{
Charges.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class When_retrieving_a_recurring_charge
Charge = Service.GetAsync(ChargeId).Await().AsTask.Result;
};

[Ignore("Charge tests cannot be run automatically; they require manual confirmation.")]
It should_retrieve_a_recurring_charge = () =>
{
Charge.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class When_counting_script_tags

Tags.Add(Service.CreateAsync(new ShopifyScriptTag()
{
Event = Enums.ShopifyScriptTagEvent.Onload,
Event = "onload",
Src = src
}).Await().AsTask.Result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class When_creating_a_script_tag
{
Tag = Service.CreateAsync(new ShopifyScriptTag()
{
Event = Enums.ShopifyScriptTagEvent.Onload,
Event = "onload",
Src = "https://nozzlegear.com/test.js"
}).Await().AsTask.Result;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_deleting_a_script_tag
Service = new ShopifyScriptTagService(Utils.MyShopifyUrl, Utils.AccessToken);
Tag = Service.CreateAsync(new ShopifyScriptTag()
{
Event = Enums.ShopifyScriptTagEvent.Onload,
Event = "onload",
Src = "https://nozzlegear.com/test.js"
}).Await().AsTask.Result;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_getting_a_script_tag
Service = new ShopifyScriptTagService(Utils.MyShopifyUrl, Utils.AccessToken);
TagId = Service.CreateAsync(new ShopifyScriptTag()
{
Event = Enums.ShopifyScriptTagEvent.Onload,
Event = "onload",
Src = "https://nozzlegear.com/test.js"
}).Await().AsTask.Result.Id.Value;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class When_listing_script_tags

Service.CreateAsync(new ShopifyScriptTag()
{
Event = Enums.ShopifyScriptTagEvent.Onload,
Event = "onload",
Src = src
}).Await();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class When_updating_a_script_tag
Service = new ShopifyScriptTagService(Utils.MyShopifyUrl, Utils.AccessToken);
OriginalTag = Service.CreateAsync(new ShopifyScriptTag()
{
Event = Enums.ShopifyScriptTagEvent.Onload,
Event = "onload",
Src = "https://nozzlegear.com/test.js"
}).Await().AsTask.Result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static ShopifyTheme CreateValidTheme()
return new ShopifyTheme()
{
Name = "My new theme.",
Role = Enums.ShopifyThemeRole.Unpublished
Role = "unpublished"
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class When_creating_a_themes
It should_create_a_theme = () =>
{
Theme.Id.HasValue.ShouldBeTrue();
Theme.Role.ShouldEqual(Enums.ShopifyThemeRole.Unpublished);
Theme.Role.ShouldEqual("unpublished");
};

Cleanup after = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,29 @@ class When_deserializing_a_theme

Because of = () =>
{
Theme1 = JsonConvert.DeserializeObject<ShopifyTheme>(Theme1Json);
Theme1 = JsonConvert.DeserializeObject<ShopifyTheme>(Theme1Json);

Theme2 = JsonConvert.DeserializeObject<ShopifyTheme>(Theme2Json);

Theme3 = JsonConvert.DeserializeObject<ShopifyTheme>(Theme3Json);
};

It should_deserialize_a_theme = () =>
{
Theme1.Role.ShouldBeNull();

Theme2.Role.ShouldBeNull();

Theme3.Role.ShouldEqual(Enums.ShopifyThemeRole.Main);
string.IsNullOrEmpty(Theme1.Role).ShouldBeTrue();

Theme2.Role.ShouldEqual("main");
};

Cleanup after = () =>
{

};

static string Theme1Json { get; } = "{\"id\":10556555,\"name\":\"launchpad-star\",\"created_at\":\"2014-09-03T11:20:41-05:00\",\"updated_at\":\"2015-11-11T11:28:59-06:00\",\"role\":\"\",\"theme_store_id\":null,\"previewable\":true,\"processing\":false}";
static string Theme1Json { get; } = "{\"id\":10556555,\"name\":\"launchpad-star\",\"created_at\":\"2014-09-03T11:20:41-05:00\",\"updated_at\":\"2015-11-11T11:28:59-06:00\",\"role\":\"\",\"theme_store_id\":null,\"previewable\":true,\"processing\":false}";

static string Theme2Json { get; } = "{\"id\":10556555,\"name\":\"launchpad-star\",\"created_at\":\"2014-09-03T11:20:41-05:00\",\"updated_at\":\"2015-11-11T11:28:59-06:00\",\"role\":\"unknown_value\",\"theme_store_id\":null,\"previewable\":true,\"processing\":false}";
static string Theme2Json { get; } = "{\"id\":10556555,\"name\":\"launchpad-star\",\"created_at\":\"2014-09-03T11:20:41-05:00\",\"updated_at\":\"2015-11-11T11:28:59-06:00\",\"role\":\"main\",\"theme_store_id\":null,\"previewable\":true,\"processing\":false}";

static string Theme3Json { get; } = "{\"id\":10556555,\"name\":\"launchpad-star\",\"created_at\":\"2014-09-03T11:20:41-05:00\",\"updated_at\":\"2015-11-11T11:28:59-06:00\",\"role\":\"main\",\"theme_store_id\":null,\"previewable\":true,\"processing\":false}";

static ShopifyTheme Theme1 { get; set; }
static ShopifyTheme Theme1 { get; set; }

static ShopifyTheme Theme2 { get; set; }

static ShopifyTheme Theme3 { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class When_updating_a_themes
}

Theme.Name = UpdatedThemeName;
Theme.Role = Enums.ShopifyThemeRole.Main;
Theme.Role = "main";
};

Because of = () =>
Expand All @@ -45,7 +45,7 @@ class When_updating_a_themes
It should_update_a_themes = () =>
{
Theme.Name.ShouldEqual(UpdatedThemeName);
Theme.Role.ShouldEqual(Enums.ShopifyThemeRole.Main);
Theme.Role.ShouldEqual("main");
};

Cleanup after = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class Setup
/// <summary>
/// Generates a valid <see cref="ShopifyTransaction"/> for testing the Transaction API.
/// </summary>
public static ShopifyTransaction GenerateTransaction(ShopifyTransactionKind kind = ShopifyTransactionKind.Authorization , double? amount = null)
public static ShopifyTransaction GenerateTransaction(string kind = "authorization", double? amount = null)
{
return new ShopifyTransaction()
{
Expand Down
Loading

0 comments on commit 13dd883

Please sign in to comment.