Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample Unit tests #17

Merged
merged 3 commits into from
Jun 15, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
run: dotnet restore
- name: Build
run: dotnet build --no-restore
#- name: Test
# run: dotnet test --no-build --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal
9 changes: 9 additions & 0 deletions FacturaE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{88086700-F1E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FacturaE", "src\facturae\FacturaE.csproj", "{E31A3B5E-FEA2-4FC0-80C1-415C91A635AF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C24D7763-A8A5-4799-8D1A-0CA4E4E0DB67}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "facturae.tests", "tests\facturae.tests\facturae.tests.csproj", "{FCCCD1AE-EFF6-4DD0-BFD2-DD0455770783}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -20,8 +24,13 @@ Global
{E31A3B5E-FEA2-4FC0-80C1-415C91A635AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E31A3B5E-FEA2-4FC0-80C1-415C91A635AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E31A3B5E-FEA2-4FC0-80C1-415C91A635AF}.Release|Any CPU.Build.0 = Release|Any CPU
{FCCCD1AE-EFF6-4DD0-BFD2-DD0455770783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCCCD1AE-EFF6-4DD0-BFD2-DD0455770783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCCCD1AE-EFF6-4DD0-BFD2-DD0455770783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCCCD1AE-EFF6-4DD0-BFD2-DD0455770783}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E31A3B5E-FEA2-4FC0-80C1-415C91A635AF} = {88086700-F1EB-4E51-B9E1-4F4D06B94876}
{FCCCD1AE-EFF6-4DD0-BFD2-DD0455770783} = {C24D7763-A8A5-4799-8D1A-0CA4E4E0DB67}
EndGlobalSection
EndGlobal
45 changes: 44 additions & 1 deletion src/facturae/DataType/DoubleFourDecimalType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public static DoubleFourDecimalType Parse(string value)
return new DoubleFourDecimalType(decimal.Parse(value));
}

public static bool operator ==(DoubleFourDecimalType left, decimal dec)
{
return left._value == dec;
}

public static bool operator !=(DoubleFourDecimalType left, decimal dec)
{
return left._value != dec;
}

public static bool operator ==(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left._value == right._value;
Expand Down Expand Up @@ -109,7 +119,19 @@ public override readonly int GetHashCode()

public override readonly bool Equals(object obj)
{
return obj is not null and DoubleFourDecimalType value && value == this;
if (obj is null)
{
return false;
}
else if (obj is decimal dec)
{
return _value == dec;
}
else if (obj is DoubleFourDecimalType dfdt)
{
return dfdt == this;
}
return false;
}

public override readonly string ToString()
Expand All @@ -124,6 +146,27 @@ public readonly string ToString(string format)

public readonly int CompareTo(object obj)
{
if (obj is decimal dec)
{
return _value.CompareTo(dec);
}
else if (obj is DoubleFourDecimalType dfdt)
{
return _value.CompareTo((decimal)dfdt);
}
else if (obj is DoubleSixDecimalType dsdt)
{
return _value.CompareTo((decimal)dsdt);
}
else if (obj is DoubleTwoDecimalType dtdt)
{
return _value.CompareTo((decimal)dtdt);
}
else if (obj is DoubleUpToEightDecimalType dedt)
{
return _value.CompareTo((decimal)dedt);
}

return _value.CompareTo(obj);
}

Expand Down
45 changes: 44 additions & 1 deletion src/facturae/DataType/DoubleSixDecimalType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public static DoubleSixDecimalType Parse(string value)
return new DoubleSixDecimalType(decimal.Parse(value));
}

public static bool operator ==(DoubleSixDecimalType left, decimal dec)
{
return left._value == dec;
}

public static bool operator !=(DoubleSixDecimalType left, decimal dec)
{
return left._value != dec;
}

public static bool operator ==(DoubleSixDecimalType left, DoubleSixDecimalType right)
{
return left._value == right._value;
Expand Down Expand Up @@ -109,7 +119,19 @@ public override readonly int GetHashCode()

public override readonly bool Equals(object obj)
{
return obj is not null and DoubleSixDecimalType dvalue && dvalue == this;
if (obj is null)
{
return false;
}
else if (obj is decimal dec)
{
return _value == dec;
}
else if (obj is DoubleSixDecimalType dsdt)
{
return dsdt == this;
}
return false;
}

public override readonly string ToString()
Expand All @@ -124,6 +146,27 @@ public readonly string ToString(string format)

public readonly int CompareTo(object obj)
{
if (obj is decimal dec)
{
return _value.CompareTo(dec);
}
else if (obj is DoubleFourDecimalType dfdt)
{
return _value.CompareTo((decimal)dfdt);
}
else if (obj is DoubleSixDecimalType dsdt)
{
return _value.CompareTo((decimal)dsdt);
}
else if (obj is DoubleTwoDecimalType dtdt)
{
return _value.CompareTo((decimal)dtdt);
}
else if (obj is DoubleUpToEightDecimalType dedt)
{
return _value.CompareTo((decimal)dedt);
}

return _value.CompareTo(obj);
}

Expand Down
45 changes: 44 additions & 1 deletion src/facturae/DataType/DoubleTwoDecimalType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public static DoubleTwoDecimalType Parse(string value)
return new DoubleTwoDecimalType(decimal.Parse(value));
}

