Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 21 additions & 26 deletions PayNLSdk.Tests/Api/Alliance/AddInvoiceRequestTests.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using Xunit;

namespace PayNLSdk.Tests.Api.Alliance
{
[TestClass]
public class AddInvoiceRequestTests
{
private PAYNLSDK.API.Alliance.AddInvoice.Request _sut;
private readonly PAYNLSDK.API.Alliance.AddInvoice.Request _sut;

[TestInitialize]
public void TestInitialize()
public AddInvoiceRequestTests()
{
_sut = new PAYNLSDK.API.Alliance.AddInvoice.Request(
"Dummy",
"Dummy",
"Dummy",
"Dummy",
12345
);
);
}
[TestMethod]

[Fact]
public void GetParameters_ReturnMandatoryProperties_OnCalled()
{
// Arrange

// Act
var parameters = _sut.GetParameters();

// Assert
Assert.IsNotNull(parameters["serviceId"]);
Assert.IsNotNull(parameters["merchantId"]);
Assert.IsNotNull(parameters["invoiceId"]);
Assert.IsNotNull(parameters["amount"]);
Assert.IsNotNull(parameters["description"]);
parameters["serviceId"].ShouldNotBeNull();
parameters["merchantId"].ShouldNotBeNull();
parameters["invoiceId"].ShouldNotBeNull();
parameters["amount"].ShouldNotBeNull();
parameters["description"].ShouldNotBeNull();
}

#region Optional parameters
[TestMethod]
[Fact]
public void MakeYesterday_internalPropertySet_True()
{
// Arrange
Expand All @@ -48,10 +44,10 @@ public void MakeYesterday_internalPropertySet_True()
_sut.MakeYesterday = true;

// Assert
Assert.AreEqual("true", _sut.GetParameters()["makeYesterday"]);
_sut.GetParameters()["makeYesterday"].ShouldBe("true");
}

[TestMethod]
[Fact]
public void MakeYesterday_propertyNotAvailableInInParameters_PropertyIsNotSet()
{
// Arrange
Expand All @@ -61,10 +57,10 @@ public void MakeYesterday_propertyNotAvailableInInParameters_PropertyIsNotSet()
var parameter = _sut.GetParameters()["makeYesterday"];

// Assert
Assert.IsNull(parameter);
parameter.ShouldBeNull();
}

[TestMethod]
[Fact]
public void InvoiceUrl_internalPropertySet_True()
{
// Arrange
Expand All @@ -74,20 +70,19 @@ public void InvoiceUrl_internalPropertySet_True()
_sut.InvoiceUrl = httpUrlToInvoice;

// Assert
Assert.AreEqual(httpUrlToInvoice, _sut.GetParameters()["invoiceUrl"]);
_sut.GetParameters()["invoiceUrl"].ShouldBe(httpUrlToInvoice);
}

[TestMethod]
[Fact]
public void InvoiceUrl_propertyNotAvailableInInParameters_PropertyIsNotSet()
{
// Arrange
//_sut.MakeYesterday = null;

// Act
var parameter = _sut.GetParameters()["invoiceUrl"];

// Assert
Assert.IsNull(parameter);
parameter.ShouldBeNull();
}
#endregion
}
Expand Down
90 changes: 44 additions & 46 deletions PayNLSdk.Tests/Api/Statistics/GetStatsTests.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using PayNLSdk.API.Statistics.GetManagement;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NSubstitute;
using PayNLSdk.API.Statistics.GetManagement;
using Shouldly;
using Xunit;

namespace PayNLSdk.Tests.Api.Statistics
{
[TestClass]
[SuppressMessage("ReSharper", "RedundantNameQualifier", Justification = "We need to be sure the correct object is called in the tests")]
public class GetStatsRequestTests
{
private PayNLSdk.API.Statistics.GetManagement.Request _sut;
private readonly PayNLSdk.API.Statistics.GetManagement.Request _sut;

[TestInitialize]
public void TestInitialize()
public GetStatsRequestTests()
{
_sut = new PayNLSdk.API.Statistics.GetManagement.Request();
}

[TestMethod]
[Fact]
public void Ctor_FilterPropertyNotTempty_Always()
{
// Arrange
Expand All @@ -30,11 +29,11 @@ public void Ctor_FilterPropertyNotTempty_Always()
// Act

// Assert
Assert.IsNotNull(_sut.Filters);
Assert.AreEqual(0, _sut.Filters.Count);
_sut.Filters.ShouldNotBeNull();
_sut.Filters.Count.ShouldBe(0);
}

[TestMethod]
[Fact]
public void Ctor_GroupByPropertyNotTempty_Always()
{
// Arrange
Expand All @@ -43,11 +42,11 @@ public void Ctor_GroupByPropertyNotTempty_Always()
// Act

// Assert
Assert.IsNotNull(_sut.GroupByFieldNames);
Assert.AreEqual(0, _sut.GroupByFieldNames.Count);
_sut.GroupByFieldNames.ShouldNotBeNull();
_sut.GroupByFieldNames.Count.ShouldBe(0);
}

[TestMethod]
[Fact]
public void GetParameters_ContainsGroupBy_IfSortByFieldNamesPropertyIsUsed()
{
// Arrange
Expand All @@ -57,11 +56,10 @@ public void GetParameters_ContainsGroupBy_IfSortByFieldNamesPropertyIsUsed()
var result = _sut.GetParameters();

// Assert
Assert.AreEqual("ABC", result.Get("groupBy[0]"));

result.Get("groupBy[0]").ShouldBe("ABC");
}

[TestMethod]
[Fact]
public void GetParameters_ContainsFilters_MultipleFiltersAdded()
{
// Arrange
Expand All @@ -72,70 +70,70 @@ public void GetParameters_ContainsFilters_MultipleFiltersAdded()
var result = _sut.GetParameters();

// Assert
Assert.IsTrue(GetWithPartialKey(result, "filterType[").Contains("KEY1"));
Assert.IsTrue(GetWithPartialKey(result, "filterType[").Contains("KEY2"));
Assert.IsTrue(GetWithPartialKey(result, "filterValue[").Contains("VAL1"));
Assert.IsTrue(GetWithPartialKey(result, "filterValue[").Contains("VAL2"));
GetWithPartialKey(result, "filterType[").ShouldContain("KEY1");
GetWithPartialKey(result, "filterType[").ShouldContain("KEY2");
GetWithPartialKey(result, "filterValue[").ShouldContain("VAL1");
GetWithPartialKey(result, "filterValue[").ShouldContain("VAL2");
}

[TestMethod]
[Fact]
public void Create_CorrectStartEndDate_LastWeek()
{
// Arrange
var dateTime = new Mock<IDateTime>();
dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11));
var dateTime = Substitute.For<IDateTime>();
dateTime.Now.Returns(new DateTime(2018, 12, 11));

// Act
var result = Request.Create(dateTime.Object, Request.StatsPeriod.LastWeek);
var result = Request.Create(dateTime, Request.StatsPeriod.LastWeek);

// Assert
Assert.AreEqual(new DateTime(2018,12,3), result.StartDate);
Assert.AreEqual(new DateTime(2018,12,9), result.EndDate);
result.StartDate.ShouldBe(new DateTime(2018, 12, 3));
result.EndDate.ShouldBe(new DateTime(2018, 12, 9));
}

