Exemple #1
0
        public async Task Test_Validate_Character_Name_Works_On_Empty_Characters(string name)
        {
            //arrange
            IServiceProvider    serviceProvider = BuildServiceProvider <CharacterController>("Test", 1);
            CharacterController controller      = serviceProvider.GetService <CharacterController>();

            //act
            CharacterNameValidationResponse result = ControllerTestsHelpers.GetActionResultObject <CharacterNameValidationResponse>(await controller.ValidateCharacterName(name));

            //assert
            Assert.True(result.isSuccessful);
            Assert.True(result.ResultCode == CharacterNameValidationResponseCode.Success);
        }
Exemple #2
0
        public async Task Test_Validate_Character_Name_Passes_On_AlreadyExisting_Character_If_The_Names_Are_Different(string name)
        {
            //arrange
            IServiceProvider    serviceProvider = BuildServiceProvider <CharacterController>("Test", 1);
            CharacterController controller      = serviceProvider.GetService <CharacterController>();

            //act
            await serviceProvider.GetService <ICharacterRepository>().TryCreateAsync(new CharacterEntryModel(1, $"{name}Z"));

            CharacterNameValidationResponse result = ControllerTestsHelpers.GetActionResultObject <CharacterNameValidationResponse>(await controller.ValidateCharacterName(name));

            //assert
            Assert.True(result.isSuccessful);
            Assert.True(result.ResultCode == CharacterNameValidationResponseCode.Success);
        }
Exemple #3
0
        public async Task Test_Validate_Character_Name_Fails_On_AlreadyExisting_Character(string name)
        {
            //arrange
            IServiceProvider    serviceProvider = BuildServiceProvider <CharacterController>("Test", 1);
            CharacterController controller      = serviceProvider.GetService <CharacterController>();

            //act
            await serviceProvider.GetService <ICharacterRepository>().TryCreateAsync(new CharacterEntryModel(1, name));

            CharacterNameValidationResponse result = ControllerTestsHelpers.GetActionResultObject <CharacterNameValidationResponse>(await controller.ValidateCharacterName(name));

            //assert
            Assert.False(result.isSuccessful, $"Response for name validation should be false when the name is taken.");
            Assert.True(result.ResultCode == CharacterNameValidationResponseCode.NameIsUnavailable);
        }