public static bool operator ==(DoubleTwoDecimalType left, decimal dec)
{
return left._value == dec;
}

public static bool operator !=(DoubleTwoDecimalType left, decimal dec)
{
return left._value != dec;
}

public static bool operator ==(DoubleTwoDecimalType left, DoubleTwoDecimalType right)
{
return left._value == right._value;
Expand Down Expand Up @@ -109,7 +119,19 @@ public override readonly int GetHashCode()

public override readonly bool Equals(object obj)
{
return obj is not null && obj is DoubleTwoDecimalType value && value == this;
if (obj is null)
{
return false;
}
else if (obj is decimal dec)
{
return _value == dec;
}
else if (obj is DoubleTwoDecimalType dsdt)
{
return dsdt == this;
}
return false;
}

public override readonly string ToString()
Expand All @@ -124,6 +146,27 @@ public readonly string ToString(string format)

public readonly int CompareTo(object obj)
{
if (obj is decimal dec)
{
return _value.CompareTo(dec);
}
else if (obj is DoubleFourDecimalType dfdt)
{
return _value.CompareTo((decimal)dfdt);
}
else if (obj is DoubleSixDecimalType dsdt)
{
return _value.CompareTo((decimal)dsdt);
}
else if (obj is DoubleTwoDecimalType dtdt)
{
return _value.CompareTo((decimal)dtdt);
}
else if (obj is DoubleUpToEightDecimalType dedt)
{
return _value.CompareTo((decimal)dedt);
}

return _value.CompareTo(obj);
}

Expand Down
50 changes: 47 additions & 3 deletions src/facturae/DataType/DoubleUpToEightDecimalType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public static DoubleUpToEightDecimalType Parse(string value)
return new DoubleUpToEightDecimalType(decimal.Parse(value));
}

public static bool operator ==(DoubleUpToEightDecimalType left, decimal dec)
{
return left._value == dec;
}


public static bool operator !=(DoubleUpToEightDecimalType left, decimal dec)
{
return left._value != dec;
}

public static bool operator ==(DoubleUpToEightDecimalType left, DoubleUpToEightDecimalType right)
{
return left._value == right._value;
Expand Down Expand Up @@ -109,7 +120,19 @@ public override readonly int GetHashCode()

public override readonly bool Equals(object obj)
{
return obj is not null and DoubleUpToEightDecimalType dvalue && dvalue == this;
if (obj is null)
{
return false;
}
else if (obj is decimal dec)
{
return _value == dec;
}
else if (obj is DoubleUpToEightDecimalType dedt)
{
return dedt == this;
}
return false;
}

public override readonly string ToString()
Expand All @@ -124,6 +147,27 @@ public readonly string ToString(string format)

public readonly int CompareTo(object obj)
{
if (obj is decimal dec)
{
return _value.CompareTo(dec);
}
else if (obj is DoubleFourDecimalType dfdt)
{
return _value.CompareTo((decimal)dfdt);
}
else if (obj is DoubleSixDecimalType dsdt)
{
return _value.CompareTo((decimal)dsdt);
}
else if (obj is DoubleTwoDecimalType dtdt)
{
return _value.CompareTo((decimal)dtdt);
}
else if (obj is DoubleUpToEightDecimalType dedt)
{
return _value.CompareTo((decimal)dedt);
}

return _value.CompareTo(obj);
}

Expand Down Expand Up @@ -217,9 +261,9 @@ readonly ulong IConvertible.ToUInt64(IFormatProvider provider)
return Convert.ToUInt64(_value);
}

readonly int IComparable<decimal>.CompareTo(decimal other)
public readonly int CompareTo(decimal other)
{
return CompareTo(other);
return _value.CompareTo(other);
}

public readonly bool Equals(decimal other)
Expand Down
23 changes: 7 additions & 16 deletions src/facturae/FacturaE.csproj
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageTags>facturae;dotnet8</PackageTags>
<PackageProjectUrl>https://github.com/carlosga/facturae</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/carlosga/facturae/blob/master/LICENSE</PackageLicenseUrl>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<!-- <Nullable>enable</Nullable> -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<PackageProjectUrl>https://github.com/carlosga/facturae</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/carlosga/facturae/blob/master/LICENSE</PackageLicenseUrl>
<AssemblyTitle>electronic invoice signing using pure C#</AssemblyTitle>
<AssemblyName>FacturaE</AssemblyName>
<PackageTags>facturae;dotnet8</PackageTags>
<PackageId>FacturaE</PackageId>
<VersionPrefix>1.1.0</VersionPrefix>
</PropertyGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Xml" Version="8.0.1-*" />
</ItemGroup>

<ItemGroup>
<None Include="Certificates\facturae.p12">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Policies\politica_de_firma_formato_facturae_v3_1.pdf" />
<EmbeddedResource Include="Schemas\xmldsig-core-schema.xsd" />
Expand Down
Loading