public void Fees_Import() { FeeTestArgs args = CreateManyFees(1, 1, 1, MethodBase.GetCurrentMethod().Name); FeeCache cache = new FeeCache(); List <Fee> listImportedFees = cache.GetListFees(args.emptyFeeSchedNum, 0, 0); foreach (Fee fee in cache.GetListFees(_standardFeeSchedNum, 0, 0)) { string codeText = _listProcCodes.Where(x => x.CodeNum == fee.CodeNum).Select(x => x.ProcCode).FirstOrDefault(); listImportedFees = Fees.Import(codeText, fee.Amount, args.emptyFeeSchedNum, fee.ClinicNum, fee.ProvNum, listImportedFees); } Fees.InsertMany(listImportedFees); //Not able to use CollectionsAssert AreEqual because the FeeNums will be different for (int i = 0; i < listImportedFees.Count; i++) { Fee fee = listImportedFees[i]; Fee originalFee = cache.GetFee(fee.CodeNum, _standardFeeSchedNum, fee.ClinicNum, fee.ProvNum); try { Assert.AreEqual(originalFee.Amount, fee.Amount); } catch (Exception e) { throw new Exception("Import failed for fee at index :" + i + " with CodeNum=" + fee.CodeNum + " Inner:" + e.Message); } } }
protected static void FeeTestSetup() { //Some unit tests cannot handle duplicate procedure codes being present within the database. //This is acceptable because that scenario should be impossible (we block the user via the UI layer). //Delete all duplicate procedure codes. Dictionary <string, ProcedureCode> dictProcCodes = ProcedureCodes.GetAllCodes().GroupBy(x => x.ProcCode).ToDictionary(x => x.Key, x => x.First()); ProcedureCodeT.ClearProcedureCodeTable(); foreach (ProcedureCode procedureCode in dictProcCodes.Values) { ProcedureCodes.Insert(procedureCode); } ProcedureCodes.RefreshCache(); _listProcCodes = ProcedureCodes.GetAllCodes(); //Just in case the PKs matter to some tests. _listProcCodesOld = _listProcCodes.Select(x => x.Copy()).ToList(); if (Fees.GetCountByFeeSchedNum(_standardFeeSchedNum) <= 0) { List <Fee> listFees = new List <Fee>(); foreach (ProcedureCode procCode in _listProcCodes) { listFees.Add(new Fee() { FeeSched = _standardFeeSchedNum, CodeNum = procCode.CodeNum, Amount = _defaultFeeAmt * _rand.NextDouble(), ClinicNum = 0, ProvNum = 0 }); //create the default fee schedule fee } Fees.InsertMany(listFees); } }
/// <summary>Creates the request number of fee schedules, clinics and providers, and creates fees for each combination and code num.</summary> private FeeTestArgs CreateManyFees(int numFeeScheds, int numClinics, int numProvs, string suffix) { FeeTestArgs retVal = new FeeTestArgs(); //Set up fee schedules for (int i = 0; i < numFeeScheds; i++) { retVal.ListFeeSchedNums.Add(FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix, false)); } //Set up clinics Prefs.UpdateBool(PrefName.EasyNoClinics, false); for (int i = 0; i < numClinics; i++) { retVal.ListClinics.Add(ClinicT.CreateClinic(suffix + i)); } //Set up providers for (int i = 0; i < numProvs; i++) { retVal.ListProvNums.Add(ProviderT.CreateProvider(suffix)); } //Create the fees List <Fee> listFees = new List <Fee>(); foreach (long codeNum in _listProcCodes.Select(x => x.CodeNum)) { foreach (long feeSchedNum in retVal.ListFeeSchedNums) { foreach (Clinic clinic in retVal.ListClinics) { foreach (long provNum in retVal.ListProvNums) { listFees.Add(new Fee() { FeeSched = feeSchedNum, ClinicNum = clinic.ClinicNum, ProvNum = provNum, CodeNum = codeNum, Amount = _defaultFeeAmt * _rand.NextDouble() }); } } } } Fees.InsertMany(listFees); retVal.ListFees = Fees.GetByFeeSchedNumsClinicNums(retVal.ListFeeSchedNums, retVal.ListClinics.Select(x => x.ClinicNum).ToList()) .Union(Fees.GetByFeeSchedNumsClinicNums(new List <long>() { _standardFeeSchedNum }, new List <long>() { 0 })).ToList(); //create an empty feeschedule for the Insert/Update/Delete tests retVal.emptyFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Empty" + suffix, false); return(retVal); }
public static void SetUp(TestContext context) { _listProcCodes = ProcedureCodes.GetAllCodes(); List <Fee> listFees = new List <Fee>(); foreach (ProcedureCode procCode in _listProcCodes) { listFees.Add(new Fee() { FeeSched = _standardFeeSchedNum, CodeNum = procCode.CodeNum, Amount = _defaultFeeAmt * _rand.NextDouble(), ClinicNum = 0, ProvNum = 0 }); //create the default fee schedule fee } Fees.InsertMany(listFees); }