Exemple #1
0
        public async Task GetListByEventId_ReturnsGuestList()
        {
            // arrange
            List <Guest> guests = new List <Guest>();

            guests.Add(new Guest {
                guestId = 123, name = "Guest1", isGoing = true, eventId = 1
            });
            guests.Add(new Guest {
                guestId = 124, name = "Guest2", isGoing = true, eventId = 1
            });
            guests.Add(new Guest {
                guestId = 125, name = "Guest3", isGoing = false, eventId = 1
            });
            guests.Add(new Guest {
                guestId = 126, name = "Guest4", isGoing = null, eventId = 1
            });

            _guestQueryMock.Setup(x => x.GetListByEventId(guests.First().eventId))
            .Returns(Task.Factory.StartNew(() => guests));

            // act
            var task = await _sut.GetListByEventId(guests.First().eventId);

            // assert
            Assert.IsType <OkObjectResult>(task);

            var result       = task as OkObjectResult;
            var guestsResult = result.Value as List <Guest>;

            Assert.Equal(guests, guestsResult);
        }