Esempio n. 1
0
        public void AddPhone_Should_ReturnFail_When_NumberIsNull(string number)
        {
            var user = _fixture.Create <User>();

            var root = new UserAggregationRoot(new UserState(user),
                                               Enumerable.Empty <IAggregationRootInterceptor <UserState, Guid> >(),
                                               Substitute.For <ILogger <UserAggregationRoot> >());
            var result = root.AddPhone(number);

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(DomainError.PhoneError.MissingNumber);
        }
Esempio n. 2
0
        public void AddPhone_Should_ReturnOk()
        {
            var user   = _fixture.Create <User>();
            var number = string.Join(string.Empty, _fixture.CreateMany <char>(14));

            var root = new UserAggregationRoot(new UserState(user),
                                               Enumerable.Empty <IAggregationRootInterceptor <UserState, Guid> >(),
                                               Substitute.For <ILogger <UserAggregationRoot> >());
            var result = root.AddPhone(number);

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(Result.Ok());
        }
Esempio n. 3
0
        public void AddPhone_Should_ReturnFail_When_NumberAlreadyAdded()
        {
            var number = string.Join(string.Empty, _fixture.CreateMany <char>(14));
            var user   = _fixture.Build <User>()
                         .With(x => x.Phones, new HashSet <Phone>
            {
                new Phone
                {
                    Number = number
                }
            })
                         .Create();

            var root = new UserAggregationRoot(new UserState(user),
                                               Enumerable.Empty <IAggregationRootInterceptor <UserState, Guid> >(),
                                               Substitute.For <ILogger <UserAggregationRoot> >());
            var result = root.AddPhone(number);

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(DomainError.PhoneError.NumberAlreadyExist);
        }