Skip to content

Commit 99eb34e

Browse files
authored
Add new release tests (#59)
These are windows .NET Framework 4.6.1 spot tests in c# against latest released package in nuget gallery
1 parent e8d8748 commit 99eb34e

File tree

7 files changed

+108
-2
lines changed

7 files changed

+108
-2
lines changed

.github/workflows/pull-requests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
- name: Build
2121
run: dotnet build -target:$TARGETS --no-restore
2222
- name: Run Tests
23-
run: dotnet test -target:$TARGETS --no-build --verbosity normal
23+
run: dotnet test .\\tests\\ExcelFinancialFunctions.Tests\\ExcelFinancialFunctions.Tests.fsproj --no-build --verbosity normal
2424

.github/workflows/push-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Build Debug
2121
run: dotnet build -target:$TARGETS --no-restore
2222
- name: Run Debug Tests (Release tests fail to discover)
23-
run: dotnet test -target:$TARGETS --no-build --verbosity normal
23+
run: dotnet test .\\tests\\ExcelFinancialFunctions.Tests\\ExcelFinancialFunctions.Tests.fsproj --no-build --verbosity normal
2424
- name: Build Release
2525
run: dotnet build -target:$TARGETS --no-restore --configuration=Release
2626
- name: Restore tools

ExcelFinancialFunctions.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExcelFinancialFunctions.Tes
3535
EndProject
3636
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExcelFinancialFunctions.ConsoleTests", "tests\ExcelFinancialFunctions.ConsoleTests\ExcelFinancialFunctions.ConsoleTests.fsproj", "{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelFinancialFunctions.ReleaseTests", "tests\ExcelFinancialFunctions.ReleaseTests\ExcelFinancialFunctions.ReleaseTests.csproj", "{006B5B4E-1293-4FD9-93EF-B48D93534B9C}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|Any CPU = Debug|Any CPU
@@ -53,6 +55,10 @@ Global
5355
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
5456
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
5557
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{006B5B4E-1293-4FD9-93EF-B48D93534B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{006B5B4E-1293-4FD9-93EF-B48D93534B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{006B5B4E-1293-4FD9-93EF-B48D93534B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{006B5B4E-1293-4FD9-93EF-B48D93534B9C}.Release|Any CPU.Build.0 = Release|Any CPU
5662
EndGlobalSection
5763
GlobalSection(SolutionProperties) = preSolution
5864
HideSolutionNode = FALSE
@@ -63,6 +69,7 @@ Global
6369
{6FEE0C58-7CBD-4091-8D56-55AA733E1131} = {7F0B1813-150B-4B30-8872-625C37BD67D4}
6470
{17FE313F-5304-448C-892E-451E17EEEE83} = {A38472EB-1686-402D-8619-EC2BA407C111}
6571
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F} = {A38472EB-1686-402D-8619-EC2BA407C111}
72+
{006B5B4E-1293-4FD9-93EF-B48D93534B9C} = {A38472EB-1686-402D-8619-EC2BA407C111}
6673
EndGlobalSection
6774
GlobalSection(ExtensibilityGlobals) = postSolution
6875
SolutionGuid = {F7A0269D-790B-4C1C-807C-7415B62CD59B}

tests/ExcelFinancialFunctions.ConsoleTests/SpotTests.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ type SpotTests () =
2626
let spotTest1 f1 f2 p1 =
2727
Assert.AreEqual(f1 p1,f2 p1,precision)
2828
let spotTest2 f1 f2 p1 p2 =
29+
// printfn "%A %A %A" p1 p2 (f1 p1 p2)
2930
Assert.AreEqual(f1 p1 p2,f2 p1 p2,precision)
3031
let spotTest3 f1 f2 p1 p2 p3 =
32+
// printfn "%A %A %A %A" p1 p2 p3 (f1 p1 p2 p3)
3133
Assert.AreEqual(f1 p1 p2 p3,f2 p1 p2 p3,precision)
3234
let spotTest4 f1 f2 p1 p2 p3 p4 =
35+
// printfn "%A %A %A %A %A" p1 p2 p3 p4 (f1 p1 p2 p3 p4)
3336
Assert.AreEqual(f1 p1 p2 p3 p4,f2 p1 p2 p3 p4,precision)
3437
let spotTest5 f1 f2 p1 p2 p3 p4 p5 =
3538
Assert.AreEqual(f1 p1 p2 p3 p4 p5,f2 p1 p2 p3 p4 p5,precision)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net461</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="ExcelFinancialFunctions" Version="3.0.0-rc1" />
11+
<PackageReference Include="NUnit" Version="3.13.2" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Release Tests
2+
3+
This project tests new release candidate nuget packages after they are deployed to the NuGet Gallery. It should always include a reference to the latest released version of the package on NuGet Gallery.
4+
5+
When a new release candidate package is uploaded, we can then update this project to refer to it, then run these tests. This helps ensure that we didn't break anything in the upgrade process.
6+
7+
## Differences
8+
9+
This project has some differences from the unit tests or the interop tests.
10+
11+
* Runs against .NET Framework 4.6.1. This is the oldest supported configuration.
12+
* Written in C#. Helps ensure that the library functions correctly in that language.
13+
* Uses the latest package from NuGet Gallery. Not the locally built code.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using NUnit.Framework;
2+
using Excel.FinancialFunctions;
3+
using System;
4+
5+
namespace ExcelFinancialFunctions.ReleaseTests
6+
{
7+
[DefaultFloatingPointTolerance(1e-6)]
8+
public class SpotTests
9+
{
10+
[Test(ExpectedResult = -0.67428578540657702)]
11+
public double YieldIssue8()
12+
=> Financial.Yield(new DateTime(2015, 9, 21), new DateTime(2015, 10, 15), 0.04625, 105.124, 100.0, Frequency.SemiAnnual, DayCountBasis.UsPsa30_360);
13+
14+
[Test(ExpectedResult = 0.065)]
15+
public double spotYield()
16+
=> Financial.Yield(new DateTime(2008, 2, 15), new DateTime(2016, 11, 15), 0.0575, 95.04287, 100.0, Frequency.SemiAnnual, DayCountBasis.UsPsa30_360);
17+
18+
[Test(ExpectedResult = 1.375214)]
19+
public double spotXnpv()
20+
=> Financial.XNpv(0.14, new double[] { 1.0, 3.0, 4.0 }, new DateTime[] { new DateTime(1970, 3, 2), new DateTime(1988, 2, 3), new DateTime(1999, 3, 5) });
21+
22+
[Test(ExpectedResult = 90.0)]
23+
public double CoupDays()
24+
=> Financial.CoupDays(new DateTime(1984, 3, 4), new DateTime(1990, 4, 5), Frequency.Quarterly, DayCountBasis.UsPsa30_360);
25+
26+
[Test(ExpectedResult = 59.0)]
27+
public double CoupDaysBS()
28+
=> Financial.CoupDaysBS(new DateTime(1984,3,4), new DateTime(1990,4,5),Frequency.Quarterly,DayCountBasis.UsPsa30_360 );
29+
30+
[Test(ExpectedResult = 31.0)]
31+
public double CoupDaysNC()
32+
=> Financial.CoupDaysNC(new DateTime(1984, 3, 4), new DateTime(1990, 4, 5), Frequency.Quarterly, DayCountBasis.UsPsa30_360);
33+
34+
[Test(ExpectedResult = 25.0)]
35+
public double CoupNum()
36+
=> Financial.CoupNum(new DateTime(1984, 3, 4), new DateTime(1990, 4, 5), Frequency.Quarterly, DayCountBasis.UsPsa30_360);
37+
38+
[Test(ExpectedResult = 1.78125)]
39+
public double DollarDe()
40+
=> Financial.DollarDe(1.125,16.0);
41+
42+
[Test(ExpectedResult = 1.02)]
43+
public double DollarFr()
44+
=> Financial.DollarFr(1.125, 16.0);
45+
46+
[Test(ExpectedResult = 0.05354266737)]
47+
public double Effect()
48+
=> Financial.Effect(0.0525, 4.0);
49+
50+
[Test(ExpectedResult = 121.5236352)]
51+
public double FvSchedule()
52+
=> Financial.FvSchedule(100.0, new double[] { 0.13, 0.14, -0.2, 0.34, -0.12 });
53+
54+
[Test(ExpectedResult = 0.260952337)]
55+
public double Irr()
56+
=> Financial.Irr(new double[] { -123.0, 12.0, 15.0, 50.0, 200.0 }, 0.14);
57+
58+
[Test(ExpectedResult = -10.5)]
59+
public double ISPmt()
60+
=> Financial.ISPmt(0.15, 3.0, 10.0, 100.0);
61+
62+
[Test(ExpectedResult = 0.2409336873)]
63+
public double Mirr()
64+
=> Financial.Mirr(new double[] { -123.0, 12.0, 15.0, 50.0, 200.0 }, 0.14, 0.12);
65+
66+
}
67+
}

0 commit comments

Comments
 (0)