public async Task Should_create_a_person() { var coffeePlace = new CoffeePlaceBuilder() .Build(); var eventRoom = new EventRoomBuilder() .Build(); var command = new CreatePersonCommandBuilder() .WithCoffeePlaceIds(new List <long> { coffeePlace.Id }) .WithEventRoomIds(new List <long> { eventRoom.Id }) .Build(); _coffeePlaceRepository .GetByIds(command.CoffeePlaceIds) .Returns(new List <CoffeePlace> { coffeePlace }); _eventRoomRepository .GetByIds(command.EventRoomIds) .Returns(new List <EventRoom> { eventRoom }); var person = await _personService .Create(command); await _personRepository .Received(1) .AddAsync(Arg.Is <Person>(a => Equals(a.FirstName, command.FirstName) && Equals(a.LastName, command.LastName) && a.PersonCoffeePlaceAssociations.Count == 1 && a.PersonEventRoomAssociations.Count == 1)); person .Should() .NotBeNull(); }
private async Task <IList <EventRoom> > GetEventRooms(IList <long> ids) { var eventRooms = await _eventRoomRepository .GetByIds(ids); foreach (var eventRoomId in ids) { var eventRoom = eventRooms.FirstOrDefault(f => f.Id == eventRoomId); if (eventRoom == default) { throw new NotFoundException("Sala de Evento não encontrada."); } } return(eventRooms); }