Example #1
0
        public async void UpdateResultNotInDatabaseDoesNotUpdateDatabase()
        {
            //Create the options to feed into the context for dependency injection...
            DbContextOptions <API_DanceFellowsDbContext> options = new DbContextOptionsBuilder <API_DanceFellowsDbContext>().UseInMemoryDatabase("UpdateNonExistentDoesNothing").Options;

            using (API_DanceFellowsDbContext context = new API_DanceFellowsDbContext(options))
            {
                //arrange
                Result result = new Result();
                result.EventCompetitionID = 1;
                result.CompetitorID       = 1;
                result.Placement          = Placement.Finalled;

                Result resultTwo = new Result();
                resultTwo.EventCompetitionID = 1;
                resultTwo.CompetitorID       = 2;
                resultTwo.Placement          = Placement.Position3;
                //act
                ResultManagementService resultServ = new ResultManagementService(context);

                await resultServ.CreateResult(result);

                Result queryResult = await resultServ.GetResult(1, 1);

                Placement oldPlacement = queryResult.Placement;
                resultTwo.Placement = Placement.Position3;
                await resultServ.UpdateResult(resultTwo);

                queryResult = await resultServ.GetResult(1, 1);

                //assert
                Assert.Equal(oldPlacement, queryResult.Placement);
            }
        }
Example #2
0
        public async void DeleteResultDeletesOnlyThatResult()
        {
            //Create the options to feed into the context for dependency injection...
            DbContextOptions <API_DanceFellowsDbContext> options = new DbContextOptionsBuilder <API_DanceFellowsDbContext>().UseInMemoryDatabase("DeletingADoesNotDeleteB").Options;

            using (API_DanceFellowsDbContext context = new API_DanceFellowsDbContext(options))
            {
                //arrange
                Result result = new Result();
                result.EventCompetitionID = 1;
                result.CompetitorID       = 1;
                result.Placement          = Placement.Finalled;

                Result resultTwo = new Result();
                resultTwo.EventCompetitionID = 1;
                resultTwo.CompetitorID       = 2;
                resultTwo.Placement          = Placement.Position3;
                //act
                ResultManagementService resultServ = new ResultManagementService(context);

                await resultServ.CreateResult(result);

                await resultServ.CreateResult(resultTwo);

                await resultServ.DeleteResult(result.EventCompetitionID, result.CompetitorID);

                Result queryResult = await resultServ.GetResult(1, 2);

                //assert
                Assert.Equal(resultTwo, queryResult);
            }
        }
Example #3
0
        public async void DeleteDeletesARecordFromTheDatabase()
        {
            //Create the options to feed into the context for dependency injection...
            DbContextOptions <API_DanceFellowsDbContext> options = new DbContextOptionsBuilder <API_DanceFellowsDbContext>().UseInMemoryDatabase("DeleteDeletes").Options;

            using (API_DanceFellowsDbContext context = new API_DanceFellowsDbContext(options))
            {
                //arrange
                Result result = new Result();
                result.EventCompetitionID = 1;
                result.CompetitorID       = 1;
                result.Placement          = Placement.Finalled;
                //act
                ResultManagementService resultServ = new ResultManagementService(context);

                await resultServ.CreateResult(result);

                await resultServ.DeleteResult(result.EventCompetitionID, result.CompetitorID);

                Result queryResult = await resultServ.GetResult(1, 1);

                //assert
                Assert.Null(queryResult);
            }
        }