public void DivisibleBy_ZeroDivisor_ThrowsDivideByExpection(double numbersInTest, double divisor) { IMathFunctions iMathFunctions = CreateDefaultMathFunctions(); var ex = Assert.Throws <DivideByZeroException>(() => iMathFunctions.DivisibleBy(numbersInTest, divisor)); Equals(ex.Message.Contains("Divisor cannot be Zero")); }
public void DivisibleBy_SingleDivisibleNumbersBy5_ReturnFalse(double numbersInTest, double divisor, bool expected) { IMathFunctions iMathFunctions = CreateDefaultMathFunctions(); var actual = iMathFunctions.DivisibleBy(numbersInTest, divisor); Assert.False(actual); }
static void Main(string[] args) { // The code provided will print ‘Hello World’ to the console. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app. iMathFunctions = new MathFunctions(); iPrintFunctions = new PrintFunctions(); PrintHelloAndWorld(); Console.ReadKey(); // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! }
public static bool CanSee(this IUnit unit, ICoordinates targetCoords, IMathFunctions math) { int visionRange = unit.GetVisionRange(); if (unit.Location.DistanceTo(targetCoords) > visionRange) { return(false); } var lineOfSight = unit.GetLineTo(targetCoords, math).Take(visionRange); return(unit.CanSee(lineOfSight)); }
/// <summary> /// 初始化数据库适配器 /// </summary> private void InitAdapters() { IAdapterLoader loader = GetLoader(DbType); if (loader == null) { throw new Exception("不支持数据库类型:" + DbType); } _curAggregateFunctions = loader.AggregateFunctions; _curCommonFunctions = loader.CommonFunctions; _curConvertFunctions = loader.ConvertFunctions; _curDbAdapter = loader.DbAdapter; _curDBStructure = loader.DBStructure; _curMathFunctions = loader.MathFunctions; }
// Constructor public Engine(ConsoleWindow console, WindowsManager windowsManager, ILogger logger, CombatManager combatManager, KeyHandler keyHandler, Visualization visualization, Movement movement, SelectablePopUpWindow inventoryWindow, Random randomProvider, IMathFunctions math ) { this.console = console; this.windowsManager = windowsManager; this.logger = logger; this.combatManager = combatManager; this.visualization = visualization; this.keyHandler = keyHandler; this.inventoryWindow = inventoryWindow; this.movement = movement; this.randomProvider = randomProvider; this.math = math; }
public static ICollection <ICoordinates> GetLineTo(this IUnit unit, ICoordinates targetCoords, IMathFunctions math) { var rayTracingPath = math.LineAlgorithm(unit.Location.CordY, unit.Location.CordX, targetCoords.CordY, targetCoords.CordX); //makes sure we start from the players location if (rayTracingPath[0].CordX != unit.Location.CordX || rayTracingPath[0].CordY != unit.Location.CordY) { rayTracingPath.Reverse(); } return(rayTracingPath.Skip(1).ToArray()); }
public MathOperation(IMathFunctions mathFunctions) { this._mathFunctions = mathFunctions; }
public Visualization(IMathFunctions math) { this.math = math; Initialise(); }
public static void UpdatePath(this IEnemy enemyUnit, ICoordinates targetCoords, IMathFunctions math) { int visionRange = enemyUnit.GetVisionRange(); var lineOfSight = enemyUnit.GetLineTo(targetCoords, math).Take(visionRange); if (enemyUnit.CanSee(lineOfSight)) { enemyUnit.UpdatePath(lineOfSight.ToArray()); } }