Beispiel #1
0
        public async Task DeleteAsync_given_existing_voteId_deletes_it()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var entity = new Vote
                    {
                        EventStockId = 1,
                        Score        = 5
                    };

                    context.Votes.Add(entity);
                    await context.SaveChangesAsync();

                    var id = entity.Id;

                    var repository = new VoteRepository(context);

                    var deleted = await repository.DeleteAsync(id);

                    Assert.True(deleted);

                    var deletedEntity = await context.Votes.FindAsync(id);

                    Assert.Null(deletedEntity);
                }
        }
Beispiel #2
0
        public async Task DeleteAsync_given_non_existing_voteId_returns_false()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var repository = new VoteRepository(context);

                    var success = await repository.DeleteAsync(42);

                    Assert.False(success);
                }
        }