Ejemplo n.º 1
0
        public void when_pass_valid_Input_value_expect_person_create_and_register()
        {
            //Arrange

            var command = new CreateNewPersonCommand
            {
                FirstName = "Alireza",
                LastName  = "Oroumand",
                Id        = Guid.NewGuid()
            };
            var moqPersonRepository = new  Moq.Mock <IPersonCommandRepository>();

            moqPersonRepository.Setup(c => c.Add(It.IsAny <Person>()));

            var commanHandler = new CreateNewPersonCommandHandler(moqPersonRepository.Object);

            // Act
            commanHandler.Handle(command);
            //Assert
            moqPersonRepository.Verify(mock => mock.Add(It.IsAny <Person>()), Times.Once());
        }
Ejemplo n.º 2
0
        public void when_pass_valid_Input_value_expect_person_create_and_register_to_databse()
        {
            //Arrange
            var command = new CreateNewPersonCommand
            {
                FirstName = "Alireza",
                LastName  = "Oroumand",
                Id        = Guid.NewGuid()
            };

            var commanHandler = new CreateNewPersonCommandHandler(fixture.PersonCommandRepository);

            // Act
            commanHandler.Handle(command);
            //Assert
            var person = fixture.DbContext.People.FirstOrDefault(c => c.Id == BusinessId.FromGuid(command.Id));

            person.ShouldNotBeNull();
            person.FirstName.ShouldBe(command.FirstName);
            person.LastName.ShouldBe(command.LastName);
        }
Ejemplo n.º 3
0
 public IActionResult Post([FromServices] CreateNewPersonCommandHandler handler, [FromBody] CreateNewPersonCommand command)
 {
     handler.Handle(command);
     return(Ok());
 }