public async Task UpdateAsync_given_existing_dto_updates_entity()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var bender = new Character {
                        Name = "Bender", Species = "Robot"
                    };
                    var fry = new Character {
                        Name = "Fry", Species = "Human"
                    };
                    var entity = new Episode
                    {
                        Title             = "Murder on the Planet Express",
                        FirstAired        = new DateTime(2013, 8, 21),
                        EpisodeCharacters = new HashSet <EpisodeCharacter>
                        {
                            new EpisodeCharacter {
                                Character = bender
                            },
                            new EpisodeCharacter {
                                Character = fry
                            }
                        }
                    };
                    context.Episodes.Add(entity);
                    await context.SaveChangesAsync();

                    var repository = new EpisodeRepository(context);
                    var dto        = new EpisodeCreateUpdateDTO
                    {
                        Id           = entity.Id,
                        Title        = "The Series Has Landed",
                        FirstAired   = new DateTime(1999, 4, 4),
                        CharacterIds = new HashSet <int> {
                            bender.Id
                        }
                    };

                    var updated = await repository.UpdateAsync(dto);

                    Assert.True(updated);

                    var updatedEntity = await context.Episodes.Include(c => c.EpisodeCharacters).FirstOrDefaultAsync(c => c.Id == entity.Id);

                    Assert.Equal("The Series Has Landed", updatedEntity.Title);
                    Assert.Equal(new DateTime(1999, 4, 4), updatedEntity.FirstAired);
                    Assert.Equal(bender.Id, updatedEntity.EpisodeCharacters.Single().CharacterId);
                }
        }
        public async Task UpdateAsync_given_non_existing_dto_returns_false()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var repository = new EpisodeRepository(context);
                    var dto        = new EpisodeCreateUpdateDTO
                    {
                        Id    = 0,
                        Title = "Dummy"
                    };

                    var updated = await repository.UpdateAsync(dto);

                    Assert.False(updated);
                }
        }