コード例 #1
0
        public async Task DeleteByIdAsync_ReturnsZero_WhenIdNotExist()
        {
            var result = 0;

            using (var context = new MSLunchesContext(GetDbOptions("DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist")))
            {
                var classUnderTest = new LunchService(context);
                result = await classUnderTest.DeleteByIdAsync(Guid.NewGuid());
            }

            Assert.True(result == 0);
        }
コード例 #2
0
        public async Task DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist()
        {
            var lunch = GetADefaultLunch();

            using (var context = new MSLunchesContext(GetDbOptions("DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist")))
            {
                await context.Lunches.AddAsync(lunch);

                await context.SaveChangesAsync();
            }

            var result = 0;

            using (var context = new MSLunchesContext(GetDbOptions("DeleteByIdAsync_ReturnsCountOfChanges_WhenIdExist")))
            {
                var classUnderTest = new LunchService(context);
                result = await classUnderTest.DeleteByIdAsync(lunch.Id);
            }

            Assert.True(result > 0);
        }