예제 #1
0
        public void AddAddress_Should_ReturnFail_When_AddressExists()
        {
            var line     = string.Join(string.Empty, _fixture.CreateMany <char>(100));
            var postCode = string.Join(string.Empty, _fixture.CreateMany <char>(10));
            var number   = Math.Abs(_fixture.Create <int>());

            var user = _fixture.Build <User>()
                       .With(x => x.Addresses, new List <Address>
            {
                _fixture.Build <Address>()
                .With(x => x.Line, line)
                .With(x => x.Number, number)
                .With(x => x.PostCode, postCode)
                .Create()
            })
                       .Create();

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

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(DomainError.AddressError.AddressAlreadyExist);
        }
예제 #2
0
        public void AddAddress_Should_ReturnFail_When_PostCodeIsMissing(string postCode)
        {
            var user = _fixture.Create <User>();

            var line   = string.Join(string.Empty, _fixture.CreateMany <char>(100));
            var number = Math.Abs(_fixture.Create <int>());

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

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(DomainError.AddressError.MissingPostCode);
        }