public void test_should_raise_exception_if_all_bounds_are_not_calculated() { IBondPricer local = new NodePricer(); IBondPricer grid = new GridPricer(); BondPricer.BondPricer calculator = new BondPricer.BondPricer(local, grid); var bonds = GenerateBonds(4, 2, 6); Assert.ThrowsException <Exception>(() => bonds[0].Price()); }
public void test_optimal_for_simple_instance3() { IBondPricer local = new NodePricer(); IBondPricer grid = new GridPricer(); BondPricer.BondPricer calculator = new BondPricer.BondPricer(local, grid); var bonds = GenerateBonds(1, 1, 0); var result = strategy(bonds, calculator); Assert.AreEqual(7, calculator.ComputingTime); }
public void test_optimal_for_simple_instance() { IBondPricer local = new NodePricer(); IBondPricer grid = new GridPricer(); BondPricer.BondPricer calculator = new BondPricer.BondPricer(local, grid); var bonds = new List <Bond> { new Bond(BondType.SemiFast), new Bond(BondType.Long), new Bond(BondType.Fast) }; var result = strategy(bonds, calculator); Assert.AreEqual(13, calculator.ComputingTime); }
public void test_grid_should_not_waste_node() { IBondPricer local = new NodePricer(); IBondPricer grid = new GridPricer(); BondPricer.BondPricer calculator = new BondPricer.BondPricer(local, grid); var bonds = GenerateBonds(1, 1, 2); strategy(bonds, calculator); GridPricer castedGrid = (GridPricer)grid; Assert.AreEqual(2, castedGrid.NumberOfNodes()); }
public void test_must_calculate_all_bonds() { IBondPricer local = new NodePricer(); IBondPricer grid = new GridPricer(); BondPricer.BondPricer calculator = new BondPricer.BondPricer(local, grid); var bonds = GenerateBonds(4, 2, 6); var result = strategy(bonds, calculator); foreach (var bond in bonds) { Assert.AreEqual(bond.Price(), 42); } }
public void test_should_take_less_than_18_seconds() { for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { for (int z = 0; z < 20; z++) { IBondPricer local = new NodePricer(); IBondPricer grid = new GridPricer(); BondPricer.BondPricer calculator = new BondPricer.BondPricer(local, grid); var bonds = GenerateBonds(4, 2, 0); var result = strategy(bonds, calculator); Assert.AreEqual(10, calculator.ComputingTime); } } } }
public void test_simulated_computed_time_should_be_equal_real_time() { BondPricer.BondPricer simulatedCalculator = new BondPricer.BondPricer(new NodePricer(), new GridPricer()); BondPricer.BondPricer realTimeCalculator = new BondPricer.BondPricer(new NodePricer() { Simulated = false }, new GridPricer() { Simulated = false }); realTimeCalculator.Simulation = false; var bonds = GenerateBonds(4, 2, 6); strategy(bonds, simulatedCalculator); strategy(bonds, realTimeCalculator); Func <int, int, bool> almostEqual = (x, y) => Math.Abs(x - y) < 0.001; Assert.IsTrue(almostEqual(simulatedCalculator.ComputingTime, realTimeCalculator.ComputingTime)); }