Here are the examples of the csharp api class NUnit.Framework.Assert.AreEqual(double, double, double, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
62 Examples
0
1. Example
View license[Test] public void TestNpv() { double r, npv, x; double[] v; r = 1; v = new double[] { 100, 200, 300, 400 }; npv = FinanceLib.npv(r, v); x = 162.5; Assert.AreEqual(x, npv, 0.000001, "npv "); r = 2.5; v = new double[] { 1000, 666.66666, 333.33, 12.2768416 }; npv = FinanceLib.npv(r, v); x = 347.99232604144827; Assert.AreEqual(x, npv, 0.000001, "npv "); r = 12.33333; v = new double[] { 1000, 0, -900, -7777.5765 }; npv = FinanceLib.npv(r, v); x = 74.3742433377061; Assert.AreEqual(x, npv, 0.000001, "npv "); r = 0.05; v = new double[] { 200000, 300000.55, 400000, 1000000, 6000000, 7000000, -300000 }; npv = FinanceLib.npv(r, v); x = 11342283.4233124; Assert.AreEqual(x, npv, 0.0000001, "npv "); }
0
2. Example
View license[Test] public void TestMirrBasic() { Mirr mirr = new Mirr(); /n ..... /n //View Source file for more details /n }
0
3. Example
View license[Test] public void TestVar() { double[] v = null; double d, x = 0; v = new double[] { 3.50, 5.00, 7.23, 2.99 }; d = StatsLib.var(v); x = 3.6178; //the following AreEqual add a delta param against java version, otherwise tests fail. Assert.AreEqual( x, d, 0.00001,"var "); v = new double[] { 34.5, 2.0, 8.9, -4.0 }; d = StatsLib.var(v); x = 286.99; Assert.AreEqual( x, d,0.001,"var "); v = new double[] { 7.0, 25.0, 21.69 }; d = StatsLib.var(v); x = 91.79203333; Assert.AreEqual( x, d,0.00000001,"var "); v = new double[] { 1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299 }; d = StatsLib.var(v); x = 754.2666667; Assert.AreEqual( x, d, 0.0000001,"var "); }
0
4. Example
View license[Test] public void TestVarp() { double[] v = null; double d, x = 0; v = new double[] { 3.50, 5.00, 7.23, 2.99 }; d = StatsLib.varp(v); x = 2.71335; Assert.AreEqual( x, d, 0.000001, "varp "); v = new double[] { 34.5, 2.0, 8.9, -4.0 }; d = StatsLib.varp(v); x = 215.2425; Assert.AreEqual( x, d,0.00001,"varp "); v = new double[] { 7.0, 25.0, 21.69 }; d = StatsLib.varp(v); x = 61.19468889; Assert.AreEqual( x, d, 0.00000001, "varp "); v = new double[] { 1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299 }; d = StatsLib.varp(v); x = 678.84; Assert.AreEqual( x, d, 0.001,"varp "); }
0
5. Example
View licensestatic public void AssertEquals(string message, double expected, double actual, double delta) { NUnit.Framework.Assert.AreEqual(expected, actual, delta, message); }
0
6. Example
View licensestatic public void AssertEquals(string message, float expected, float actual, float delta) { NUnit.Framework.Assert.AreEqual(expected, actual, delta, message); }
0
7. Example
View licensestatic public void AssertEquals(string message, double expected, double actual, double delta) { NUnit.Framework.Assert.AreEqual(expected, actual, delta, message); }
0
8. Example
View licensestatic public void AssertEquals(string message, float expected, float actual, float delta) { NUnit.Framework.Assert.AreEqual(expected, actual, delta, message); }
0
9. Example
View licenseinternal static void ShouldEqualWithTolerance(this float actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
10. Example
View licenseinternal static void ShouldEqualWithTolerance(this long actualValue, long expectedValue, int tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
11. Example
View licenseinternal static void ShouldEqualWithTolerance(this double actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
12. Example
View licenseinternal static void ShouldEqualWithTolerance(this int actualValue, int expectedValue, int tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
13. Example
View licenseinternal static void ShouldEqualWithTolerance(this float actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
14. Example
View licenseinternal static void ShouldEqualWithTolerance(this long actualValue, long expectedValue, int tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
15. Example
View licenseinternal static void ShouldEqualWithTolerance(this double actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
16. Example
View licenseinternal static void ShouldEqualWithTolerance(this decimal actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, (double)actualValue, tolerance, errorMessage); }
0
17. Example
View licenseinternal static void ShouldEqualWithTolerance(this int actualValue, int expectedValue, int tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
18. Example
View licenseinternal static void ShouldEqualWithTolerance(this float actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
19. Example
View licenseinternal static void ShouldEqualWithTolerance(this long actualValue, long expectedValue, int tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
20. Example
View licenseinternal static void ShouldEqualWithTolerance(this double actualValue, double expectedValue, double tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
21. Example
View licenseinternal static void ShouldEqualWithTolerance(this int actualValue, int expectedValue, int tolerance, string errorMessage = null) { Assert.AreEqual(expectedValue, actualValue, tolerance, errorMessage); }
0
22. Example
View license[Test(Description = "Assert that processing dependencies doesn't fail if there are no mods installed.")] public void ProcessDependencies_NoMods_DoesNothing() { // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new IModMetadata[0]).ToArray(); // assert Assert.AreEqual(0, mods.Length, 0, "Expected to get an empty list of mods."); }
0
23. Example
View license[Test] public void TestFv() { double f, r, y, p, x; int n; bool t = false; r = 0; n = 3; y = 2; p = 7; t = true; f = FinanceLib.fv(r, n, y, p, t); x = -13; Assert.AreEqual(x, f, "fv "); r = 1; n = 10; y = 100; p = 10000; t = false; f = FinanceLib.fv(r, n, y, p, t); x = -10342300; Assert.AreEqual(x, f, "fv "); r = 1; n = 10; y = 100; p = 10000; t = true; f = FinanceLib.fv(r, n, y, p, t); x = -10444600; Assert.AreEqual(x, f, "fv "); r = 2; n = 12; y = 120; p = 12000; t = false; f = FinanceLib.fv(r, n, y, p, t); x = -6409178400d; Assert.AreEqual(x, f, "fv "); r = 2; n = 12; y = 120; p = 12000; t = true; f = FinanceLib.fv(r, n, y, p, t); x = -6472951200d; Assert.AreEqual(x, f, "fv "); // cross Tests with pv r = 2.95; n = 13; y = 13000; p = -4406.78544294496; t = false; f = FinanceLib.fv(r, n, y, p, t); x = 333891.230010986; // as returned by excel Assert.AreEqual(x, f, 0.01, "fv "); r = 2.95; n = 13; y = 13000; p = -17406.7852148156; t = true; f = FinanceLib.fv(r, n, y, p, t); x = 333891.230102539; // as returned by excel Assert.AreEqual(x, f, 0.01, "fv "); }
0
24. Example
View license[Test] public void TestPv() { double f, r, y, p, x; int n; bool t = false; r = 0; n = 3; y = 2; f = 7; t = true; f = FinanceLib.pv(r, n, y, f, t); x = -13; Assert.AreEqual(x, f, "pv "); r = 1; n = 10; y = 100; f = 10000; t = false; p = FinanceLib.pv(r, n, y, f, t); x = -109.66796875; Assert.AreEqual(x, p, "pv "); r = 1; n = 10; y = 100; f = 10000; t = true; p = FinanceLib.pv(r, n, y, f, t); x = -209.5703125; Assert.AreEqual(x, p, "pv "); r = 2.95; n = 13; y = 13000; f = 333891.23; t = false; p = FinanceLib.pv(r, n, y, f, t); x = -4406.78544294496; Assert.AreEqual(x, p, 0.0000001, "pv "); r = 2.95; n = 13; y = 13000; f = 333891.23; t = true; p = FinanceLib.pv(r, n, y, f, t); x = -17406.7852148156; Assert.AreEqual(x, p, 0.0000001, "pv "); // cross Tests with fv r = 2; n = 12; y = 120; f = -6409178400d; t = false; p = FinanceLib.pv(r, n, y, f, t); x = 12000; Assert.AreEqual(x, p, "pv "); r = 2; n = 12; y = 120; f = -6472951200d; t = true; p = FinanceLib.pv(r, n, y, f, t); x = 12000; Assert.AreEqual(x, p, "pv "); }
0
25. Example
View license[Test] public void TestNper() { double f, r, y, p, x, n; bool t = false; r = 0; y = 7; p = 2; f = 3; t = false; n = FinanceLib.nper(r, y, p, f, t); x = -0.71428571429; // can you believe it? excel returns nper as a fraction!?? Assert.AreEqual(x, n, 0.0000000001, "nper "); // cross check with pv r = 1; y = 100; p = -109.66796875; f = 10000; t = false; n = FinanceLib.nper(r, y, p, f, t); x = 10; Assert.AreEqual(x, n, 0.01, "nper "); r = 1; y = 100; p = -209.5703125; f = 10000; t = true; n = FinanceLib.nper(r, y, p, f, t); x = 10; Assert.AreEqual(x, n, 0.1, "nper "); // cross check with fv r = 2; y = 120; f = -6409178400d; p = 12000; t = false; n = FinanceLib.nper(r, y, p, f, t); x = 12; Assert.AreEqual(x, n, "nper "); r = 2; y = 120; f = -6472951200d; p = 12000; t = true; n = FinanceLib.nper(r, y, p, f, t); x = 12; Assert.AreEqual(x, n, "nper "); }
0
26. Example
View license[Test] public void TestDevsq() { double[] v = null; double d, x = 0; v = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; d = StatsLib.devsq(v); x = 82.5; Assert.AreEqual( x, d,"devsq "); v = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; d = StatsLib.devsq(v); x = 0; Assert.AreEqual( x, d,"devsq "); v = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; d = StatsLib.devsq(v); x = 0; Assert.AreEqual( x, d,"devsq "); v = new double[] { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }; d = StatsLib.devsq(v); x = 2.5; Assert.AreEqual( x, d,"devsq "); v = new double[] { 123.12, 33.3333, 2d / 3d, 5.37828, 0.999 }; d = StatsLib.devsq(v); x = 10953.7416965767; Assert.AreEqual( x, d, 0.0000000001, "devsq "); v = new double[] { -1, -2, -3, -4, -5, -6, -7, -8, -9, -10 }; d = StatsLib.devsq(v); x = 82.5; Assert.AreEqual( x, d,"devsq "); }
0
27. Example
View license[Test] public void TestAvedev() { double[] v = null; double d, x = 0; v = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; d = StatsLib.avedev(v); x = 2.5; Assert.AreEqual( x, d,"avedev "); v = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; d = StatsLib.avedev(v); x = 0; Assert.AreEqual( x, d,"avedev "); v = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; d = StatsLib.avedev(v); x = 0; Assert.AreEqual( x, d,"avedev "); v = new double[] { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }; d = StatsLib.avedev(v); x = 0.5; Assert.AreEqual( x, d,"avedev "); v = new double[] { 123.12, 33.3333, 2d / 3d, 5.37828, 0.999 }; d = StatsLib.avedev(v); x = 36.42176053333; Assert.AreEqual( x, d,0.00000000001,"avedev "); v = new double[] { -1, -2, -3, -4, -5, -6, -7, -8, -9, -10 }; d = StatsLib.avedev(v); x = 2.5; Assert.AreEqual( x, d,"avedev "); }
0
28. Example
View license[Test] public void TestStddev() { double[] v = null; double d, x = 0; v = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; d = StatsLib.stdev(v); x = 3.02765035409749; Assert.AreEqual( x, d,0.0000000001, "stdev "); v = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; d = StatsLib.stdev(v); x = 0; Assert.AreEqual( x, d,"stdev "); v = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; d = StatsLib.stdev(v); x = 0; Assert.AreEqual( x, d,"stdev "); v = new double[] { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }; d = StatsLib.stdev(v); x = 0.52704627669; Assert.AreEqual( x, d,0.000000001,"stdev "); v = new double[] { 123.12, 33.3333, 2d / 3d, 5.37828, 0.999 }; d = StatsLib.stdev(v); x = 52.33006233652; Assert.AreEqual( x, d,0.0000000001,"stdev "); v = new double[] { -1, -2, -3, -4, -5, -6, -7, -8, -9, -10 }; d = StatsLib.stdev(v); x = 3.02765035410; Assert.AreEqual( x, d,0.0000000001,"stdev "); }
0
29. Example
View licensepublic void BaseTestResize(IPicture input, IPicture Compare, double scaleX, double scaleY) { input.Resize(scaleX, scaleY); IClientAnchor inpCA = input.ClientAnchor; IClientAnchor cmpCA = Compare.ClientAnchor; Size inpDim = ImageUtils.GetDimensionFromAnchor(input); Size cmpDim = ImageUtils.GetDimensionFromAnchor(Compare); double emuPX = Units.EMU_PER_PIXEL; Assert.AreEqual(inpDim.Height, cmpDim.Height, emuPX * 6, "the image height differs"); Assert.AreEqual(inpDim.Width, cmpDim.Width, emuPX * 6, "the image width differs"); Assert.AreEqual(inpCA.Col1, cmpCA.Col1, "the starting column differs"); Assert.AreEqual(inpCA.Dx1, cmpCA.Dx1, 1, "the column x-offset differs"); Assert.AreEqual(inpCA.Dy1, cmpCA.Dy1, 1, "the column y-offset differs"); Assert.AreEqual(inpCA.Col2, cmpCA.Col2, "the ending columns differs"); // can't compare row heights because of variable test heights input.Resize(); inpDim = ImageUtils.GetDimensionFromAnchor(input); Size imgDim = input.GetImageDimension(); Assert.AreEqual(imgDim.Height, inpDim.Height / emuPX, 1, "the image height differs"); Assert.AreEqual(imgDim.Width, inpDim.Width / emuPX, 1, "the image width differs"); }
0
30. Example
View license[Test] public void CanCreateComplexNumberWithModulusArgument() { var complex = Complex32.FromPolarCoordinates(2, (float)-Math.PI / 6); Assert.AreEqual((float)Constants.Sqrt3, complex.Real, 1e-7f, "Real part is Sqrt(3)."); Assert.AreEqual(-1.0f, complex.Imaginary, 1e-7f, "Imaginary part is -1."); }
0
31. Example
View license[Test] public void TrapeziumRuleSupportsTwoPointIntegration() { Assert.AreEqual( TargetAreaA, NewtonCotesTrapeziumRule.IntegrateTwoPoint(TargetFunctionA, StartA, StopA), 0.4 * TargetAreaA, "Direct (1 Partition)"); }
0
32. Example
View license[Test] public void SimpsonRuleSupportsThreePointIntegration() { Assert.AreEqual( TargetAreaA, SimpsonRule.IntegrateThreePoint(TargetFunctionA, StartA, StopA), 0.2 * TargetAreaA, "Direct (2 Partitions)"); }
0
33. Example
View license[Test] public void TestIntegrateFacade() { Assert.AreEqual( TargetAreaA, Integrate.OnClosedInterval(TargetFunctionA, StartA, StopA), 1e-5, "Interval"); Assert.AreEqual( TargetAreaA, Integrate.OnClosedInterval(TargetFunctionA, StartA, StopA, 1e-10), 1e-10, "Interval, Target 1e-10"); Assert.AreEqual( Integrate.OnRectangle(TargetFunctionB, StartA, StopA, StartB, StopB), TargetAreaB, 1e-12, "Rectangle"); Assert.AreEqual( Integrate.OnRectangle(TargetFunctionB, StartA, StopA, StartB, StopB, 22), TargetAreaB, 1e-10, "Rectangle, Gauss-Legendre Order 22"); }
0
34. Example
View license[Test(Description = "Assert that processing dependencies doesn't change the order if there are no mod dependencies.")] public void ProcessDependencies_NoDependencies_DoesNothing() { // arrange // A B C Mock<IModMetadata> modA = this.GetMetadata("Mod A"); Mock<IModMetadata> modB = this.GetMetadata("Mod B"); Mock<IModMetadata> modC = this.GetMetadata("Mod C"); // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modA.Object, modB.Object, modC.Object }).ToArray(); // assert Assert.AreEqual(3, mods.Length, 0, "Expected to get the same number of mods input."); Assert.AreSame(modA.Object, mods[0], "The load order unexpectedly changed with no dependencies."); Assert.AreSame(modB.Object, mods[1], "The load order unexpectedly changed with no dependencies."); Assert.AreSame(modC.Object, mods[2], "The load order unexpectedly changed with no dependencies."); }
0
35. Example
View licenseprivate static void CompareLgb(LinearGradientBrush brushS, LinearGradientBrush brushD) { /n ..... /n //View Source file for more details /n }
0
36. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
37. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
38. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
39. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
40. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
41. Example
View license[Test] public void TestMimeMessageWithHeaders () { var msg = new MimeMessage ( new Header ("From", "Federico Di Gregorio <[email protected]>"), new Header ("To", "[email protected]"), new [] { new Header ("Cc", "[email protected]"), new Header ("Cc", "<[email protected]>") }, new Header ("Subject", "Hello"), new TextPart ("plain", "Just a short message to say hello!") ); Assert.AreEqual (1, msg.From.Count, "Wrong count in From"); Assert.AreEqual ("\"Federico Di Gregorio\" <[email protected]>", msg.From[0].ToString(), "Wrong value in From[0]"); Assert.AreEqual (1, msg.To.Count, "Wrong count in To"); Assert.AreEqual ("[email protected]", msg.To[0].ToString(), "Wrong value in To[0]"); Assert.AreEqual (2, msg.Cc.Count, 2, "Wrong count in Cc"); Assert.AreEqual ("[email protected]", msg.Cc[0].ToString(), "Wrong value in Cc[0]"); Assert.AreEqual ("[email protected]", msg.Cc[1].ToString(), "Wrong value in Cc[1]"); Assert.AreEqual ("Hello", msg.Subject, "Wrong value in Subject"); }
0
42. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
43. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }
0
44. Example
View license[Test(Description = "Assert that simple dependencies are reordered correctly.")] public void ProcessDependencies_Reorders_SimpleDependencies() { // arrange // A ??? B // ? ? // ? ? // ?? C ?? Mock<IModMetadata> modA = this.GetMetadata("Mod A"); Mock<IModMetadata> modB = this.GetMetadata("Mod B", dependencies: new[] { "Mod A" }); Mock<IModMetadata> modC = this.GetMetadata("Mod C", dependencies: new[] { "Mod A", "Mod B" }); // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modC.Object, modA.Object, modB.Object }).ToArray(); // assert Assert.AreEqual(3, mods.Length, 0, "Expected to get the same number of mods input."); Assert.AreSame(modA.Object, mods[0], "The load order is incorrect: mod A should be first since the other mods depend on it."); Assert.AreSame(modB.Object, mods[1], "The load order is incorrect: mod B should be second since it needs mod A, and is needed by mod C."); Assert.AreSame(modC.Object, mods[2], "The load order is incorrect: mod C should be third since it needs both mod A and mod B."); }
0
45. Example
View license[Test(Description = "Assert that simple dependency chains are reordered correctly.")] public void ProcessDependencies_Reorders_DependencyChain() { // arrange // A ??? B ??? C ??? D Mock<IModMetadata> modA = this.GetMetadata("Mod A"); Mock<IModMetadata> modB = this.GetMetadata("Mod B", dependencies: new[] { "Mod A" }); Mock<IModMetadata> modC = this.GetMetadata("Mod C", dependencies: new[] { "Mod B" }); Mock<IModMetadata> modD = this.GetMetadata("Mod D", dependencies: new[] { "Mod C" }); // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modC.Object, modA.Object, modB.Object, modD.Object }).ToArray(); // assert Assert.AreEqual(4, mods.Length, 0, "Expected to get the same number of mods input."); Assert.AreSame(modA.Object, mods[0], "The load order is incorrect: mod A should be first since it's needed by mod B."); Assert.AreSame(modB.Object, mods[1], "The load order is incorrect: mod B should be second since it needs mod A, and is needed by mod C."); Assert.AreSame(modC.Object, mods[2], "The load order is incorrect: mod C should be third since it needs mod B, and is needed by mod D."); Assert.AreSame(modD.Object, mods[3], "The load order is incorrect: mod D should be fourth since it needs mod C."); }
0
46. Example
View license[Test(Description = "Assert that overlapping dependency chains are reordered correctly.")] p/n ..... /n //View Source file for more details /n }
0
47. Example
View license[Test(Description = "Assert that dependencies are accepted if they meet the minimum version.")] public void ProcessDependencies_WithMinVersions_SucceedsIfMet() { // arrange // A 1.0 ??? B (need A 1.0-beta) Mock<IModMetadata> modA = this.GetMetadata(this.GetManifest("Mod A", "1.0")); Mock<IModMetadata> modB = this.GetMetadata(this.GetManifest("Mod B", "1.0", new ManifestDependency("Mod A", "1.0-beta")), allowStatusChange: false); // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modA.Object, modB.Object }).ToArray(); // assert Assert.AreEqual(2, mods.Length, 0, "Expected to get the same number of mods input."); Assert.AreSame(modA.Object, mods[0], "The load order is incorrect: mod A should be first since it's needed by mod B."); Assert.AreSame(modB.Object, mods[1], "The load order is incorrect: mod B should be second since it needs mod A."); }
0
48. Example
View license[Test(Description = "Assert that optional dependencies are sorted correctly if present.")] public void ProcessDependencies_IfOptional() { // arrange // A ??? B Mock<IModMetadata> modA = this.GetMetadata(this.GetManifest("Mod A", "1.0")); Mock<IModMetadata> modB = this.GetMetadata(this.GetManifest("Mod B", "1.0", new ManifestDependency("Mod A", "1.0", required: false)), allowStatusChange: false); // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modB.Object, modA.Object }).ToArray(); // assert Assert.AreEqual(2, mods.Length, 0, "Expected to get the same number of mods input."); Assert.AreSame(modA.Object, mods[0], "The load order is incorrect: mod A should be first since it's needed by mod B."); Assert.AreSame(modB.Object, mods[1], "The load order is incorrect: mod B should be second since it needs mod A."); }
0
49. Example
View license[Test(Description = "Assert that optional dependencies are accepted if they're missing.")] public void ProcessDependencies_IfOptional_SucceedsIfMissing() { // arrange // A ??? B where A doesn't exist Mock<IModMetadata> modB = this.GetMetadata(this.GetManifest("Mod B", "1.0", new ManifestDependency("Mod A", "1.0", required: false)), allowStatusChange: false); // act IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modB.Object }).ToArray(); // assert Assert.AreEqual(1, mods.Length, 0, "Expected to get the same number of mods input."); Assert.AreSame(modB.Object, mods[0], "The load order is incorrect: mod B should be first since it's the only mod."); }
0
50. Example
View license[Test] public void Equals() { Assert.AreEqual(12, 12, "Integer"); Assert.AreEqual(12L, 12L, "Long"); Assert.AreEqual('a', 'a', "Char"); Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); Assert.AreEqual(12, 13, "Expected Failure (Integer)"); Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); }