Skip to content

Commit

Permalink
Merge pull request #123 from digipost/dev
Browse files Browse the repository at this point in the history
Støtte for datatyper
  • Loading branch information
sindrebn authored Nov 23, 2017
2 parents 358268e + 59214ac commit b69fab3
Show file tree
Hide file tree
Showing 54 changed files with 5,082 additions and 3,559 deletions.
103 changes: 24 additions & 79 deletions Digipost.Api.Client.Common.Tests/DataTransferObjectConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace Digipost.Api.Client.Common.Tests
{
public class DataTransferObjectConverterTests
{
private readonly Comparator _comparator = new Comparator();

public class ToDataTransferObjectMethod : DataTransferObjectConverterTests
{
[Fact]
Expand Down Expand Up @@ -44,9 +42,7 @@ public void ForeignAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand All @@ -71,9 +67,7 @@ public void IdentificationByAddressReturnsDigipostResultWithDigipostAddressResul
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand All @@ -98,9 +92,7 @@ public void IdentificationByAddressReturnsIdentifiedResultWithPersonalAliasResul
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand Down Expand Up @@ -131,9 +123,7 @@ public void IdentificationByAddressReturnsUnidentifiedResultWithUnidentifiedReas
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand Down Expand Up @@ -173,9 +163,7 @@ public void IdentificationByNameAndAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -213,9 +201,7 @@ public void IdentificationByNameAndAddressAcceptsNoBirthDate()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand All @@ -233,9 +219,7 @@ public void IdentificationByOrganizationNumber()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand All @@ -260,9 +244,7 @@ public void IdentificationByOrganizationNumberReturnsDigipostResultWithDigipostA
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand Down Expand Up @@ -293,9 +275,7 @@ public void IdentificationByOrganizationNumberReturnsInvalidResultWithInvalidRea
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand All @@ -320,9 +300,7 @@ public void IdentificationByOrganizationNumberReturnsUnidentifiedResultWithUnide
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand All @@ -346,9 +324,7 @@ public void IdentificationByPinReturnsDigipostResultWithNoneResultType()
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand All @@ -373,9 +349,7 @@ public void IdentificationByPinReturnsIdentifiedResultWithNoneResultType()
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand All @@ -400,9 +374,7 @@ public void IdentificationByPinReturnsInvalidResultWithInvalidReason()
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand Down Expand Up @@ -430,9 +402,7 @@ public void NorwegianAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -486,10 +456,7 @@ public void PrintDetails()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);

Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);

Assert.Null(DataTransferObjectConverter.ToDataTransferObject((IPrintDetails) null));
}
Expand Down Expand Up @@ -527,10 +494,7 @@ public void PrintRecipientFromForeignAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -558,10 +522,7 @@ public void PrintRecipientFromNorwegianAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -597,10 +558,7 @@ public void PrintReturnRecipientFromForeignAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -628,9 +586,7 @@ public void PrintReturnRecipientFromNorwegianAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand All @@ -653,9 +609,7 @@ public void RecipientById()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -693,9 +647,7 @@ public void RecipientByNameAndAddress()
var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actualDto, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actualDto);
}

[Fact]
Expand Down Expand Up @@ -821,10 +773,7 @@ public void SearchResult()
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
var comparator = new Comparator {ComparisonConfiguration = new ComparisonConfiguration {IgnoreObjectTypes = true}};
comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}

[Fact]
Expand All @@ -848,9 +797,7 @@ public void SmsNotification()
var actual = DataTransferObjectConverter.ToDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expectedDto, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expectedDto, actual);
}
}

Expand Down Expand Up @@ -878,9 +825,7 @@ public void Error()
var actual = DataTransferObjectConverter.FromDataTransferObject(source);

