コード例 #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);
        }
コード例 #2
0
        public async Task EditAsync_ShouldSuccessfullyEdit()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var roadObjectService          = new RoadObjectService(context);
            var editRoadObjectServiceModel = new EditRoadObjectServiceModel();
            var roadObjectId   = 1;
            var roadObjectName = "FN 3";

            editRoadObjectServiceModel.Id   = roadObjectId;
            editRoadObjectServiceModel.Name = roadObjectName;

            await roadObjectService.EditAsync(editRoadObjectServiceModel);

            var expectedResult = roadObjectName;
            var actualResult   = roadObjectService
                                 .All()
                                 .First()
                                 .Name;

            Assert.True(expectedResult == actualResult);
        }
コード例 #3
0
        public void All_ShouldReturnEmptyResult()
        {
            MapperInitializer.InitializeMapper();
            var context           = ApplicationDbContextInMemoryFactory.InitializeContext();
            var roadObjectService = new RoadObjectService(context);

            var actualResult = roadObjectService.All();

            Assert.True(actualResult.Count() == 0);
        }
コード例 #4
0
        public async Task All_ShouldReturnCorrectResult()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var roadObjectService = new RoadObjectService(context);

            var actualResult   = roadObjectService.All().Select(x => x.Name).ToList();
            var expectedResult = this.GetDummyData().Select(x => x.Name).ToList();

            for (int i = 0; i < actualResult.Count; i++)
            {
                Assert.True(expectedResult[i] == actualResult[i]);
            }
        }
コード例 #5
0
        public async Task CreateAsync_ShouldSuccessfullyCreate()
        {
            MapperInitializer.InitializeMapper();
            var context                      = ApplicationDbContextInMemoryFactory.InitializeContext();
            var roadObjectService            = new RoadObjectService(context);
            var createRoadObjectServiceModel = new CreateRoadObjectServiceModel();
            var roadObjectName               = "RON 1";

            createRoadObjectServiceModel.Name = roadObjectName;

            await roadObjectService.CreateAsync(createRoadObjectServiceModel);

            var expectedResult = roadObjectName;
            var actualResult   = roadObjectService
                                 .All()
                                 .First()
                                 .Name;

            Assert.True(expectedResult == actualResult);
        }