public void FeeSchedTools_CopyFeeSched_Clinics() { //Make sure there are no duplicate fees already present within the database. string dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check); if (dbmResult.Trim() != _feeDeleteDuplicatesExpectedResult) { DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Fix); } //Make sure that there are more than six clinics ClinicT.ClearClinicTable(); for (int i = 0; i < 10; i++) { ClinicT.CreateClinic(MethodBase.GetCurrentMethod().Name + "_" + i); } //Create two fee schedules; from and to FeeSched feeSchedNumFrom = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM"); FeeSched feeSchedNumTo = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO"); //Create a fee for every single procedure code in the database and associate it to the "from" fee schedule. foreach (ProcedureCode code in _listProcCodes) { FeeT.CreateFee(feeSchedNumFrom.FeeSchedNum, code.CodeNum, _rand.Next(5000)); } //Copy the "from" fee schedule into the "to" fee schedule and do it for at least seven clinics. FeeScheds.CopyFeeSchedule(feeSchedNumFrom, 0, 0, feeSchedNumTo, Clinics.GetDeepCopy(true).Select(x => x.ClinicNum).ToList(), 0); //Make sure that there was NOT a duplicate fee inserted into the database. dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check); Assert.AreEqual(dbmResult.Trim(), _feeDeleteDuplicatesExpectedResult, "Duplicate fees detected due to concurrent copying."); }
public void FeeSchedTools_CopyFeeSched_Concurrency() { //Make sure there are no duplicate fees already present within the database. string dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check); if (dbmResult.Trim() != _feeDeleteDuplicatesExpectedResult) { DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Fix); } //Create two fee schedules; from and to FeeSched feeSchedFrom = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM"); FeeSched feeSchedTo = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO"); //Create a single fee and associate it to the "from" fee schedule. FeeT.CreateFee(feeSchedFrom.FeeSchedNum, _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum, _defaultFeeAmt); //Create a helper action that will simply copy the "from" schedule into the "to" schedule for the given fee cache passed in. Action actionCopyFromTo = new Action(() => { FeeScheds.CopyFeeSchedule(feeSchedFrom, 0, 0, feeSchedTo, null, 0); }); //Mimic each user clicking the "Copy" button from within the Fee Tools window one right after the other (before they click OK). actionCopyFromTo(); actionCopyFromTo(); //Make sure that there was NOT a duplicate fee inserted into the database. dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check); Assert.AreEqual(dbmResult.Trim(), _feeDeleteDuplicatesExpectedResult, "Duplicate fees detected due to concurrent copying."); }