Esempio n. 1
0
        public async Task DeleteByIdAsync_ShouldSuccessfullyDelete()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var roadObjectService            = new RoadObjectService(context);
            var deleteRoadObjectServiceModel = new DeleteRoadObjectServiceModel();

            deleteRoadObjectServiceModel.Id = 1;

            await roadObjectService.DeleteByIdAsync(deleteRoadObjectServiceModel.Id);

            var expectedResult = 1;
            var actualResult   = roadObjectService
                                 .All()
                                 .Count();
            var expectedResult2 = "RON 2";
            var actualResult2   = roadObjectService
                                  .All()
                                  .First()
                                  .Name;

            Assert.True(expectedResult == actualResult);
            Assert.True(expectedResult2 == actualResult2);
        }
Esempio n. 2
0
        public async Task DeleteByIdAsync_WithNonExistingIdShouldThrowArgumentNullException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var roadObjectService            = new RoadObjectService(context);
            var deleteRoadObjectServiceModel = new DeleteRoadObjectServiceModel();

            deleteRoadObjectServiceModel.Id = 3;

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