Skip to content

Commit

Permalink
Merge pull request #59 from sveawebpay/develop
Browse files Browse the repository at this point in the history
Artical number and unit should be optional in credit order rows
  • Loading branch information
mlvochin authored Oct 8, 2024
2 parents 98dfce4 + dcf8191 commit 22d059c
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,8 @@ public void TestCreditNewOrderRows()
DiscountAmount = 10,
DiscountPercent=2 ,
Name = "test",
Unit = "test",
UnitPrice = 10,
VatPercent=1
VatPercent=1,
UnitPrice = 1
}
},
OrderRows = new List<CreditOrderRowBuilder> { new CreditOrderRowBuilder { Quantity = 1, RowId = 1 } }
Expand Down
234 changes: 117 additions & 117 deletions Webpay.Integration.CSharp/IntegrationTest/WebPayAdminIntegrationTest.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.10.1\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.10.1\build\NUnit.props')" />
<Import Project="..\packages\NUnit3TestAdapter.4.6.0\build\net462\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.4.6.0\build\net462\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.4.2.2\build\NUnit.props" Condition="Exists('..\packages\NUnit.4.2.2\build\NUnit.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -45,11 +45,32 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.10.1\lib\net40\nunit.framework.dll</HintPath>
<Private>True</Private>
<Reference Include="nunit.framework, Version=4.2.2.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.4.2.2\lib\net462\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.framework.legacy, Version=4.2.2.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.4.2.2\lib\net462\nunit.framework.legacy.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Runtime.Serialization" />
Expand Down Expand Up @@ -119,8 +140,8 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.10.1\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.10.1\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\NUnit.4.2.2\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.4.2.2\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.4.6.0\build\net462\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.4.6.0\build\net462\NUnit3TestAdapter.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ [Test] public void Test_CreateOrder_CreateInvoiceOrder_WithAllExVatRows()
{
// create order
var order = TestingTool.CreateInvoiceOrderWithTwoOrderRows();
Assert.IsTrue(order.Accepted);
Assert.That(order.Accepted);
}
[Test] public void Test_CreateOrder_CreatePaymentPlanOrder_WithAllExVatRows()
{
// create order
var order = TestingTool.CreatePaymentPlanOrderWithTwoOrderRows();
Assert.IsTrue(order.Accepted);
Assert.That(order.Accepted);
}
// WebpayConnection.DeliverOrder()
[Test] public void Test_DeliverOrder_DeliverInvoiceOrder_WithAllIdenticalRows()
Expand All @@ -40,7 +40,7 @@ [Test] public void Test_DeliverOrder_DeliverInvoiceOrder_WithAllIdenticalRows()
.AddOrderRow(TestingTool.CreateExVatBasedOrderRow("2"))
;
var delivery = builder.DeliverInvoiceOrder().DoRequest();
Assert.IsTrue(delivery.Accepted);
Assert.That(delivery.Accepted);
Assert.That(delivery.DeliverOrderResult.Amount, Is.EqualTo(500.00M)); // 100ex@25%*2st *2rows
}
[Test] public void Test_DeliverOrder_DeliverInvoiceOrder_WithOneIdenticalRows()
Expand All @@ -59,7 +59,7 @@ [Test] public void Test_DeliverOrder_DeliverInvoiceOrder_WithOneIdenticalRows()
.AddOrderRow(TestingTool.CreateExVatBasedOrderRow("2"))
;
var delivery = builder.DeliverInvoiceOrder().DoRequest();
Assert.IsTrue(delivery.Accepted);
Assert.That(delivery.Accepted);
Assert.That(delivery.DeliverOrderResult.Amount, Is.EqualTo(250.00M)); // 100ex@25%*2st *1row
}
[Test] public void Test_DeliverOrder_DeliverPaymentPlanOrder_WithAllIdenticalRows()
Expand All @@ -75,7 +75,7 @@ [Test] public void Test_DeliverOrder_DeliverPaymentPlanOrder_WithAllIdenticalRow
.AddOrderRow(TestingTool.CreateExVatBasedOrderRow("2"))
;
var delivery = builder.DeliverPaymentPlanOrder().DoRequest();
Assert.IsTrue(delivery.Accepted);
Assert.That(delivery.Accepted);
Assert.That(delivery.DeliverOrderResult.Amount, Is.EqualTo(5000.00M)); // 1000ex@25%*2st *2rows
}
[Test] public void Test_DeliverOrder_DeliverPaymentPlanOrder_IgnoresOrderRows()
Expand All @@ -91,7 +91,7 @@ [Test] public void Test_DeliverOrder_DeliverPaymentPlanOrder_IgnoresOrderRows()
.AddOrderRow(TestingTool.CreateExVatBasedOrderRow("2"))
;
var delivery = builder.DeliverPaymentPlanOrder().DoRequest();
Assert.IsTrue(delivery.Accepted);
Assert.That(delivery.Accepted);
Assert.That(delivery.DeliverOrderResult.Amount, Is.EqualTo(5000.00M)); // 1000ex@25%*2st *2row
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void TestCompanyIdResponse()
.DoRequest();

