Ejemplo n.º 1
0
        private static RandomCharacter GetCharacter()
        {
            RandomCharacter res = RandomCharacter.Letter;
            int             rnd = GetRandom(0, 3);

            switch (rnd)
            {
            case 0:
                res = RandomCharacter.Letter;
                break;

            case 1:
                res = RandomCharacter.Capital;
                break;

            case 2:
                res = RandomCharacter.Number;
                break;

            case 3:
                res = RandomCharacter.Special;
                break;

            default:
                res = RandomCharacter.Letter;
                break;
            }

            return(res);
        }
Ejemplo n.º 2
0
        public void RandomFirstNameIsNotNull()
        {
            // Arrange
            RandomCharacter testCharacter = new RandomCharacter();

            // Act
            testCharacter.SetRandomName(testCharacter.GetGender(), testCharacter.GetRace().GetName());
            // Assert
            Assert.NotNull(testCharacter.GetFirstName());
        }
Ejemplo n.º 3
0
        public void GenderIsNotNull()
        {
            // Arrange
            RandomCharacter testCharacter = new RandomCharacter();

            // Act
            testCharacter.SetRandomGender();
            // Assert
            Assert.NotNull(testCharacter.GetGender());
        }
Ejemplo n.º 4
0
        public void RaceIsNotNull()
        {
            // Arrange
            RandomCharacter testCharacter = new RandomCharacter();

            // Act
            testCharacter.SetRandomRace();
            // Assert
            Assert.NotNull(testCharacter.GetRace());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the password.
        /// </summary>
        /// <param name="length">The length.</param>
        /// <param name="isLowercaseIncluded">if set to <c>true</c> [is lowercase included].</param>
        /// <param name="isNumbersIncluded">if set to <c>true</c> [is numbers included].</param>
        /// <param name="isUppercaseIncluded">if set to <c>true</c> [is uppercase included].</param>
        /// <returns>System.String.</returns>
        public static string generatePassword(int length, bool isLowercaseIncluded, bool isNumbersIncluded, bool isUppercaseIncluded)
        {
            bool isOthersIncluded = false;

            string password = "";

            RandomCharacter[] r = new RandomCharacter[4];

            // keep track of how many array locations we're actually using
            int count = 0;

            if (isLowercaseIncluded)
            {
                // using our delegate, store a reference to the randomLowercase
                // function in our array
                r[count++] = new RandomCharacter(PasswordGenerator.randomLowercase);
            }
            if (isUppercaseIncluded)
            {
                r[count++] = new RandomCharacter(PasswordGenerator.randomUppercase);
            }
            if (isOthersIncluded)
            {
                r[count++] = new RandomCharacter(PasswordGenerator.randomOther);
            }
            if (isNumbersIncluded)
            {
                r[count++] = new RandomCharacter(PasswordGenerator.randomNumber);
            }

            for (int i = 0; i < length; i++)
            {
                password += r[(int)random.Next(0, count)]();
            }

            return(password);
        } // end generatePassword method
Ejemplo n.º 6
0
        public void CorrectAbilityScoreModifersAreReturned()
        {
            // Arrange
            RandomCharacter testCharacter = new RandomCharacter();
            AbilityScore    AS            = new AbilityScore();

            var scores = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 141, 516, 17, 17, 19, 20, 21, 22 };

            // Assert
            foreach (var score in scores)
            {
                var mod = AS.getAbilityScoreModifier(score);

                Assert.Equal(mod, (score - 10 / 2));
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            RandomCharacter newCharacter = new RandomCharacter();

            Tools.saveCharacterToJSON(newCharacter);
        }