Skip to content

Commit cceaee6

Browse files
committed
Update console tests to use new NET Core library and use NUnit
1 parent b66fff3 commit cceaee6

6 files changed

+468
-135
lines changed

ExcelFinancialFunctions.sln

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24720.0
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31702.278
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ExcelFinancialFunctions", "src\ExcelFinancialFunctions\ExcelFinancialFunctions.fsproj", "{8853070C-D0B3-4DE6-B80B-B1D10F839359}"
6+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExcelFinancialFunctions", "src\ExcelFinancialFunctions\ExcelFinancialFunctions.fsproj", "{8853070C-D0B3-4DE6-B80B-B1D10F839359}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7F0B1813-150B-4B30-8872-625C37BD67D4}"
99
EndProject
@@ -31,7 +31,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{499DEF1A-038
3131
EndProject
3232
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A38472EB-1686-402D-8619-EC2BA407C111}"
3333
EndProject
34-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ExcelFinancialFunctions.Tests", "tests\ExcelFinancialFunctions.Tests\ExcelFinancialFunctions.Tests.fsproj", "{17FE313F-5304-448C-892E-451E17EEEE83}"
34+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExcelFinancialFunctions.Tests", "tests\ExcelFinancialFunctions.Tests\ExcelFinancialFunctions.Tests.fsproj", "{17FE313F-5304-448C-892E-451E17EEEE83}"
35+
EndProject
36+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExcelFinancialFunctions.ConsoleTests", "tests\ExcelFinancialFunctions.ConsoleTests\ExcelFinancialFunctions.ConsoleTests.fsproj", "{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}"
3537
EndProject
3638
Global
3739
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -47,6 +49,10 @@ Global
4749
{17FE313F-5304-448C-892E-451E17EEEE83}.Debug|Any CPU.Build.0 = Debug|Any CPU
4850
{17FE313F-5304-448C-892E-451E17EEEE83}.Release|Any CPU.ActiveCfg = Release|Any CPU
4951
{17FE313F-5304-448C-892E-451E17EEEE83}.Release|Any CPU.Build.0 = Release|Any CPU
52+
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53+
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
54+
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
55+
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F}.Release|Any CPU.Build.0 = Release|Any CPU
5056
EndGlobalSection
5157
GlobalSection(SolutionProperties) = preSolution
5258
HideSolutionNode = FALSE
@@ -56,5 +62,9 @@ Global
5662
{5E196AFF-81D3-4BD5-964A-5A9E642CD104} = {7F0B1813-150B-4B30-8872-625C37BD67D4}
5763
{6FEE0C58-7CBD-4091-8D56-55AA733E1131} = {7F0B1813-150B-4B30-8872-625C37BD67D4}
5864
{17FE313F-5304-448C-892E-451E17EEEE83} = {A38472EB-1686-402D-8619-EC2BA407C111}
65+
{EAF937EA-E9E0-4D8D-8DDF-8430CC47CD2F} = {A38472EB-1686-402D-8619-EC2BA407C111}
66+
EndGlobalSection
67+
GlobalSection(ExtensibilityGlobals) = postSolution
68+
SolutionGuid = {F7A0269D-790B-4C1C-807C-7415B62CD59B}
5969
EndGlobalSection
6070
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,26 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
42
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>d9d40c7c-5928-4b59-8def-628fa0e4d8d0</ProjectGuid>
9-
<OutputType>Exe</OutputType>
10-
<RootNamespace>ExcelFinancialFunctions.ConsoleTests</RootNamespace>
11-
<AssemblyName>ExcelFinancialFunctions.ConsoleTests</AssemblyName>
12-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13-
<Name>ExcelFinancialFunctions.ConsoleTests</Name>
14-
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<DebugSymbols>true</DebugSymbols>
17-
<DebugType>full</DebugType>
18-
<Optimize>false</Optimize>
19-
<Tailcalls>false</Tailcalls>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<WarningLevel>3</WarningLevel>
23-
<PlatformTarget>AnyCPU</PlatformTarget>
24-
<DocumentationFile>bin\Debug\ExcelFinancialFunctions.ConsoleTests.XML</DocumentationFile>
25-
<Prefer32Bit>true</Prefer32Bit>
26-
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28-
<DebugType>pdbonly</DebugType>
29-
<Optimize>true</Optimize>
30-
<Tailcalls>true</Tailcalls>
31-
<OutputPath>bin\Release\</OutputPath>
32-
<DefineConstants>TRACE</DefineConstants>
33-
<WarningLevel>3</WarningLevel>
34-
<PlatformTarget>AnyCPU</PlatformTarget>
35-
<DocumentationFile>bin\Release\ExcelFinancialFunctions.ConsoleTests.XML</DocumentationFile>
36-
<Prefer32Bit>true</Prefer32Bit>
3+
<TargetFramework>net48</TargetFramework>
4+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
5+
<WarnOn>3390;$(WarnOn)</WarnOn>
376
</PropertyGroup>
7+
388
<ItemGroup>
39-
<Reference Include="ExcelFinancialFunctions">
40-
<HintPath>..\..\bin\ExcelFinancialFunctions\ExcelFinancialFunctions.dll</HintPath>
41-
</Reference>
42-
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
43-
<Reference Include="System" />
44-
<Reference Include="System.Core" />
45-
<Reference Include="System.Numerics" />
46-
</ItemGroup>
47-
<ItemGroup>
9+
<None Include="README.md" />
4810
<Compile Include="excel.fs" />
4911
<Compile Include="testinfrastructure.fs" />
5012
<Compile Include="testsdef.fs" />
51-
<Compile Include="testsexec.fs" />
13+
<Compile Include="MatrixTests.fs" />
14+
<Compile Include="SpotTests.fs" />
5215
</ItemGroup>
53-
<PropertyGroup>
54-
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
55-
</PropertyGroup>
56-
<Choose>
57-
<When Condition="'$(VisualStudioVersion)' == '11.0'">
58-
<PropertyGroup>
59-
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
60-
</PropertyGroup>
61-
</When>
62-
<Otherwise>
63-
<PropertyGroup>
64-
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
65-
</PropertyGroup>
66-
</Otherwise>
67-
</Choose>
68-
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
69-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
70-
Other similar extension points exist, see Microsoft.Common.targets.
71-
<Target Name="BeforeBuild">
72-
</Target>
73-
<Target Name="AfterBuild">
74-
</Target>
75-
-->
76-
</Project>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
19+
<PackageReference Include="NUnit" Version="3.13.2" />
20+
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<ProjectReference Include="..\..\src\ExcelFinancialFunctions\ExcelFinancialFunctions.fsproj" />
25+
</ItemGroup>
26+
</Project>

