public void FixVersion_2_5_0(string fileName) { var targetPath = InitializeTestFile(fileName); using (var db = new CruiseDatastore(targetPath)) { //var trees = db.From<TreeDO>().Query().ToArray(); db.From <TreeDOold>().Invoking(x => x.Query().ToArray()).Should().NotThrow(); var errorTrees = db.QueryGeneric("SELECT * FROM Tree WHERE typeof(Tree_GUID) = 'text' AND Tree_GUID NOT LIKE '________-____-____-____-____________';") .ToArray(); errorTrees.Should().NotBeEmpty(); var updater = new Updater_V2(); updater.Update(db); //db.DatabaseVersion.Should().Be("2.5.1.1"); var errorTreesAgain = db.QueryGeneric("SELECT * FROM Tree WHERE typeof(Tree_GUID) = 'text' AND Tree_GUID NOT LIKE '________-____-____-____-____________';") .ToArray(); errorTreesAgain.Should().BeEmpty(); db.From <TreeDOold>().Invoking(x => x.Query()).Should().NotThrow(); } }
public static List <T> ReadCruiseMethods <T>(CruiseDatastore db, bool reconMethodsOnly) where T : CruiseMethodsDO, new() { if (reconMethodsOnly) { return(db.From <T>() .Where("Code = 'FIX' OR Code = 'PNT'") .Read().ToList()); } else { return(db.From <T>().Read().ToList()); } }
public void Tree_Test(string fileName) { var(orgFile, crz3File, origAgain) = SetUpTestFile(fileName); using (var dbv2 = new CruiseDatastore(orgFile)) using (var dbv2Arain = new CruiseDatastore(origAgain)) { var treev2Again = dbv2Arain.From <V2.Models.Tree>() .Query().ToArray(); treev2Again.Should().NotBeEmpty(); var treev2 = dbv2.From <V2.Models.Tree>() .Query().ToArray(); treev2.Should().NotBeEmpty(); treev2Again.Should().HaveSameCount(treev2); treev2Again.Should().BeEquivalentTo(treev2, config => config .Excluding(y => y.TreeDefaultValue_CN) .Excluding(y => y.TreeFactor) .Excluding(y => y.PointFactor) .Excluding(y => y.ExpansionFactor) .Excluding(y => y.Tree_GUID)); } }
public static Dictionary <String, List <LogMatrixDO> > GetByRowNumberGroupBySpecies(CruiseDatastore cruiseDAL, string reportNum) { var dict = new Dictionary <string, List <LogMatrixDO> >(); var list = cruiseDAL.From <LogMatrixDO>() .Where("ReportNumber = @p1") .Read(reportNum).ToList(); //.Read<LogMatrixDO>("WHERE ReportNumber = ?", (object)reportNum); foreach (LogMatrixDO lm in list) { if (dict.ContainsKey(lm.Species)) { dict[lm.Species].Add(lm); } else { var l = new List <LogMatrixDO>(); l.Add(lm); dict.Add(lm.Species, l); } } return(dict); }
public void Update(string fileName) { var filePath = InitializeTestFile(fileName); using (var ds = new CruiseDatastore(filePath)) { var orgDbVersion = ds.DatabaseVersion; orgDbVersion.Should().Be(Path.GetFileNameWithoutExtension(fileName)); var unitCount = ds.GetRowCount("CuttingUnit", ""); var updater = new Updater_V3(); updater.Update(ds); var unitCountAfter = ds.GetRowCount("CuttingUnit", ""); unitCountAfter.Should().Be(unitCount); var verAfter = ds.DatabaseVersion; verAfter.Should().Be(CruiseDatastoreBuilder_V3.DATABASE_VERSION.ToString()); var tableDefs = CruiseDatastoreBuilder_V3.TABLE_DEFINITIONS; foreach (var t in tableDefs) { var ti = ds.GetTableInfo(t.TableName); ti.Should().NotBeNullOrEmpty(t.TableName); } var sale = ds.From <Sale>().Query().Single(); sale.Should().NotBeNull(); var cruise = ds.From <Cruise>().Query().Single(); cruise.SaleNumber.Should().Be(sale.SaleNumber); var logs = ds.From <Log>().Query().ToArray(); if (logs.Any()) { logs.Should().OnlyContain(x => string.IsNullOrEmpty(x.CruiseID) == false); } // do integrity check var ic_results = ds.QueryScalar <string>("PRAGMA integrity_check;"); ic_results.Should().HaveCount(1); ic_results.Single().Should().Be("ok"); } }
void ValidateMigration(CruiseDatastore v3db, CruiseDatastore v2db) { var units = v3db.From <V3.Models.CuttingUnit>().Query(); var strata = v3db.From <V3.Models.Stratum>().Query().ToArray(); var samplegroups = v3db.From <V3.Models.SampleGroup>().Query(); var plots = v3db.From <V3.Models.Plot>().Query(); var trees = v3db.From <V3.Models.Tree>().Query(); var units2 = v2db.From <V2.Models.CuttingUnit>().Query(); var strata2 = v2db.From <V2.Models.Stratum>().Query().ToArray(); var samplegroups2 = v2db.From <V2.Models.SampleGroup>().Query(); var plots2 = v2db.From <V2.Models.Plot>().Query(); var trees2 = v2db.From <V2.Models.Tree>().Query(); units.Should().HaveSameCount(units2); strata.Should().HaveSameCount(strata2); samplegroups.Should().HaveSameCount(samplegroups2); plots.Should().HaveSameCount(plots2); trees.Should().HaveSameCount(trees2); }
public void Reports_Test(string fileName) { var(orgFile, crz3File, origAgain) = SetUpTestFile(fileName); using (var dbv2 = new CruiseDatastore(orgFile)) using (var dbv2Again = new CruiseDatastore(origAgain)) { var reportsV2Again = dbv2Again.From <V2.Models.Reports>() .Query().ToArray(); reportsV2Again.Should().NotBeEmpty(); var reportsV2 = dbv2.From <V2.Models.Reports>() .Query().ToArray(); reportsV2.Should().NotBeEmpty(); reportsV2Again.Should().HaveSameCount(reportsV2); reportsV2Again.Should().BeEquivalentTo(reportsV2); } }
public void SampleGroup_Test(string fileName) { var(orgFile, crz3File, origAgain) = SetUpTestFile(fileName); using (var dbv2 = new CruiseDatastore(orgFile)) using (var dbv2Again = new CruiseDatastore(origAgain)) { var sgv2Again = dbv2Again.From <V2.Models.SampleGroup>() .Query(); var sgv2 = dbv2.From <V2.Models.SampleGroup>() .Query(); sgv2Again.Should().BeEquivalentTo(sgv2, x => x.Excluding(y => y.SampleSelectorState) .Excluding(y => y.SampleSelectorType) .Excluding(y => y.TallyMethod)); } }
public void CuttingUnits_Test(string fileName) { var(orgFile, crz3File, origAgain) = SetUpTestFile(fileName); using (var dbv2 = new CruiseDatastore(orgFile)) using (var dbv2Again = new CruiseDatastore(origAgain)) { var cuttingUnitsV2Again = dbv2Again.From <V2.Models.CuttingUnit>() .Query(); var cuttingUnitsv2 = dbv2.From <V2.Models.CuttingUnit>() .Query(); cuttingUnitsV2Again.Should().BeEquivalentTo(cuttingUnitsv2, config => config .Using <string>(x => x.Subject.Should().Be(x.Expectation?.Trim())).WhenTypeIs <string>()// ignore whitespace when type is string .Excluding(y => y.TallyHistory)); } }
public void Stratum_Test(string fileName) { var(orgFile, crz3File, origAgain) = SetUpTestFile(fileName); using (var dbv2 = new CruiseDatastore(orgFile)) using (var dbv2Again = new CruiseDatastore(origAgain)) { var stratav2Again = dbv2Again.From <V2.Models.Stratum>() .Query(); var stratav2 = dbv2.From <V2.Models.Stratum>() .Query(); stratav2Again.Should().BeEquivalentTo(stratav2, config => config .Excluding(x => x.VolumeFactor) .Excluding(x => x.Month) .Excluding(x => x.Year)); } }
// test that all positive counts are the same after round trip conversion // we only test positive counts because additional 0 count records can be // created in the conversion process public void RountTrip_CountTree_Test_only_positiveTreeCounts(string fileName) { var(orgFile, crz3File, origAgain) = SetUpTestFile(fileName); using (var dbv2 = new CruiseDatastore(orgFile)) using (var dbv2Again = new CruiseDatastore(origAgain)) { var countTreeV2Again = dbv2Again.From <V2.Models.CountTree>() .Where("TreeCount > 0") .Query(); countTreeV2Again.Should().NotBeEmpty(); var countTreeV2 = dbv2.From <V2.Models.CountTree>() .Where("TreeCount > 0") .GroupBy("CuttingUnit_CN", "SampleGroup_CN", "ifnull(TreeDefaultValue_CN, '')") .Query(); countTreeV2.Should().NotBeEmpty(); countTreeV2Again.Should().HaveSameCount(countTreeV2); countTreeV2Again.Should().BeEquivalentTo(countTreeV2, x => x.Excluding(y => y.Tally_CN) .Excluding(y => y.CountTree_CN)); } }