public void Should_Create_New_Person() { var initialPeopleCount = GetPeopleCount(); var loCelso = new CreatePersonDto { FirstName = "Lo", LastName = "Celso", Gender = Gender.Male, BirthDate = new DateTime(1996, 4, 9) }; _personAppService.Create(loCelso); UsingDbContext(context => { context.People.Count().ShouldBe(initialPeopleCount + 1); var foundLoCelso = context.People.FirstOrDefault ( p => p.FirstName == loCelso.FirstName && p.LastName == loCelso.LastName && p.Gender == loCelso.Gender && p.BirthDate == loCelso.BirthDate ); foundLoCelso.ShouldNotBeNull(); }); }
public void Should_Insert_Person_With_Success() { //Arrange var personDto = new PersonDto { Id = 2, Name = "John Doe" }; //Act var result = _personAppService.Create(personDto); //Assert Assert.False(LocalNotification.HasNotification()); result.Id.ShouldBe(2); }
public async Task <IActionResult> Post(CreatePersonViewModel model) { var response = await _personAppService.Create(model); if (!response) { return(BadRequest()); } return(Ok()); }
public IActionResult Create([FromBody] PersonViewModel personViewModel) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(Response(personViewModel)); } personAppService.Create(personViewModel); return(Response(personViewModel)); }
public async Task Should_Create_New_Person() { await _personAppService.Create(new CreatePersonInput { Name = "NewPerson" }); UsingDbContext(context => { var t1 = context.People.FirstOrDefault(t => t.Name == "NewPerson"); t1.ShouldNotBeNull(); }); }
public IActionResult Post([FromBody] PersonDto person) { var response = _personAppService.Create(person); return(CreateResponseOnPost(response, PERSON_NAME)); }