Пример #1
0
        public void ToTitleLower()
        {
            //arrange
            string lowerResult = RandomMethods.ToTitle("hello how are you");

            //act
            //assert
            Assert.AreEqual("Hello How Are You", lowerResult, "not correct");
        }
Пример #2
0
 public void VerifyEnemyPresence()
 {
     if (EnemiesInRange())
     {
         if (RandomMethods.PercentageChance(25f))
         {
             NotificationFactory.Instance.CreateNotificationEnemyDetected(controller.gameObject, controller.gameObject, GetSecondNearestEnemy());
         }
         else
         {
             NotificationFactory.Instance.CreateNotificationEnemyDetected(controller.gameObject, controller.gameObject, GetNearestEnemy());
         }
     }
     else
     {
         NotificationFactory.Instance.CreateNotificationNoTarget(controller.gameObject, controller.gameObject);
     }
 }
Пример #3
0
        public void GetSeed()
        {
            var local      = new Stack <ForthDatum>();
            var parameters = new ForthPrimativeParameters(null, local, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var result     = RandomMethods.GetSeed(parameters);

            Assert.NotNull(result);
            Assert.IsTrue(result.IsSuccessful, result.Reason);

            Assert.AreEqual(1, local.Count);

            var seed = local.Pop();

            Assert.AreEqual(ForthDatum.DatumType.String, seed.Type);
            Assert.NotNull(seed.Value);

            Assert.AreEqual(0, local.Count);
        }
Пример #4
0
        public void GenerateSeededRandomNumber()
        {
            var local      = new Stack <ForthDatum>();
            var parameters = new ForthPrimativeParameters(null, local, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var result     = RandomMethods.SRand(parameters);

            Assert.NotNull(result);
            Assert.IsTrue(result.IsSuccessful, result.Reason);

            Assert.AreEqual(1, local.Count);

            var n = local.Pop();

            Assert.AreEqual(ForthDatum.DatumType.Integer, n.Type);
            Assert.Greater(n.UnwrapInt(), 0);

            Assert.AreEqual(0, local.Count);
        }
Пример #5
0
        public void SetSeed()
        {
            var localSetSeed1      = new Stack <ForthDatum>(new[] { new ForthDatum("unit-test-seed") });
            var setSeed1Parameters = new ForthPrimativeParameters(null, localSetSeed1, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var setSeed1Result     = RandomMethods.SetSeed(setSeed1Parameters);

            var getRandom1Stack      = new Stack <ForthDatum>();
            var getRandom1Parameters = new ForthPrimativeParameters(null, getRandom1Stack, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var getRandom1           = RandomMethods.SRand(getRandom1Parameters);
            var getRandom1Value      = getRandom1Stack.Pop().UnwrapInt();

            var localGetSeed      = new Stack <ForthDatum>();
            var getSeedParameters = new ForthPrimativeParameters(null, localGetSeed, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var getSeed           = RandomMethods.GetSeed(getSeedParameters);
            var getSeedValue      = localGetSeed.Pop();

            Assert.AreEqual("unit-test-seed", getSeedValue.Value);

            var localSetSeed2      = new Stack <ForthDatum>(new[] { new ForthDatum("unit-test-seed") });
            var setSeed2Parameters = new ForthPrimativeParameters(null, localSetSeed2, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var setSeed2Result     = RandomMethods.SetSeed(setSeed2Parameters);

            var getRandom2Stack      = new Stack <ForthDatum>();
            var getRandom2Parameters = new ForthPrimativeParameters(null, getRandom2Stack, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var getRandom2           = RandomMethods.SRand(getRandom2Parameters);
            var getRandom2Value      = getRandom2Stack.Pop().UnwrapInt();

            Assert.AreEqual(getRandom1Value, getRandom2Value, "When setting the same seed, the same random numbers should be returned.");

            var getRandom3Stack      = new Stack <ForthDatum>();
            var getRandom3Parameters = new ForthPrimativeParameters(null, getRandom3Stack, null, Dbref.NOT_FOUND, Dbref.NOT_FOUND, Dbref.NOT_FOUND, null, null, null, null, default);
            var getRandom3           = RandomMethods.SRand(getRandom3Parameters);

            Assert.NotNull(getRandom3);
            Assert.IsTrue(getRandom3.IsSuccessful);

            var getRandom3Value = getRandom3Stack.Pop().UnwrapInt();

            Assert.AreNotEqual(getRandom2Value, getRandom3Value, "Subsequent random numbers should not be the same");
        }
Пример #6
0
        public void getRatio913to88()
        {
            double convert1UnitFromNineByThirteenToightByEight = RandomMethods.getRatio(1, RandomMethods.getSq(9, 13), RandomMethods.getSq(8, 8));

            Assert.AreEqual(0.5470, convert1UnitFromNineByThirteenToightByEight, "not working");
        }
Пример #7
0
        public void getRatio88to913()
        {
            double convert1UnitFromEightByEightToNineByThirteen = RandomMethods.getRatio(1, RandomMethods.getSq(8, 8), RandomMethods.getSq(9, 13));

            Assert.AreEqual(1.8281, convert1UnitFromEightByEightToNineByThirteen, "not working");
        }
Пример #8
0
        public void getSq()
        {
            double geteightByEight = RandomMethods.getSq(8, 8);

            Assert.AreEqual(64, geteightByEight, $"should equal 64 but equals {geteightByEight}");
        }
Пример #9
0
        public void ToTitleUpper()
        {
            string upperresult = RandomMethods.ToTitle("HELLO HOW ARE YOU");

            Assert.AreEqual("Hello How Are You", upperresult, "upper case doesn't convert properly");
        }
Пример #10
0
        public bool submitIngredient(Ingredient ingredient)
        {
            string connString = @"Data Source=database-1.cur7afppexfe.us-east-2.rds.amazonaws.com,1433; Initial Catalog=RecipeManager;User ID=admin;Password=Whatthe770!";

/*            {ingredient.IngredientName.Substring(0, 1).ToUpper()}{ingredient.IngredientName.Substring(1).ToLower()}
 */         using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand command = new SqlCommand($"insert into Ingredients(IngredientName) VALUES ('{RandomMethods.ToTitle(ingredient.IngredientName)}')", conn);

                conn.Open();
                foreach (Ingredient ing in getIngredients())
                {
                    if (ing.IngredientName.ToLower().Equals(ingredient.IngredientName.ToLower()))
                    {
                        return(false);
                    }
                }
                command.ExecuteNonQuery();
            }
            return(true);
        }
Пример #11
0
 public Card(CardRank rank)
 {
     Rank = rank;
     Suit = RandomMethods.RandomEnumValue <CardSuit>();
 }