コード例 #1
0
        public void User_CreatingAUserWithANullName_AExceptionShouldBeThrown()
        {
            Action action = () => User.Create(
                ValidEmail, _nullStringParameter, _validBirthdate, _validGender.Id);

            action.Should().Throw <DomainException>().WithMessage(DomainPreconditionMessages.GetNotEmpty(nameof(User.Name)));
        }
コード例 #2
0
        public void User_CreatingAUserWithANotRightFormat_AExceptionShouldBeThrown()
        {
            Action action = () => User.Create(
                _notValidEmail, _validName, _validBirthdate, _validGender.Id);

            action.Should().Throw <DomainException>().WithMessage(DomainPreconditionMessages.GetSuccessMatch(nameof(User.Email)));
        }
コード例 #3
0
ファイル: GameTests.cs プロジェクト: VFA91/AggregateExamples
        public void When_create_a_game_without_name_must_throw_an_exception()
        {
            Action action = () => Game.Create(null);

            action.Should().Throw <DomainException>()
            .WithMessage(DomainPreconditionMessages.GetNotNull(nameof(Game.Name)));
        }
コード例 #4
0
        public void User_CreatingAUserWithATooEarlyBirthday_AExceptionShouldBeThrown()
        {
            Action action = () => User.Create(
                ValidEmail, _validName, _tooEarlyBirthdate, _validGender.Id);

            action.Should().Throw <DomainException>()
            .WithMessage(DomainPreconditionMessages.GetLaterThan(User.BirthdateMinDate, nameof(User.Birthdate)));
        }
コード例 #5
0
        public void User_CreatingAUserWithATooShortName_AExceptionShouldBeThrown()
        {
            Action action = () => User.Create(
                ValidEmail, _tooShortName, _validBirthdate, _validGender.Id);

            action.Should().Throw <DomainException>()
            .WithMessage(DomainPreconditionMessages.GetShorterThan(User.NameMinLength, nameof(User.Name)));
        }
コード例 #6
0
        public void User_CreatingAUserWithATooLongEmail_AExceptionShouldBeThrown()
        {
            Action action = () => User.Create(
                _tooLongEmail, _validName, _validBirthdate, _validGender.Id);

            action.Should().Throw <DomainException>()
            .WithMessage(DomainPreconditionMessages.GetLongerThan(User.EmailMaxLength, nameof(User.Email)));
        }
コード例 #7
0
ファイル: GameTests.cs プロジェクト: VFA91/AggregateExamples
        public void When_create_a_game_with_more_than_max_length_must_throw_an_exception()
        {
            var name = new string('c', Game.NAME_MAX_LENGTH + 1);

            Action action = () => Game.Create(name);

            action.Should().Throw <DomainException>().WithMessage(DomainPreconditionMessages.GetLongerThan(Game.NAME_MAX_LENGTH, nameof(Game.Name)));
        }