diff --git a/src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs b/src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs new file mode 100644 index 00000000..1652aa29 --- /dev/null +++ b/src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs @@ -0,0 +1,410 @@ +// +// Math.NET Numerics, part of the Math.NET Project +// http://numerics.mathdotnet.com +// http://github.com/mathnet/mathnet-numerics +// http://mathnetnumerics.codeplex.com +// +// Copyright (c) 2009-2010 Math.NET +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double +{ + using System; + using System.Collections.Generic; + using Algorithms.LinearAlgebra; + using LinearAlgebra.Double; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + /// + /// Base class for linear algebra provider tests. + /// + [TestClass] + public class LinearAlgebraProviderTests + { + /// + /// Initializes a new instance of the class. + /// + public LinearAlgebraProviderTests() + { + Provider = new ManagedLinearAlgebraProvider(); + } + + /// + /// Gets or sets linear algebra provider to test. + /// + protected ILinearAlgebraProvider Provider + { + get; + set; + } + + /// + /// The Y double test vector. + /// + private readonly double[] _y = new[] { 1.1, 2.2, 3.3, 4.4, 5.5 }; + + /// + /// The X double test vector. + /// + private readonly double[] _x = new[] { 6.6, 7.7, 8.8, 9.9, 10.1 }; + + /// + /// Test matrix to use. + /// + private readonly IDictionary _matrices = new Dictionary + { + { "Singular3x3", new DenseMatrix(new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } }) }, + { "Square3x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } }) }, + { "Square4x4", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } }) }, + { "Singular4x4", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } }) }, + { "Tall3x2", new DenseMatrix(new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, + { "Wide2x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) } + }; + + /// + /// Can add a vector to scaled vector + /// + [TestMethod] + public void CanAddVectorToScaledVectorDouble() + { + var result = new double[_y.Length]; + Array.Copy(_y, result, _y.Length); + + Provider.AddVectorToScaledVector(result, 0, _x); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i], result[i]); + } + + Array.Copy(_y, result, _y.Length); + Provider.AddVectorToScaledVector(result, 1, _x); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i] + _x[i], result[i]); + } + + Array.Copy(_y, result, _y.Length); + Provider.AddVectorToScaledVector(result, Math.PI, _x); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i] + (Math.PI * _x[i]), result[i]); + } + } + + /// + /// Can scale an array. + /// + [TestMethod] + public void CanScaleArray() + { + var result = new double[_y.Length]; + + Array.Copy(_y, result, _y.Length); + Provider.ScaleArray(1, result); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i], result[i]); + } + + Array.Copy(_y, result, _y.Length); + Provider.ScaleArray(Math.PI, result); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i] * Math.PI, result[i]); + } + } + + /// + /// Can compute the dot product. + /// + [TestMethod] + public void CanComputeDotProduct() + { + var result = Provider.DotProduct(_x, _y); + AssertHelpers.AlmostEqual(152.35, result, 15); + } + + /// + /// Can add two arrays. + /// + [TestMethod] + public void CanAddArrays() + { + var result = new double[_y.Length]; + Provider.AddArrays(_x, _y, result); + for (var i = 0; i < result.Length; i++) + { + Assert.AreEqual(_x[i] + _y[i], result[i]); + } + } + + /// + /// Can subtract two arrays. + /// + [TestMethod] + public void CanSubtractArrays() + { + var result = new double[_y.Length]; + Provider.SubtractArrays(_x, _y, result); + for (var i = 0; i < result.Length; i++) + { + Assert.AreEqual(_x[i] - _y[i], result[i]); + } + } + + /// + /// Can pointwise multiply two arrays. + /// + [TestMethod] + public void CanPointWiseMultiplyArrays() + { + var result = new double[_y.Length]; + Provider.PointWiseMultiplyArrays(_x, _y, result); + for (var i = 0; i < result.Length; i++) + { + Assert.AreEqual(_x[i] * _y[i], result[i]); + } + } + + /// + /// Can compute L1 norm. + /// + [TestMethod] + public void CanComputeMatrixL1Norm() + { + var matrix = _matrices["Square3x3"]; + var work = new double[matrix.RowCount]; + var norm = Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work); + AssertHelpers.AlmostEqual(12.1, norm, 6); + } + + /// + /// Can compute Frobenius norm. + /// + [TestMethod] + public void CanComputeMatrixFrobeniusNorm() + { + var matrix = _matrices["Square3x3"]; + var work = new double[matrix.RowCount]; + var norm = Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work); + AssertHelpers.AlmostEqual(10.777754868246, norm, 8); + } + + /// + /// Can compute Infinity norm. + /// + [TestMethod] + public void CanComputeMatrixInfinityNorm() + { + var matrix = _matrices["Square3x3"]; + var work = new double[matrix.RowCount]; + var norm = Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work); + Assert.AreEqual(16.5, norm); + } + + /// + /// Can compute L1 norm using a work array. + /// + [TestMethod] + public void CanComputeMatrixL1NormWithWorkArray() + { + var matrix = _matrices["Square3x3"]; + var norm = Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data); + AssertHelpers.AlmostEqual(12.1, norm, 6); + } + + /// + /// Can compute Frobenius norm using a work array. + /// + [TestMethod] + public void CanComputeMatrixFrobeniusNormWithWorkArray() + { + var matrix = _matrices["Square3x3"]; + var norm = Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data); + AssertHelpers.AlmostEqual(10.777754868246, norm, 8); + } + + /// + /// Can compute Infinity norm using a work array. + /// + [TestMethod] + public void CanComputeMatrixInfinityNormWithWorkArray() + { + var matrix = _matrices["Square3x3"]; + var norm = Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data); + Assert.AreEqual(16.5, norm); + } + + /// + /// Can multiply two square matrices. + /// + [TestMethod] + public void CanMultiplySquareMatrices() + { + var x = _matrices["Singular3x3"]; + var y = _matrices["Square3x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a wide and tall matrix. + /// + [TestMethod] + public void CanMultiplyWideAndTallMatrices() + { + var x = _matrices["Wide2x3"]; + var y = _matrices["Tall3x2"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a tall and wide matrix. + /// + [TestMethod] + public void CanMultiplyTallAndWideMatrices() + { + var x = _matrices["Tall3x2"]; + var y = _matrices["Wide2x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply two square matrices. + /// + [TestMethod] + public void CanMultiplySquareMatricesWithUpdate() + { + var x = _matrices["Singular3x3"]; + var y = _matrices["Square3x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(2.2 * x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a wide and tall matrix. + /// + [TestMethod] + public void CanMultiplyWideAndTallMatricesWithUpdate() + { + var x = _matrices["Wide2x3"]; + var y = _matrices["Tall3x2"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(2.2 * x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a tall and wide matrix. + /// + [TestMethod] + public void CanMultiplyTallAndWideMatricesWithUpdate() + { + var x = _matrices["Tall3x2"]; + var y = _matrices["Wide2x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(2.2 * x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can compute the Cholesky factorization. + /// + [TestMethod] + public void CanComputeCholeskyFactor() + { + var matrix = new double[] { 1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15 }; + Provider.CholeskyFactor(matrix, 4); + Assert.AreEqual(matrix[0], 1); + Assert.AreEqual(matrix[1], 1); + Assert.AreEqual(matrix[2], 1); + Assert.AreEqual(matrix[3], 1); + Assert.AreEqual(matrix[4], 0); + Assert.AreEqual(matrix[5], 2); + Assert.AreEqual(matrix[6], 2); + Assert.AreEqual(matrix[7], 2); + Assert.AreEqual(matrix[8], 0); + Assert.AreEqual(matrix[9], 0); + Assert.AreEqual(matrix[10], 3); + Assert.AreEqual(matrix[11], 3); + Assert.AreEqual(matrix[12], 0); + Assert.AreEqual(matrix[13], 0); + Assert.AreEqual(matrix[14], 0); + Assert.AreEqual(matrix[15], 1); + } + } +} \ No newline at end of file diff --git a/src/MSUnitTests/LinearAlgebraProviderTests/LinearAlgebraProviderTests/ManagedLinearAlgebraProviderTests.cs b/src/MSUnitTests/LinearAlgebraProviderTests/LinearAlgebraProviderTests/ManagedLinearAlgebraProviderTests.cs deleted file mode 100644 index ac1e5223..00000000 --- a/src/MSUnitTests/LinearAlgebraProviderTests/LinearAlgebraProviderTests/ManagedLinearAlgebraProviderTests.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://numerics.mathdotnet.com -// http://github.com/mathnet/mathnet-numerics -// http://mathnetnumerics.codeplex.com -// -// Copyright (c) 2009-2010 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Unit test container for the managed linear algebra provider. - /// - [TestClass] - public class ManagedLinearAlgebraProviderTests : LinearAlgebraProviderTests - { - /// - /// Sets the linear algebra provider to the managed one. - /// - /// The test context to use. - [ClassInitialize] - public static void SetProvider(TestContext context) - { - Provider = new Algorithms.LinearAlgebra.ManagedLinearAlgebraProvider(); - } - } -} diff --git a/src/MSUnitTests/MSUnitTests.csproj b/src/MSUnitTests/MSUnitTests.csproj index 3258e705..4b75065a 100644 --- a/src/MSUnitTests/MSUnitTests.csproj +++ b/src/MSUnitTests/MSUnitTests.csproj @@ -47,8 +47,7 @@ - - + diff --git a/src/MathNet.Numerics.sln b/src/MathNet.Numerics.sln index 0df10e2f..935903e9 100644 --- a/src/MathNet.Numerics.sln +++ b/src/MathNet.Numerics.sln @@ -28,10 +28,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{4D50FB34 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{49EE74BD-301F-4C3B-B76A-07F90CC88CE7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightUnitTests", "SilverlightUnitTests\SilverlightUnitTests.csproj", "{6271AB18-BFD3-4CC5-81E4-55E1F4BC10FB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightUnitTests.Web", "SilverlightUnitTests.Web\SilverlightUnitTests.Web.csproj", "{477CCFEB-B5BF-496D-9449-6C8AD5A782AE}" -EndProject Global GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = MathNet.Numerics.vsmdi @@ -73,14 +69,6 @@ Global {624FB757-A724-4B0D-85EB-F0563CE43A33}.Debug|Any CPU.Build.0 = Debug|Any CPU {624FB757-A724-4B0D-85EB-F0563CE43A33}.Release|Any CPU.ActiveCfg = Release|Any CPU {624FB757-A724-4B0D-85EB-F0563CE43A33}.Release|Any CPU.Build.0 = Release|Any CPU - {6271AB18-BFD3-4CC5-81E4-55E1F4BC10FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6271AB18-BFD3-4CC5-81E4-55E1F4BC10FB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6271AB18-BFD3-4CC5-81E4-55E1F4BC10FB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6271AB18-BFD3-4CC5-81E4-55E1F4BC10FB}.Release|Any CPU.Build.0 = Release|Any CPU - {477CCFEB-B5BF-496D-9449-6C8AD5A782AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {477CCFEB-B5BF-496D-9449-6C8AD5A782AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {477CCFEB-B5BF-496D-9449-6C8AD5A782AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {477CCFEB-B5BF-496D-9449-6C8AD5A782AE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -91,7 +79,5 @@ Global {F2F8032B-A31D-4E33-A05E-F2CDCBFAA75D} = {4D50FB34-10BC-495A-8B2F-482E34B4D771} {624FB757-A724-4B0D-85EB-F0563CE43A33} = {4D50FB34-10BC-495A-8B2F-482E34B4D771} {8C9A5D3F-A20C-4D24-A09C-98E187A8D720} = {4D50FB34-10BC-495A-8B2F-482E34B4D771} - {6271AB18-BFD3-4CC5-81E4-55E1F4BC10FB} = {4D50FB34-10BC-495A-8B2F-482E34B4D771} - {477CCFEB-B5BF-496D-9449-6C8AD5A782AE} = {4D50FB34-10BC-495A-8B2F-482E34B4D771} EndGlobalSection EndGlobal diff --git a/src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs b/src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs index 7bebe211..71b765aa 100644 --- a/src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs +++ b/src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs @@ -40,13 +40,11 @@ namespace MathNet.Numerics.MklWrapperTests.LinearAlgebra.Double public class MklLinearAlgebraProviderTests : LinearAlgebraProviderTests { /// - /// Sets the linear algebra provider to the managed one. + /// Initializes a new instance of the class. /// - /// The test context to use. - [ClassInitialize] - public static void SetProvider(TestContext context) - { - Provider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider(); - } + public MklLinearAlgebraProviderTests() + { + Provider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider(); + } } } diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/ClientBin/SilverlightUnitTests.xap b/src/SilverlightUnitTests/SilverlightUnitTests.Web/ClientBin/SilverlightUnitTests.xap new file mode 100644 index 00000000..9b8ab729 Binary files /dev/null and b/src/SilverlightUnitTests/SilverlightUnitTests.Web/ClientBin/SilverlightUnitTests.xap differ diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..dcfe8525 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SilverlightUnitTests.Web")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SilverlightUnitTests.Web")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5868b737-92b9-4ca4-bdd8-f86f35a777f2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Silverlight.js b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Silverlight.js new file mode 100644 index 00000000..80ff3970 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Silverlight.js @@ -0,0 +1,2 @@ +//v2.0.30511.0 +if(!window.Silverlight)window.Silverlight={};Silverlight._silverlightCount=0;Silverlight.__onSilverlightInstalledCalled=false;Silverlight.fwlinkRoot="http://go2.microsoft.com/fwlink/?LinkID=";Silverlight.__installationEventFired=false;Silverlight.onGetSilverlight=null;Silverlight.onSilverlightInstalled=function(){window.location.reload(false)};Silverlight.isInstalled=function(b){if(b==undefined)b=null;var a=false,m=null;try{var i=null,j=false;if(window.ActiveXObject)try{i=new ActiveXObject("AgControl.AgControl");if(b===null)a=true;else if(i.IsVersionSupported(b))a=true;i=null}catch(l){j=true}else j=true;if(j){var k=navigator.plugins["Silverlight Plug-In"];if(k)if(b===null)a=true;else{var h=k.description;if(h==="1.0.30226.2")h="2.0.30226.2";var c=h.split(".");while(c.length>3)c.pop();while(c.length<4)c.push(0);var e=b.split(".");while(e.length>4)e.pop();var d,g,f=0;do{d=parseInt(e[f]);g=parseInt(c[f]);f++}while(f");delete a.id;delete a.width;delete a.height;for(var c in a)if(a[c])b.push('');b.push("");return b.join("")};Silverlight.createObjectEx=function(b){var a=b,c=Silverlight.createObject(a.source,a.parentElement,a.id,a.properties,a.events,a.initParams,a.context);if(a.parentElement==null)return c};Silverlight.buildPromptHTML=function(b){var a="",d=Silverlight.fwlinkRoot,c=b.version;if(b.alt)a=b.alt;else{if(!c)c="";a="Get Microsoft Silverlight";a=a.replace("{1}",c);a=a.replace("{2}",d+"108181")}return a};Silverlight.getSilverlight=function(e){if(Silverlight.onGetSilverlight)Silverlight.onGetSilverlight();var b="",a=String(e).split(".");if(a.length>1){var c=parseInt(a[0]);if(isNaN(c)||c<2)b="1.0";else b=a[0]+"."+a[1]}var d="";if(b.match(/^\d+\056\d+$/))d="&v="+b;Silverlight.followFWLink("149156"+d)};Silverlight.followFWLink=function(a){top.location=Silverlight.fwlinkRoot+String(a)};Silverlight.HtmlAttributeEncode=function(c){var a,b="";if(c==null)return null;for(var d=0;d96&&a<123||a>64&&a<91||a>43&&a<58&&a!=47||a==95)b=b+String.fromCharCode(a);else b=b+"&#"+a+";"}return b};Silverlight.default_error_handler=function(e,b){var d,c=b.ErrorType;d=b.ErrorCode;var a="\nSilverlight error message \n";a+="ErrorCode: "+d+"\n";a+="ErrorType: "+c+" \n";a+="Message: "+b.ErrorMessage+" \n";if(c=="ParserError"){a+="XamlFile: "+b.xamlFile+" \n";a+="Line: "+b.lineNumber+" \n";a+="Position: "+b.charPosition+" \n"}else if(c=="RuntimeError"){if(b.lineNumber!=0){a+="Line: "+b.lineNumber+" \n";a+="Position: "+b.charPosition+" \n"}a+="MethodName: "+b.methodName+" \n"}alert(a)};Silverlight.__cleanup=function(){for(var a=Silverlight._silverlightCount-1;a>=0;a--)window["__slEvent"+a]=null;Silverlight._silverlightCount=0;if(window.removeEventListener)window.removeEventListener("unload",Silverlight.__cleanup,false);else window.detachEvent("onunload",Silverlight.__cleanup)};Silverlight.__getHandlerName=function(b){var a="";if(typeof b=="string")a=b;else if(typeof b=="function"){if(Silverlight._silverlightCount==0)if(window.addEventListener)window.addEventListener("onunload",Silverlight.__cleanup,false);else window.attachEvent("onunload",Silverlight.__cleanup);var c=Silverlight._silverlightCount++;a="__slEvent"+c;window[a]=b}else a=null;return a};Silverlight.onRequiredVersionAvailable=function(){};Silverlight.onRestartRequired=function(){};Silverlight.onUpgradeRequired=function(){};Silverlight.onInstallRequired=function(){};Silverlight.IsVersionAvailableOnError=function(d,a){var b=false;try{if(a.ErrorCode==8001&&!Silverlight.__installationEventFired){Silverlight.onUpgradeRequired();Silverlight.__installationEventFired=true}else if(a.ErrorCode==8002&&!Silverlight.__installationEventFired){Silverlight.onRestartRequired();Silverlight.__installationEventFired=true}else if(a.ErrorCode==5014||a.ErrorCode==2106){if(Silverlight.__verifySilverlight2UpgradeSuccess(a.getHost()))b=true}else b=true}catch(c){}return b};Silverlight.IsVersionAvailableOnLoad=function(b){var a=false;try{if(Silverlight.__verifySilverlight2UpgradeSuccess(b.getHost()))a=true}catch(c){}return a};Silverlight.__verifySilverlight2UpgradeSuccess=function(d){var c=false,b="2.0.31005",a=null;try{if(d.IsVersionSupported(b+".99")){a=Silverlight.onRequiredVersionAvailable;c=true}else if(d.IsVersionSupported(b+".0"))a=Silverlight.onRestartRequired;else a=Silverlight.onUpgradeRequired;if(a&&!Silverlight.__installationEventFired){a();Silverlight.__installationEventFired=true}}catch(e){}return c} \ No newline at end of file diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj new file mode 100644 index 00000000..5f893093 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + + + 2.0 + {955CBD46-9E5E-454D-8BA8-087C3AD36CE8} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + SilverlightUnitTests.Web + SilverlightUnitTests.Web + v4.0 + {2E7CF5BB-2E02-4654-8964-79675F535727}|..\SilverlightUnitTests\SilverlightUnitTests.csproj|ClientBin|False + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + + + + + + + + + False + True + 40188 + / + + + False + False + + + False + + + + + + \ No newline at end of file diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTestsTestPage.aspx b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTestsTestPage.aspx new file mode 100644 index 00000000..c3a095be --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTestsTestPage.aspx @@ -0,0 +1,74 @@ +<%@ Page Language="C#" AutoEventWireup="true" %> + + + + + SilverlightUnitTests + + + + + +
+
+ + + + + + + + Get Microsoft Silverlight + +
+
+ + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTestsTestPage.html b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTestsTestPage.html new file mode 100644 index 00000000..d8252299 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTestsTestPage.html @@ -0,0 +1,73 @@ + + + + + SilverlightUnitTests + + + + + +
+
+ + + + + + + + Get Microsoft Silverlight + +
+
+ + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.Debug.config b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.Debug.config new file mode 100644 index 00000000..2c6dd51a --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.Release.config b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.Release.config new file mode 100644 index 00000000..4122d79b --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.config b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.config new file mode 100644 index 00000000..ea5e4d6e --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Web.config @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.sln b/src/SilverlightUnitTests/SilverlightUnitTests.sln new file mode 100644 index 00000000..4fa0c322 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightUnitTests", "SilverlightUnitTests\SilverlightUnitTests.csproj", "{2E7CF5BB-2E02-4654-8964-79675F535727}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightUnitTests.Web", "SilverlightUnitTests.Web\SilverlightUnitTests.Web.csproj", "{955CBD46-9E5E-454D-8BA8-087C3AD36CE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2E7CF5BB-2E02-4654-8964-79675F535727}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E7CF5BB-2E02-4654-8964-79675F535727}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E7CF5BB-2E02-4654-8964-79675F535727}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E7CF5BB-2E02-4654-8964-79675F535727}.Release|Any CPU.Build.0 = Release|Any CPU + {955CBD46-9E5E-454D-8BA8-087C3AD36CE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {955CBD46-9E5E-454D-8BA8-087C3AD36CE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {955CBD46-9E5E-454D-8BA8-087C3AD36CE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {955CBD46-9E5E-454D-8BA8-087C3AD36CE8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/App.xaml b/src/SilverlightUnitTests/SilverlightUnitTests/App.xaml new file mode 100644 index 00000000..c2f8b3ef --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/App.xaml.cs b/src/SilverlightUnitTests/SilverlightUnitTests/App.xaml.cs new file mode 100644 index 00000000..a00992bf --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests/App.xaml.cs @@ -0,0 +1,58 @@ +using System; +using System.Windows; +using Microsoft.Silverlight.Testing; + +namespace SilverlightUnitTests +{ + public partial class App : Application + { + + public App() + { + this.Startup += this.Application_Startup; + this.Exit += this.Application_Exit; + this.UnhandledException += this.Application_UnhandledException; + + InitializeComponent(); + } + + private void Application_Startup(object sender, StartupEventArgs e) + { + RootVisual = UnitTestSystem.CreateTestPage(); + } + + private void Application_Exit(object sender, EventArgs e) + { + + } + private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + // If the app is running outside of the debugger then report the exception using + // the browser's exception mechanism. On IE this will display it a yellow alert + // icon in the status bar and Firefox will display a script error. + if (!System.Diagnostics.Debugger.IsAttached) + { + + // NOTE: This will allow the application to continue running after an exception has been thrown + // but not handled. + // For production applications this error handling should be replaced with something that will + // report the error to the website and stop the application. + e.Handled = true; + Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); + } + } + private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e) + { + try + { + string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; + errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); + + System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");"); + } + catch (Exception) + { + } + } + } +} \ No newline at end of file diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AppManifest.xml b/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AppManifest.xml new file mode 100644 index 00000000..fd53a6b3 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AppManifest.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs b/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..8a201aa8 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +// Copyright © Microsoft 2010 + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SilverlightUnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SilverlightUnitTests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ea9dc74-07ae-49b4-a6d8-88b3d83c29c0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj b/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj new file mode 100644 index 00000000..15d7cba8 --- /dev/null +++ b/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj @@ -0,0 +1,125 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {2E7CF5BB-2E02-4654-8964-79675F535727} + {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + SilverlightUnitTests + SilverlightUnitTests + Silverlight + v4.0 + $(TargetFrameworkVersion) + true + + true + true + SilverlightUnitTests.xap + Properties\AppManifest.xml + SilverlightUnitTests.App + TestPage.html + true + true + false + Properties\OutOfBrowserSettings.xml + false + true + + + + + + + v3.5 + + + true + full + false + Bin\Debug + DEBUG;TRACE;SILVERLIGHT + true + true + prompt + 4 + + + pdbonly + true + Bin\Release + TRACE;SILVERLIGHT + true + true + prompt + 4 + + + + ..\..\..\out\debug\SL4\MathNet.Numerics.dll + + + $(MSBuildExtensionsPath)\..\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Testing\Microsoft.Silverlight.Testing.dll + + + $(MSBuildExtensionsPath)\..\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Testing\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll + + + + + + + + + + + + + AssertHelpers.cs + + + LinearAlgebraProviderTests\Double\LinearAlgebraProviderTests.cs + + + App.xaml + + + + + + Designer + MSBuild:Compile + + + + + + + + + + + + + + + + \ No newline at end of file