Exemplo n.º 1
0
        private async Task <Show> MapToDomainModel(Infrastructure.TvMaze.Contract.Show show)
        {
            var model = new Show(show.Name, show.Id);

            foreach (var dto in show.Cast.Select(c => c.Person))
            {
                // use external ids to match to already synced people
                var person = await _peopleRepository.FindByExternalIdAsync(dto.Id)
                             ?? new Person(dto.Name, dto.Id, dto.Birthday);

                model.AddCastMember(person);
            }

            return(model);
        }
Exemplo n.º 2
0
        public async Task Handle_Always_ReturnsCastOrderedByDescendingBirthday()
        {
            // Arrange
            var theWire = new Show("The Wire", 42);

            theWire.AddCastMember(new Person("Idris Elba", 3, DateTime.Parse("1970-09-22")));
            theWire.AddCastMember(new Person("Michael K. Williams", 4, DateTime.Parse("1970-09-23")));

            _repository
            .Setup(r => r.GetPageAsync(It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(new List <Show> {
                theWire
            });

            // Act
            var result = await _target.Handle(new GetAllShowsQuery(0), default);

            // Assert
            foreach (var show in result.Shows)
            {
                var expected = show.Cast.OrderByDescending(c => c.Birthday);
                Assert.True(show.Cast.SequenceEqual(expected));
            }
        }