public void Sync_PlotLocation_Update() { var fromPath = base.GetTempFilePath(".crz3", "Sync_Plot_Add_fromFile"); var toPath = base.GetTempFilePath(".crz3", "Sync_Plot_Add_toFile"); var syncOptions = new CruiseSyncOptions() { Design = SyncFlags.Insert, FieldData = SyncFlags.Update, }; var cruiseID = Guid.NewGuid().ToString(); var saleID = Guid.NewGuid().ToString(); using var fromDb = CreateDatabaseFile(fromPath, cruiseID, saleID); var newPlot = new Plot() { CruiseID = cruiseID, PlotID = Guid.NewGuid().ToString(), CuttingUnitCode = Units[0], PlotNumber = 1, }; fromDb.Insert(newPlot); var plotLocation = new PlotLocation() { PlotID = newPlot.PlotID, }; fromDb.Insert(plotLocation); fromDb.CopyTo(toPath, true); using var toDb = new CruiseDatastore_V3(toPath); plotLocation.Latitude = Rand.Double(); plotLocation.Longitude = Rand.Double(); fromDb.Update(plotLocation); var syncer = new CruiseSyncer(); syncer.Sync(cruiseID, fromDb, toDb, syncOptions); var plotLocationAgain = toDb.From <PlotLocation>() .Where("PlotID = @p1") .Query(plotLocation.PlotID) .FirstOrDefault(); plotLocationAgain.Should().BeEquivalentTo(plotLocation, config => config.Excluding(x => x.Modified_TS)); }
public void Sync_PlotLocation_Add() { var fromPath = base.GetTempFilePath(".crz3", "Sync_Plot_Add_fromFile"); var toPath = base.GetTempFilePath(".crz3", "Sync_Plot_Add_toFile"); var syncOptions = new CruiseSyncOptions() { Design = SyncFlags.Insert, FieldData = SyncFlags.Insert, }; var cruiseID = Guid.NewGuid().ToString(); var saleID = Guid.NewGuid().ToString(); using var fromDb = CreateDatabaseFile(fromPath, cruiseID, saleID); var newPlot = new Plot() { CruiseID = cruiseID, PlotID = Guid.NewGuid().ToString(), CuttingUnitCode = Units[0], PlotNumber = 1, }; fromDb.Insert(newPlot); fromDb.CopyTo(toPath, true); using var toDb = new CruiseDatastore_V3(toPath); var newPlotLocation = new PlotLocation() { PlotID = newPlot.PlotID, }; fromDb.Insert(newPlotLocation); var syncer = new CruiseSyncer(); syncer.Sync(cruiseID, fromDb, toDb, syncOptions); toDb.GetRowCount("Plot", "WHERE PlotID = @p1", newPlot.PlotID) .Should().Be(1); toDb.GetRowCount("PlotLocation", "WHERE PlotID = @p1", newPlot.PlotID) .Should().Be(1); }