Exemplo n.º 1
0
        public void CreateFromNameAndEmail_GivenNullName_ThrowsException()
        {
            var ex = Should.Throw <ArgumentNullException>(
                () => ExamplePerson.Create(null, _email));

            ex.ParamName.ShouldBe("name");
        }
Exemplo n.º 2
0
        public void CreateFromNameAndEmail_GivenNullEmailAddress_ThrowsException()
        {
            var ex = Should.Throw <ArgumentNullException>(
                () => ExamplePerson.Create(_name, null));

            ex.ParamName.ShouldBe("emailAddress");
        }
Exemplo n.º 3
0
        public void CreateFromNameAndEmail_GivenValidData_ReturnsAggregate()
        {
            var result = ExamplePerson.Create(_name, _email);

            result.ShouldSatisfyAllConditions(
                () => result.NewAggregate.ShouldNotBeNull(),
                () => result.NewAggregate.ShouldBeOfType <ExamplePerson>());
        }
Exemplo n.º 4
0
        public void CreateFromNameAndEmail_GivenInvalidNonEmptyEmail_ReturnsNotifications()
        {
            var result = ExamplePerson.Create(_name, "bugbunnyattest.com");

            result.ShouldSatisfyAllConditions(
                () => result.Notifications["EmailAddress"].ShouldContain(
                    n => n.Message.Contains("A valid email address is required.")));
        }
Exemplo n.º 5
0
 protected override async Task <CommandResult> HandleCore(CreateExamplePersonCommand request, CancellationToken cancellationToken)
 {
     return
         ((await
           ExamplePerson
           .Create(request.Name, request.EmailAddress)
           .AddIfSucceeded(_dbContext))
          .ToCommandResult());
 }
Exemplo n.º 6
0
        public void CreateFromNameAndEmail_adds_ExamplePersonCreated_event()
        {
            var aggregate = ExamplePerson.Create("Elmer Fudd", "*****@*****.**").NewAggregate;

            var createdEvent = aggregate.Events.OfType <ExamplePersonCreated>().SingleOrDefault();

            createdEvent.ShouldSatisfyAllConditions(
                () => createdEvent.ShouldNotBeNull(),
                () => createdEvent.Name.ShouldBe("Elmer Fudd"));
        }
Exemplo n.º 7
0
        public void CreateFromNameAndEmail_GivenEmptyData_ReturnsNotifications()
        {
            var result = ExamplePerson.Create("", "");

            result.ShouldSatisfyAllConditions(
                () => result.Notifications["Name"].ShouldContain(
                    n => n.Message.Contains("A name is required.")),
                () => result.Notifications["EmailAddress"].ShouldContain(
                    n => n.Message.Contains("A valid email address is required.")));
        }
Exemplo n.º 8
0
        public void Constructor_sets_properties()
        {
            var person = ExamplePerson.Create("bob", "*****@*****.**").NewAggregate;

            var @event = new ExamplePersonCreated(person.Id, person.Name, person.EmailAddress);

            @event.ShouldSatisfyAllConditions(
                () => @event.EventId.ShouldNotBe(Guid.Empty),
                () => @event.Name.ShouldBe(person.Name),
                () => @event.EmailAddress.ShouldBe(person.EmailAddress));
        }
Exemplo n.º 9
0
        public void CreateFromNameAndEmail_GivenValidEmail_SetsEmail()
        {
            var examplePerson = ExamplePerson.Create(_name, _email).NewAggregate;

            examplePerson.EmailAddress.ShouldBe(_email);
        }
Exemplo n.º 10
0
        public void CreateFromNameAndEmail_GivenValidName_SetsNameProperty()
        {
            var examplePerson = ExamplePerson.Create(_name, _email).NewAggregate;

            examplePerson.Name.ShouldBe(_name);
        }