Пример #1
0
        public async Task DeleteByIdAsync_ShouldSuccessfullyDelete()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var driverService            = new DriverService(context);
            var deleteDriverServiceModel = new DeleteDriverServiceModel();

            deleteDriverServiceModel.Id = 1;

            await driverService.DeleteByIdAsync(deleteDriverServiceModel.Id);

            var expectedResult = 1;
            var actualResult   = driverService
                                 .All()
                                 .Count();
            var expectedResult2 = "DFN 2";
            var actualResult2   = driverService
                                  .All()
                                  .First()
                                  .FullName;

            Assert.True(expectedResult == actualResult);
            Assert.True(expectedResult2 == actualResult2);
        }
Пример #2
0
        public async Task DeleteByIdAsync_WithNonExistingIdShouldThrowArgumentNullException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var driverService            = new DriverService(context);
            var deleteDriverServiceModel = new DeleteDriverServiceModel();

            deleteDriverServiceModel.Id = 3;

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await driverService.DeleteByIdAsync(deleteDriverServiceModel.Id);
            });
        }