[TestMethod]
[Fact]
public void Create_CorrectStartEndDate_LastMonth()
{
// Arrange
var dateTime = new Mock<IDateTime>();
dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11));
var dateTime = Substitute.For<IDateTime>();
dateTime.Now.Returns(new DateTime(2018, 12, 11));

// Act
var result = Request.Create(dateTime.Object, Request.StatsPeriod.LastMonth);
var result = Request.Create(dateTime, Request.StatsPeriod.LastMonth);

// Assert
Assert.AreEqual(new DateTime(2018, 11, 1), result.StartDate);
Assert.AreEqual(new DateTime(2018, 11, 30), result.EndDate);
result.StartDate.ShouldBe(new DateTime(2018, 11, 1));
result.EndDate.ShouldBe(new DateTime(2018, 11, 30));
}

[TestMethod]
[Fact]
public void Create_CorrectStartEndDate_ThisWeek()
{
// Arrange
var dateTime = new Mock<IDateTime>();
dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11));
var dateTime = Substitute.For<IDateTime>();
dateTime.Now.Returns(new DateTime(2018, 12, 11));

// Act
var result = Request.Create(dateTime.Object, Request.StatsPeriod.ThisWeek);
var result = Request.Create(dateTime, Request.StatsPeriod.ThisWeek);

// Assert
Assert.AreEqual(new DateTime(2018, 12, 10), result.StartDate);
Assert.AreEqual(new DateTime(2018, 12, 16), result.EndDate);
result.StartDate.ShouldBe(new DateTime(2018, 12, 10));
result.EndDate.ShouldBe(new DateTime(2018, 12, 16));
}

[TestMethod]
[Fact]
public void Create_CorrectStartEndDate_ThisMonth()
{
// Arrange
var dateTime = new Mock<IDateTime>();
dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11));
var dateTime = Substitute.For<IDateTime>();
dateTime.Now.Returns(new DateTime(2018, 12, 11));

// Act
var result = Request.Create(dateTime.Object, Request.StatsPeriod.ThisMonth);
var result = Request.Create(dateTime, Request.StatsPeriod.ThisMonth);

// Assert
Assert.AreEqual(new DateTime(2018, 12, 1), result.StartDate);
Assert.AreEqual(new DateTime(2018, 12, 11), result.EndDate);
result.StartDate.ShouldBe(new DateTime(2018, 12, 1));
result.EndDate.ShouldBe(new DateTime(2018, 12, 11));
}

/// <summary>
Expand Down
17 changes: 6 additions & 11 deletions PayNLSdk.Tests/Api/Transaction/TransactionRefundTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using Xunit;

namespace PayNLSdk.Tests.Api.Transaction
{
[TestClass]
public class TransactionRefundTests
{
[TestMethod]
[Fact]
public void Request_AmountInCents_PassedInAsDecimal()
{
// Arrange
Expand All @@ -22,10 +19,10 @@ public void Request_AmountInCents_PassedInAsDecimal()
var result = sut.GetParameters();

// Assert
Assert.AreEqual("350", result["amount"]);
result["amount"].ShouldBe("350");
}

[TestMethod]
[Fact]
public void Request_NoAmountSupplied_NoParameterWithAmount()
{
// Arrange
Expand All @@ -39,9 +36,7 @@ public void Request_NoAmountSupplied_NoParameterWithAmount()
var result = sut.GetParameters();

// Assert
Assert.IsNull(result["amount"]);
result["amount"].ShouldBeNull();
}


}
}
Loading
Loading