Exemplo n.º 1
0
            public void ThrowsArgumentNullException_WhenCommandArgIsNull()
            {
                ArgumentNullException exception = null;
                var handler = new CreatePersonHandler(null);

                try
                {
                    handler.Handle(null);
                }
                catch (ArgumentNullException ex)
                {
                    exception = ex;
                }

                exception.ShouldNotBeNull();
                // ReSharper disable PossibleNullReferenceException
                exception.ParamName.ShouldEqual("command");
                // ReSharper restore PossibleNullReferenceException
            }
Exemplo n.º 2
0
            public void CreatesPerson_WithLastName()
            {
                var command = new CreatePersonCommand
                {
                    LastName = "West",
                };
                var    entities  = new Mock <ICommandEntities>(MockBehavior.Strict);
                Person outPerson = null;

                entities.Setup(m => m.Create(It.IsAny <Person>()))
                .Callback((Entity entity) => outPerson = (Person)entity);
                var handler = new CreatePersonHandler(entities.Object);

                handler.Handle(command);

                outPerson.ShouldNotBeNull();
                outPerson.LastName.ShouldEqual(command.LastName);
                entities.Verify(m => m.Create(It.Is <Person>(p =>
                                                             p.LastName == command.LastName)), Times.Once());
            }
Exemplo n.º 3
0
            public void CreatesPerson_AndRegisteredUser()
            {
                var command = new CreatePersonCommand
                {
                    UserName         = "******",
                    UserIsRegistered = true,
                };
                var    entities  = new Mock <ICommandEntities>(MockBehavior.Strict);
                Person outPerson = null;

                entities.Setup(m => m.Create(It.IsAny <Person>()))
                .Callback((Entity entity) => outPerson = (Person)entity);
                var handler = new CreatePersonHandler(entities.Object);

                handler.Handle(command);

                outPerson.ShouldNotBeNull();
                outPerson.ShouldEqual(command.CreatedPerson);
                outPerson.User.ShouldNotBeNull();
                outPerson.User.IsRegistered.ShouldBeTrue();
                entities.Verify(m => m.Create(It.Is <Person>(p =>
                                                             p.User.IsRegistered == command.UserIsRegistered)), Times.Once());
            }