//Assert
IEnumerable<IDifference> differences;
_comparator.Equal(expected, actual, out differences);
Assert.Equal(0, differences.Count());
Comparator.AssertEqual(expected, actual);
}
}
}
Expand Down
14 changes: 3 additions & 11 deletions Digipost.Api.Client.Common.Tests/Print/PrintDetailsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Digipost.Api.Client.Common.Enums;
using Digipost.Api.Client.Common.Enums;
using Digipost.Api.Client.Common.Print;
using Digipost.Api.Client.Tests;
using Digipost.Api.Client.Tests.CompareObjects;
Expand All @@ -12,8 +10,6 @@ public class PrintDetailsTests
{
public class ConstructorMethod : PrintDetailsTests
{
private readonly Comparator _comparator = new Comparator();

[Fact]
public void SimpleConstructor()
{
Expand All @@ -24,13 +20,9 @@ public void SimpleConstructor()
//Act

//Assert
IEnumerable<IDifference> printDifference;
_comparator.Equal(DomainUtility.GetPrintRecipientWithNorwegianAddress(), printDetails.PrintRecipient, out printDifference);
Assert.Equal(0, printDifference.Count());
Comparator.AssertEqual(DomainUtility.GetPrintRecipientWithNorwegianAddress(), printDetails.PrintRecipient);

IEnumerable<IDifference> printReturnDifference;
_comparator.Equal(DomainUtility.GetPrintReturnRecipientWithNorwegianAddress(), printDetails.PrintReturnRecipient, out printReturnDifference);
Assert.Equal(0, printReturnDifference.Count());
Comparator.AssertEqual(DomainUtility.GetPrintReturnRecipientWithNorwegianAddress(), printDetails.PrintReturnRecipient);

Assert.Equal(PostType.A, printDetails.PostType);
Assert.Equal(PrintColors.Colors, printDetails.PrintColors);
Expand Down
11 changes: 2 additions & 9 deletions Digipost.Api.Client.Common.Tests/Print/PrintRecipientTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Digipost.Api.Client.Common.Print;
using Digipost.Api.Client.Common.Print;
using Digipost.Api.Client.Tests;
using Digipost.Api.Client.Tests.CompareObjects;
using Xunit;
Expand All @@ -12,8 +10,6 @@ public class PrintRecipientTests
public class ConstructorMethod : PrintRecipientTests

{
private readonly Comparator _comparator = new Comparator();

[Fact]
public void SimpleConstructor()
{
Expand All @@ -27,10 +23,7 @@ public void SimpleConstructor()
//Assert
Assert.Equal(name, printRecipient.Name);

IEnumerable<IDifference> differences;
_comparator.Equal(DomainUtility.GetNorwegianAddress(), printRecipient.Address, out differences);

Assert.Equal(0, differences.Count());
Comparator.AssertEqual(DomainUtility.GetNorwegianAddress(), printRecipient.Address);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Digipost.Api.Client.Common.Print;
using Digipost.Api.Client.Common.Print;
using Digipost.Api.Client.Tests;
using Digipost.Api.Client.Tests.CompareObjects;
using Xunit;
Expand All @@ -11,8 +9,6 @@ public class PrintReturnRecipientTests
{
public class ConstructorMethod : PrintReturnRecipientTests
{
private readonly Comparator _comparator = new Comparator();

[Fact]
public void SimpleConstructor()
{
Expand All @@ -25,10 +21,7 @@ public void SimpleConstructor()
//Assert
Assert.Equal(name, printRecipient.Name);

IEnumerable<IDifference> differences;
_comparator.Equal(DomainUtility.GetNorwegianAddress(), printRecipient.Address, out differences);

Assert.Equal(0, differences.Count());
Comparator.AssertEqual(DomainUtility.GetNorwegianAddress(), printRecipient.Address);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Digipost.Api.Client.Common/ApiClientXmlValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal class ApiClientXmlValidator : XmlValidator
public ApiClientXmlValidator()
{
AddXsd(Namespace.DigipostApiV7, XsdResource.GetApiV7Xsd());
AddXsd(Namespace.DataTypes, XsdResource.GetDataTypesXsd());
}
}
}
2 changes: 1 addition & 1 deletion Digipost.Api.Client.Common/Exceptions/XmlParseException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public XmlParseException(string message, Exception inner, string xmlRawData)
XmlRawData = xmlRawData;
}

public string XmlRawData { get; private set; }
public string XmlRawData { get; }
}
}
5 changes: 2 additions & 3 deletions Digipost.Api.Client.Common/Namespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
{
internal class Namespace
{
/// <summary>
/// http://api.digipost.no/schema/v7
/// </summary>
public const string DigipostApiV7 = "http://api.digipost.no/schema/v7";

public const string DataTypes = "http://api.digipost.no/schema/datatypes";
}
}
Loading

0 comments on commit b69fab3

Please sign in to comment.