Assert.That(response.CreateOrderResult.CustomerIdentity.CustomerType, Is.EqualTo(CustomerType.Company));
Assert.IsNull(response.CreateOrderResult.CustomerIdentity.IndividualIdentity);
Assert.IsNull(response.CreateOrderResult.CustomerIdentity.CompanyIdentity);
Assert.That(response.CreateOrderResult.CustomerIdentity.IndividualIdentity == null);
Assert.That(response.CreateOrderResult.CustomerIdentity.CompanyIdentity == null);
Assert.That(response.Accepted, Is.True);
}

Expand Down Expand Up @@ -144,10 +144,10 @@ public void Test_CreateOrder_SE_WithOnlyNationalIdNumber_ShouldNotSetIndividualI
.SetCurrency(TestingTool.DefaultTestCurrency)
;
CreateOrderEuRequest request = createOrderBuilder.UseInvoicePayment().PrepareRequest();
Assert.IsNull(request.CreateOrderInformation.CustomerIdentity.IndividualIdentity);
Assert.That(request.CreateOrderInformation.CustomerIdentity.IndividualIdentity == null);

CreateOrderEuResponse order = createOrderBuilder.UseInvoicePayment().DoRequest();
Assert.IsTrue(order.Accepted);
Assert.That(order.Accepted);
}

[Test]
Expand All @@ -164,10 +164,10 @@ public void Test_CreateOrder_NO_WithOnlyNationalIdNumber_ShouldNotSetIndividualI
.SetCurrency(TestingTool.DefaultTestCurrency)
;
CreateOrderEuRequest request = createOrderBuilder.UseInvoicePayment().PrepareRequest();
Assert.IsNull(request.CreateOrderInformation.CustomerIdentity.IndividualIdentity);
Assert.That(request.CreateOrderInformation.CustomerIdentity.IndividualIdentity == null);

CreateOrderEuResponse order = createOrderBuilder.UseInvoicePayment().DoRequest();
Assert.IsTrue(order.Accepted);
Assert.That(order.Accepted);
}

[Test]
Expand Down Expand Up @@ -196,10 +196,10 @@ public void Test_CreateOrder_NO_WithAllCustomerDetailsSet_ShouldNotSetIndividual
.SetCurrency(TestingTool.DefaultTestCurrency)
;
CreateOrderEuRequest request = createOrderBuilder.UseInvoicePayment().PrepareRequest();
Assert.IsNull(request.CreateOrderInformation.CustomerIdentity.IndividualIdentity);
Assert.That(request.CreateOrderInformation.CustomerIdentity.IndividualIdentity == null);

CreateOrderEuResponse order = createOrderBuilder.UseInvoicePayment().DoRequest();
Assert.IsTrue(order.Accepted);
Assert.That(order.Accepted);
}

//CreateOrderEuResponse response = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void TestResultGetPaymentPlanParams()
.SetCountryCode(TestingTool.DefaultTestCountryCode)
.DoRequest();

Assert.IsTrue(response.Accepted);
Assert.That(response.Accepted);
Assert.That(response.CampaignCodes[0].CampaignCode, Is.EqualTo(223060));
Assert.That(response.CampaignCodes[0].Description, Is.EqualTo("Köp nu betala om 3 månader (räntefritt)"));
Assert.That(response.CampaignCodes[0].PaymentPlanType, Is.EqualTo(PaymentPlanTypeCode.InterestAndAmortizationFree));
Expand Down Expand Up @@ -62,7 +62,7 @@ public void TestPaymentPlanRequestReturnsAcceptedResult()
.UsePaymentPlanPayment(code)
.DoRequest();

