Esempio n. 1
0
        public async Task CreateUser_With_Duplicated_Email_Should_Return_Validation_Error()
        {
            var response = await Some.UserService(Some.MockedContext().With(Some.User().With(userName: "******", email: "*****@*****.**").ToList()))
                           .CreateUserAsync(Some.CreateUserCommand().With(userName: "******", email: "*****@*****.**"));

            response.ValidationResult.Errors.Should().ContainKey(PropertyName.Get((CreateUserCommand x) => x.Email));
        }
Esempio n. 2
0
        public async Task CreateUser_With_Correct_Command_Should_Create_User()
        {
            var context        = Some.MockedContext().With(new List <User>()).Build();
            var userRepository = Substitute.For <Repository <User> >(context);

            var command  = Some.CreateUserCommand().With(password: "******", rePassword: "******").Build();
            var response = await Some.UserService(context, userRepository).CreateUserAsync(command);

            response.ValidationResult.Errors.Should().BeEmpty();
            userRepository.Received(1).Add(Arg.Is <User>(x => !string.IsNullOrEmpty(x.HashedPassword) && x.HashedPassword != command.Password));
        }
Esempio n. 3
0
        public async Task CreateUser_With_Incorrectly_Repeated_Password_Should_Return_Validation_Error()
        {
            var response = await Some.UserService().CreateUserAsync(Some.CreateUserCommand().With(password: "******", rePassword: "******"));

            response.ValidationResult.Errors.Should().ContainKey(PropertyName.Get((CreateUserCommand x) => x.RepeatedPassword));
        }
Esempio n. 4
0
        public async Task CreateUser_Invalid_UserName_Should_Return_Validation_Error()
        {
            var response = await Some.UserService().CreateUserAsync(Some.CreateUserCommand().With(userName: "******"));

            response.ValidationResult.Errors.Should().ContainKey(PropertyName.Get((CreateUserCommand x) => x.UserName));
        }
Esempio n. 5
0
        public async Task CreateUser_Invalid_Email_Should_Return_Validation_Error()
        {
            var response = await Some.UserService().CreateUserAsync(Some.CreateUserCommand().With(email: "invalid"));

            response.ValidationResult.Errors.Should().ContainKey(PropertyName.Get((CreateUserCommand x) => x.Email));
        }