예제 #1
0
        public async Task GetVotesForDateAsyncTest()
        {
            Guid  eId = new Guid();
            Event e   = new Event {
                Id = eId
            };
            TimeSlot t1 = new TimeSlot {
                Id = new Guid("00000000-0000-0000-0000-000000000001"), EventId = eId, Event = e
            };
            TimeSlot t2 = new TimeSlot {
                Id = new Guid("00000000-0000-0000-0000-000000000002"), EventId = eId, Event = e
            };
            VoteForDate vd1 = new VoteForDate {
                Id = new Guid("00000000-0000-0000-0000-000000000000"), TimeSlotId = t1.Id, TimeSlot = t1
            };
            VoteForDate vd2 = new VoteForDate {
                Id = new Guid("00000000-0000-0000-0000-000000000002"), TimeSlotId = t1.Id, TimeSlot = t1
            };
            VoteForDate vd3 = new VoteForDate {
                Id = new Guid("00000000-0000-0000-0000-000000000003"), TimeSlotId = t2.Id, TimeSlot = t2
            };
            var tcs = new TaskCompletionSource <List <VoteForDate> >();

            tcs.SetResult(new List <VoteForDate> {
                vd1, vd2, vd3
            });
            _voteForDateRepository.Setup(mock => mock.GetAll()).Returns(tcs.Task);
            var task = await _votingService.GetVotesForDateAsync(eId, t1.Id);

            _voteForDateRepository.Verify(mock => mock.GetAll(), Times.Once(), "Method GetAll was not called or was called more than once (or its parameters were wrong).");

            CollectionAssert.AreEqual(new List <VoteForDate> {
                vd1, vd2
            }, task.ToList(), "Returned list of votes is not correct");
        }