public async Task Should_get_all_event_rooms() { var eventRoom1 = new EventRoomBuilder() .Build(); var eventRoom2 = new EventRoomBuilder() .Build(); var eventRooms = new List <EventRoom> { eventRoom1, eventRoom2 }; _eventRoomRepository .GetAllAsync() .Returns(eventRooms); var eventRoomsResponse = await _eventRoomService .GetAll(); eventRoomsResponse .Should() .SatisfyRespectively( item1 => { item1 .Should() .BeEquivalentTo(eventRoom1, opt => opt.ExcludingMissingMembers()); }, item2 => { item2 .Should() .BeEquivalentTo(eventRoom2, opt => opt.ExcludingMissingMembers()); }); }
public async Task Should_update_a_coffee_place() { var command = new UpdateEventRoomCommandBuilder() .Build(); var eventRoom = new EventRoomBuilder() .WithId(command.EventRoomId) .Build(); _eventRoomRepository .GetByIdAsync(command.EventRoomId) .Returns(eventRoom); var response = await _eventRoomService .Update(command); response .Id .Should() .Be(command.EventRoomId); response .Name .Should() .Be(command.Name); response .Capacity .Should() .Be(command.Capacity); response .PersonEventRoomAssociations .Should() .BeEmpty(); }
public async Task Should_update_a_person() { var coffeePlace = new CoffeePlaceBuilder() .Build(); var eventRoom = new EventRoomBuilder() .Build(); var command = new UpdatePersonCommandBuilder() .WithCoffeePlaceIds(new List <long> { coffeePlace.Id }) .WithEventRoomIds(new List <long> { eventRoom.Id }) .Build(); var person = new PersonBuilder() .WithId(command.PersonId) .Build(); _coffeePlaceRepository .GetByIds(command.CoffeePlaceIds) .Returns(new List <CoffeePlace> { coffeePlace }); _eventRoomRepository .GetByIds(command.EventRoomIds) .Returns(new List <EventRoom> { eventRoom }); _personRepository .GetByIdAsync(command.PersonId) .Returns(person); var personResponse = await _personService .Update(command); personResponse .Should() .BeEquivalentTo(command, opt => opt.ExcludingMissingMembers()); await _personRepository .Received(1) .DeleteAssociationsByIdAsync(command.PersonId); }
public async Task Should_get_a_event_room_by_id() { const long eventRoomId = 1; var eventRoom = new EventRoomBuilder() .WithId(eventRoomId) .Build(); _eventRoomRepository .GetByIdAsync(eventRoomId) .Returns(eventRoom); var ceventRoomResponse = await _eventRoomService .GetByIdWithDetails(eventRoomId); ceventRoomResponse .Should() .BeEquivalentTo(eventRoom, opt => opt.ExcludingMissingMembers()); }
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(); }