Esempio n. 1
0
        public async Task CreateAttributeAsync_ValidInput_ReturnSuccess()
        {
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();
            var controller   = new StatisticController(charProvider, statProvider, null);

            var result = await controller.CreateAttributeAsync("Wisdom");

            Assert.Equal(StatisticResult.StatisticCreatedSuccessfully(), result);
        }
Esempio n. 2
0
        public async Task CreateSkillAsync_ValidInput_ReturnSuccess()
        {
            var charProvider = new MockCharacterProvider();
            var statProvider = new MockStatisticProvider();
            var controller   = new StatisticController(charProvider, statProvider, null);

            var result = await controller.CreateSkillAsync("Intimidation", "Strength");

            Assert.Equal(StatisticResult.StatisticCreatedSuccessfully(), result);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new Skill in the database.
        /// </summary>
        /// <param name="statName">The name for the new skill.</param>
        /// <param name="attribName">The name of the attribute to go with the skill. Must exist in the database beforehand.</param>
        /// <returns>
        /// A result detailing if the operation was successful or why it failed.
        /// </returns>
        public async Task <IResult> CreateSkillAsync(string statName, string attribName)
        {
            if (await _statProvider.GetStatisticAsync(statName) != null)
            {
                return(StatisticResult.NameAlreadyExists());
            }

            var result = await _statProvider.CreateSkillAsync(statName, attribName);

            if (result == null)
            {
                return(StatisticResult.StatisticCreationFailed());
            }
            return(StatisticResult.StatisticCreatedSuccessfully());
        }