tests/ExcelFinancialFunctions.ConsoleTests/ExcelFinancialFunctions.ConsoleTests_vs2010.fsproj

-62
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
namespace Excel.FinancialFunctions
2+
3+
open NUnit.Framework
4+
open TestInfrastructure
5+
open Excel.FinancialFunctions.ExcelTesting
6+
open Excel.FinancialFunctions.Tvm
7+
open Excel.FinancialFunctions.Loan
8+
open Excel.FinancialFunctions.Irr
9+
open Excel.FinancialFunctions.Depreciation
10+
open Excel.FinancialFunctions.DayCount
11+
open Excel.FinancialFunctions.TestsDef
12+
open Excel.FinancialFunctions.Bonds
13+
open Excel.FinancialFunctions.TBill
14+
open Excel.FinancialFunctions.Misc
15+
open Excel.FinancialFunctions.OddBonds
16+
open Excel.FinancialFunctions.TestPreconditions
17+
18+
[<Parallelizable(ParallelScope.Children)>]
19+
type MatrixTests () =
20+
let tests = [|
21+
// --------------------------------------------------------------------------------------------------
22+
//"RATE", Excel uses a different root finding algo. Sometimes mine is better, sometimes Excel's is. Using the TestRate function instead.
23+
//"ODDFYIELD", Excel uses a different root finding algo. Sometimes mine is better, sometimes Excel's is. Using the TestOddFYield function instead.
24+
//"XNPV", the excel object model has an xnpv function with a different number of args. Tested through XIRR and separate testcase.
25+
//"YIELD", the excel object model lacks this function. Tested through the price function and separate testcase.
26+
// --------------------------------------------------------------------------------------------------
27+
"PV", (fun _ -> test5 calcPv pvEx rates npers pmts fvs dues tryPv);
28+
"FV", (fun _ -> test5 calcFv fvEx rates npers pmts pvs dues tryFv);
29+
"PMT", (fun _ -> test5 calcPmt pmtEx rates npers pvs fvs dues tryPmt);
30+
"NPER", (fun _ -> test5 calcNper nperEx rates pmts pvs fvs dues tryNper);
31+
"IPMT", (fun _ -> test6 calcIpmt ipmtEx rates pers npers pvs fvs dues tryIpmt);
32+
"PPMT", (fun _ -> test6 calcPpmt ppmtEx rates pers npers pvs fvs dues tryPpmt);
33+
"CUMIPMT", (fun _ -> test6 calcCumipmt cumipmtEx rates npers pvs pers endPers dues tryCumipmt);
34+
"CUMPRINC", (fun _ -> test6 calcCumprinc cumprincEx rates npers pvs pers endPers dues tryCumprinc);
35+
"ISPMT", (fun _ -> test4 calcIspmt ispmtEx rates pers npers pvs tryIspmt);
36+
"FVSCHEDULE", (fun _ -> test2 calcFvSchedule fvScheduleEx pvs testInterests precondOk2);
37+
"IRR", (fun _ -> test2 calcIrr irrEx testCfs guesses precondOk2);
38+
"NPV", (fun _ -> test2 calcNpv npvEx rates testCfs tryNpv);
39+
"MIRR", (fun _ -> test3 calcMirr mirrEx testCfs rates rates tryMirr);
40+
//"XIRR", fun _-> test3 calcXirr xirrEx testCfs testDates guesses tryXirr;
41+
"DB", fun _ -> test5 calcDb dbEx testCosts testSalvages testLives testPeriods testMonths tryDb;
42+
"SLN", fun _ -> test3 calcSln slnEx testCosts testSalvages testLives trySln;
43+
"SYD", fun _ -> test4 calcSyd sydEx testCosts testSalvages testLives testPeriods trySyd;
44+
"DDB", fun _ -> test5 calcDdb ddbEx testCosts testSalvages testLives testDdbPeriods testFactors tryDdb;
45+
"VDB excluding fractional startdates", fun _ -> test7 vdbWrap vdbEx testCosts testSalvages testLives testPeriods testEndPeriods testFactors testVdbSwitch tryVdb;
46+
"AMORLINC", fun _ -> test7 calcAmorLinc amorLincEx testCosts testIssueDates testFirstInterestDates testSalvages testPeriods testBondRates testDayCountBasis tryAmorLinc;
47+
"AMORDEGRC", fun _ -> test7 amorDegrcWrapper amorDegrcEx testCosts testIssueDates testFirstInterestDates testSalvages testPeriods testDeprRates testDayCountBasis tryAmorDegrc;
48+
"COUPDAYS excluding leap years", fun _ -> test4 calcCoupDays coupDaysEx testSettlDates testMatDates testFrequency testDayCountBasis tryCoupDays;
49+
"COUPDAYSBS", fun _ -> test4 calcCoupDaysBS coupDaysBSEx testSettlDates testMatDates testFrequency testDayCountBasis tryCoupDaysBS;
50+
"COUPDAYSNC", fun _ -> test4 calcCoupDaysNC coupDaysNCEx testSettlDates testMatDates testFrequency testDayCountBasis tryCoupDaysNC;
51+
"COUPNUM", fun _ -> test4 calcCoupNum coupNumEx testSettlDates testMatDates testFrequency testDayCountBasis tryCoupNum;
52+
"COUPPCD", fun _ -> test4 coupPCDWrapper coupPCDEx testSettlDates testMatDates testFrequency testDayCountBasis tryCoupPCD;
53+
"COUPNCD", fun _ -> test4 coupNCDWrapper coupNCDEx testSettlDates testMatDates testFrequency testDayCountBasis tryCoupNCD;
54+
"ACCRINTM", fun _ -> test5 calcAccrIntM accrIntMEx testIssue testSettl testBondRates testPars testDayCountBasis tryAccrIntM;
55+
"ACCRINT", fun _ -> test7 calcAccrIntWrap accrIntEx testIssue testFirstInt testSettl testBondRates testPars testFrequency testDayCountBasis tryAccrInt;
56+
"PRICE", fun _ -> test7 calcPrice priceEx testSettlDates testMatDates testBondRates testYlds testRedemptions testFrequency testDayCountBasis tryPrice
57+
"PRICEMAT", fun _ -> test6 calcPriceMat priceMatEx testSettlDates testMatDates testIssue testBondRates testYlds testDayCountBasis tryPriceMat
58+
"YIELDMAT", fun _ -> test6 calcYieldMat yieldMatEx testSettlDates testMatDates testIssue testBondRates testPrices testDayCountBasis tryYieldMat
59+
"YEARFRAC", fun _ -> test3 calcYearFrac yearFracEx testSDates testEDates testDayCountBasis tryYearFrac;
60+
"INTRATE", fun _ -> test5 calcIntRate intRateEx testSettlDates testMatDates testInvestments testRedemptions testDayCountBasis tryIntRate;
61+
"RECEIVED", fun _ -> test5 calcReceived receivedEx testSettlDates testMatDates testInvestments testDiscounts testDayCountBasis tryReceived;
62+
"DISC", fun _ -> test5 calcDisc discEx testSettlDates testMatDates testInvestments testRedemptions testDayCountBasis tryDisc;
63+
"PRICEDISC", fun _ -> test5 calcPriceDisc priceDiscEx testSettlDates testMatDates testDiscounts testRedemptions testDayCountBasis tryPriceDisc;
64+
"YIELDDISC", fun _ -> test5 calcYieldDisc yieldDiscEx testSettlDates testMatDates testInvestments testRedemptions testDayCountBasis tryYieldDisc;
65+
"TBILLEQ", fun _ -> test3 calcTBillEq TBillEqEx testSettlDates testTBillMat testDiscounts tryTBillEq;
66+
"TBILLYIELD", fun _ -> test3 calcTBillYield TBillYieldEx testSettlDates testTBillMat testPrices tryTBillYield;
67+
"TBILLPrice", fun _ -> test3 calcTBillPrice TBillPriceEx testSettlDates testTBillMat testDiscounts tryTBillPrice;
68+
"DOLLARDE", fun _ -> test2 calcDollarDe dollarDeEx testFractionalDollars testFractions tryDollarDe;
69+
"DOLLARFR", fun _ -> test2 calcDollarFr dollarFrEx testFractionalDollars testFractions tryDollarFr;
70+
"EFFECT", fun _ -> test2 calcEffect effectEx rates testPeriods tryEffect;
71+
"NOMINAL", fun _ -> test2 calcNominal nominalEx rates testPeriods tryNominal;
72+
"DURATION", fun _ -> test6 calcDuration durationEx testSettlDates testMatDates testInvestments testYlds testFrequency testDayCountBasis tryDuration;
73+
"MDURATION", fun _ -> test6 calcMDuration mdurationEx testSettlDates testMatDates testInvestments testYlds testFrequency testDayCountBasis tryMDuration;
74+
"ODDFPRICE", fun _ -> test9 calcOddFPrice oddFPriceEx testSettlDates2 testMatDates testIssueDates testFirstInterestDates testBondRates testYlds testRedemptions testFrequency testDayCountBasis tryOddFPrice;
75+
"ODDLPRICE", fun _ -> test8 calcOddLPrice oddLPriceEx testSettlDates2 testMatDates testIssueDates testBondRates testYlds testRedemptions testFrequency testDayCountBasis tryOddLPrice;
76+
"ODDLYIELD", fun _ -> test8 calcOddLYield oddLYieldEx testSettlDates2 testMatDates testIssueDates testBondRates testRedemptions testRedemptions testFrequency testDayCountBasis tryOddLYield;
77+
|]
78+
79+
[<TestCase("PV")>]
80+
[<TestCase("FV")>]
81+
[<TestCase("PMT")>]
82+
[<TestCase("NPER")>]
83+
[<TestCase("IPMT")>]
84+
[<TestCase("PPMT")>]
85+
[<TestCase("CUMIPMT",Category="Fast")>]
86+
[<TestCase("CUMPRINC",Category="Fast")>]
87+
[<TestCase("ISPMT")>]
88+
[<TestCase("DB")>]
89+
[<TestCase("SLN",Category="Fast")>]
90+
[<TestCase("SYD",Category="Fast")>]
91+
[<TestCase("DDB")>]
92+
[<TestCase("VDB excluding fractional startdates")>]
93+
[<TestCase("FVSCHEDULE",Category="Fast")>]
94+
[<TestCase("MIRR",Category="Fast")>]
95+
[<TestCase("NPV")>]
96+
[<TestCase("ISPMT")>]
97+
[<TestCase("IRR",Category="Fast")>]
98+
[<TestCase("AMORLINC")>]
99+
[<TestCase("AMORDEGRC")>]
100+
[<TestCase("COUPDAYS excluding leap years")>]
101+
[<TestCase("COUPDAYSBS")>]
102+
[<TestCase("COUPDAYSNC")>]
103+
[<TestCase("COUPNUM")>]
104+
[<TestCase("COUPPCD")>]
105+
[<TestCase("COUPNCD")>]
106+
[<TestCase("ACCRINTM")>]
107+
[<TestCase("ACCRINT")>]
108+
[<TestCase("PRICE")>]
109+
[<TestCase("PRICEMAT")>]
110+
[<TestCase("YIELDMAT")>]
111+
[<TestCase("YEARFRAC")>]
112+
[<TestCase("INTRATE")>]
113+
[<TestCase("RECEIVED")>]
114+
[<TestCase("DISC")>]
115+
[<TestCase("PRICEDISC")>]
116+
[<TestCase("YIELDDISC")>]
117+
[<TestCase("TBILLEQ")>]
118+
[<TestCase("TBILLYIELD",Category="Fast")>]
119+
[<TestCase("TBILLPrice",Category="Fast")>]
120+
[<TestCase("DOLLARDE",Category="Fast")>]
121+
[<TestCase("DOLLARFR",Category="Fast")>]
122+
[<TestCase("EFFECT",Category="Fast")>]
123+
[<TestCase("NOMINAL",Category="Fast")>]
124+
[<TestCase("DURATION")>]
125+
[<TestCase("MDURATION")>]
126+
[<TestCase("ODDFPRICE")>]
127+
[<TestCase("ODDLPRICE")>]
128+
[<TestCase("ODDLYIELD")>]
129+
member __.RunMatrix test =
130+
let found = Array.tryFind (fun x -> fst x = test) tests
131+
let (_,func) = found.Value
132+
let (tries,success,_,_) = func ()
133+
Assert.AreEqual(success,tries)

0 commit comments

Comments
 (0)