Assert.IsTrue(response.Accepted);
Assert.That(response.Accepted);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ public void TestInvoiceForIndividualFromSe()
.UseInvoicePayment()
.DoRequest();

Assert.IsTrue(response.Accepted);
Assert.IsTrue(response.CreateOrderResult.SveaWillBuyOrder);
Assert.That(response.Accepted);
Assert.That(response.CreateOrderResult.SveaWillBuyOrder);
Assert.That(response.CreateOrderResult.Amount, Is.EqualTo(250.00));
Assert.That(response.CreateOrderResult.OrderType, Is.EqualTo("Invoice"));

Expand Down
27 changes: 18 additions & 9 deletions Webpay.Integration.CSharp/IntegrationTest/app.config
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ServiceSoap">
<security mode="Transport"/>
<security mode="Transport" />
</binding>
<binding name="ServiceSoap1"/>
<binding name="ServiceSoap1" />
<binding name="AdminSoapService">
<security mode="Transport"/>
<security mode="Transport" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WcfAdminSoapService">
<security mode="Transport">
<transport clientCredentialType="None"/>
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://webpaywsstage.svea.com/SveaWebPay.asmx" binding="basicHttpBinding" bindingConfiguration="ServiceSoap" contract="WebpayWS.ServiceSoap" name="ServiceSoap"/>
<endpoint address="https://webpayadminservicestage.svea.com/AdminService.svc/secure" binding="wsHttpBinding" bindingConfiguration="WcfAdminSoapService" contract="AdminWS.IAdminService" name="WcfAdminSoapService"/>
<endpoint address="https://webpayadminservicestage.svea.com/AdminService.svc/backward" binding="basicHttpBinding" bindingConfiguration="AdminSoapService" contract="AdminWS.IAdminService" name="AdminSoapService"/>
<endpoint address="https://webpaywsstage.svea.com/SveaWebPay.asmx" binding="basicHttpBinding" bindingConfiguration="ServiceSoap" contract="WebpayWS.ServiceSoap" name="ServiceSoap" />
<endpoint address="https://webpayadminservicestage.svea.com/AdminService.svc/secure" binding="wsHttpBinding" bindingConfiguration="WcfAdminSoapService" contract="AdminWS.IAdminService" name="WcfAdminSoapService" />
<endpoint address="https://webpayadminservicestage.svea.com/AdminService.svc/backward" binding="basicHttpBinding" bindingConfiguration="AdminSoapService" contract="AdminWS.IAdminService" name="AdminSoapService" />
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
10 changes: 8 additions & 2 deletions Webpay.Integration.CSharp/IntegrationTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.10.1" targetFramework="net40" requireReinstallation="true" />
<package id="NUnit3TestAdapter" version="3.10.0" targetFramework="net40" />
<package id="NUnit" version="4.2.2" targetFramework="net472" />
<package id="NUnit3TestAdapter" version="4.6.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Webpay.Integration.CSharp.Webservice.Helper;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Webpay.Integration.CSharp.Webservice.Helper;

namespace Webpay.Integration.CSharp.Test.Webservice.Helper
{
Expand All @@ -17,7 +17,7 @@ public void TestValidPeppolId()
public void TestInvalidPeppolId()
{
bool validationResult = PeppolId.IsValidPeppolId("1:1");
Assert.IsFalse(validationResult);
Assert.IsTrue(!validationResult);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ private Tuple<bool, CreditResponse> ValidateDelivery(Delivery delivery)
|| (x.VatPercent < 0)
|| (x.DiscountPercent < 0)
|| (x.DiscountAmount < 0)
|| string.IsNullOrEmpty(x.Unit)
))
{
return new Tuple<bool, CreditResponse>(false, GetValidationErrorResponse($"Invalid NewOrderRow for delivery Id {delivery.Id}"));
Expand Down

0 comments on commit 22d059c

Please sign in to comment.