Exemple #1
0
        public async Task GetListByEventGuid_ReturnsGuestList()
        {
            // arrange
            var          eventGuid = Guid.NewGuid().ToString();
            List <Guest> guests    = new List <Guest>();

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

            _guestQueryMock.Setup(x => x.GetListByEventGuid(guests.First().eventGuid))
            .Returns(Task.Factory.StartNew(() => guests));

            // act
            var task = await _sut.GetListByEventGuid(guests.First().eventGuid);

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

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

            Assert.Equal(guests, guestsResult);
        }