public async Task CreateSkillAsync_InvalidAttributeName_ReturnCreationFailed() { var charProvider = new MockCharacterProvider(); var statProvider = new MockStatisticProvider(); var controller = new StatisticController(charProvider, statProvider, null); var result = await controller.CreateSkillAsync("Intimidation", "STR"); Assert.Equal(StatisticResult.StatisticCreationFailed(), result); }
/// <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()); }