コード例 #1
0
        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"));
        }
コード例 #2
0
        public void DivisibleBy_SingleDivisibleNumbersBy5_ReturnFalse(double numbersInTest, double divisor, bool expected)
        {
            IMathFunctions iMathFunctions = CreateDefaultMathFunctions();
            var            actual         = iMathFunctions.DivisibleBy(numbersInTest, divisor);

            Assert.False(actual);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ManbirSinghRakhra/Skedulo
        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!
        }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: DBInfo.cs プロジェクト: radtek/buffalobro
        /// <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;
        }
コード例 #6
0
 // 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;
 }
コード例 #7
0
        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());
        }
コード例 #8
0
 public MathOperation(IMathFunctions mathFunctions)
 {
     this._mathFunctions = mathFunctions;
 }
コード例 #9
0
 public Visualization(IMathFunctions math)
 {
     this.math = math;
     Initialise();
 }
コード例 #10
0
        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());
            }
        }