diff --git a/.github/workflows/nuget_publish.yml b/.github/workflows/nuget_publish.yml index ed4774b..38f709d 100644 --- a/.github/workflows/nuget_publish.yml +++ b/.github/workflows/nuget_publish.yml @@ -1,40 +1,39 @@ -#name: Build and NuGet Publish - -#on: -# push: -# branches: [ master ] -# pull_request: -# branches: [ master ] - -#jobs: -# build-test: -# name: Build and Publish -# runs-on: ubuntu-latest - -# steps: -# - name: Checkout Repository -# uses: actions/checkout@v2 -# with: -# fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - -# - name: Setup .NET -# uses: actions/setup-dotnet@v1 -# with: -# dotnet-version: 5.0.x - -# - uses: dotnet/nbgv@master -# with: -# setAllVars: true - -# - name: Restore dependencies -# run: dotnet restore - -# - name: Build -# run: dotnet build --no-restore /nowarn:CS1591 - -# - name: Publish -# run: | # | character makes the "run" property multi-line, so we can put multiple commands in the same step -# mkdir __out -# dotnet pack -c Release -o ${GITHUB_WORKSPACE}/packages --no-restore -p:RepositoryBranch=main -p:ContinuousIntegrationBuild=true /p:PublicRelease=true -# dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols true --api-key ${{secrets.NUGET_KEY}} - \ No newline at end of file +name: Build and NuGet Publish + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build-test: + name: Build and Publish + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + + - uses: dotnet/nbgv@master + with: + setAllVars: true + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore /nowarn:CS1591 + + - name: Publish + run: | # | character makes the "run" property multi-line, so we can put multiple commands in the same step + mkdir __out + dotnet pack -c Release -o ${GITHUB_WORKSPACE}/packages --no-restore -p:RepositoryBranch=main -p:ContinuousIntegrationBuild=true /p:PublicRelease=true + dotnet nuget push ${GITHUB_WORKSPACE}/packages/'*.nupkg' -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols true --api-key ${{secrets.NUGET_KEY}} diff --git a/Source/ChargifyDotNet.Tests/Base/ChargifyTestBase.cs b/Source/ChargifyDotNet.Tests/Base/ChargifyTestBase.cs index 257fc9a..17b1c08 100644 --- a/Source/ChargifyDotNet.Tests/Base/ChargifyTestBase.cs +++ b/Source/ChargifyDotNet.Tests/Base/ChargifyTestBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using ChargifyNET; using System.Net; using Bogus; @@ -14,7 +14,7 @@ public class ChargifyTestBase /// public TestContext TestContext { get; set; } - public ChargifyConnect Chargify => _chargify ?? (_chargify = new ChargifyConnect + public ChargifyConnect Chargify => _chargify ??= new ChargifyConnect { apiKey = "", Password = "X", @@ -22,7 +22,7 @@ public class ChargifyTestBase SharedKey = "123456789", UseJSON = false, ProtocolType = SecurityProtocolType.Tls12 - }); + }; private ChargifyConnect _chargify; @@ -77,11 +77,12 @@ public string GetNewRandomValue(string oldValue, Func generateVa return retVal; } - public static Faker Faker => new Faker("en"); + public static Faker Faker => new("en"); internal void SetJson(bool useJson) { - if (Chargify != null) { + if (Chargify != null) + { _chargify.UseJSON = useJson; } } diff --git a/Source/ChargifyDotNet.Tests/ComponentTests.cs b/Source/ChargifyDotNet.Tests/ComponentTests.cs index 3554b6e..b53bd4f 100644 --- a/Source/ChargifyDotNet.Tests/ComponentTests.cs +++ b/Source/ChargifyDotNet.Tests/ComponentTests.cs @@ -182,7 +182,7 @@ public void PricePoints_Create(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -286,7 +286,7 @@ public void PricePoints_PromoteToDefault(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -313,7 +313,7 @@ public void PricePoints_CreateBulk(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -331,7 +331,7 @@ public void PricePoints_Update(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -348,7 +348,7 @@ public void PricePoints_Archive(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -376,7 +376,7 @@ public void PricePoints_Read(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -400,7 +400,7 @@ public void PricePoints_Unarchive(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); @@ -428,10 +428,19 @@ public void PricePoints_UpdatePrices(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150); + var pricePoints = Chargify.GetPricePoints(subscriptionComponent.ComponentID)?.Values.ToList(); + var firstPricePoint = pricePoints.FirstOrDefault(); + if (firstPricePoint == null) Assert.Inconclusive(); + + var firstPrice = firstPricePoint.Prices.FirstOrDefault(); + firstPrice.UnitPrice += 1; + + //Chargify.UpdatePriceInPricePoint(subscriptionComponent.ComponentID, firstPrice); + SetJson(!isJson); } @@ -445,7 +454,7 @@ public void PricePoints_CreatePrices(string method) SetJson(isJson); // Arrange - var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active).Value; + var subscription = Chargify.GetSubscriptionList().FirstOrDefault(s => s.Value.State == SubscriptionState.Active && s.Value.Product.ID == 5830949).Value; if (subscription == null) Assert.Inconclusive("A valid subscription could not be found."); var subscriptionComponent = Chargify.GetComponentInfoForSubscription(subscription.SubscriptionID, 1526150);