private POCOMultiTypeObject CreateRandomPoco(bool nullableSetNull = false) { var randomizer = new Bogus.Randomizer(); var poco = new POCOMultiTypeObject() { BoolField = randomizer.Bool(), DateTimeField = DateTime.Now, NDateTimeField = (nullableSetNull) ? (DateTime?)null : DateTime.Now, StrDateTime = (nullableSetNull) ? (string)null : DateTime.Now.ToShortTimeString(), DoubleField = randomizer.Double(), FloatField = randomizer.Float(), GuidField = randomizer.Guid(), NGuidField = (nullableSetNull) ? (Guid?)null : randomizer.Guid(), ID = randomizer.Int(), IntField = randomizer.Int(), LongField = randomizer.Long(), NBoolField = (nullableSetNull) ? (bool?)null : randomizer.Bool(), NDoubleField = (nullableSetNull) ? (double?)null : randomizer.Double(), NFloatField = (nullableSetNull) ? (float?)null : randomizer.Float(), NIntField = (nullableSetNull) ? (int?)null : randomizer.Int(), NLongField = (nullableSetNull) ? (long?)null : randomizer.Long(), //RowID = randomizer.Int(), StringField = randomizer.String2(16), }; return(poco); }
public void UpdatePlot() { var random = new Bogus.Randomizer(); var unitCode = "u1"; var stratumCode = "st1"; var plotNumber = 1; var plotID = Guid.NewGuid().ToString(); var cruiseID = CruiseID; using (var database = CreateDatabase()) { var datastore = new CuttingUnitDatastore(database, cruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID)); var stratumPlot = new Plot_Stratum() { CuttingUnitCode = unitCode, PlotNumber = plotNumber, StratumCode = stratumCode, IsEmpty = false, }; database.Execute($"INSERT INTO Plot (CruiseID, PlotID, CuttingUnitCode, PlotNumber) VALUES " + $"('{cruiseID}', '{plotID}', '{unitCode}', {plotNumber})"); var plot = datastore.GetPlot(unitCode, plotNumber); var slope = random.Double(); plot.Slope = slope; var aspect = random.Double(); plot.Aspect = aspect; var remarks = random.String2(24); plot.Remarks = remarks; datastore.UpdatePlot(plot); var plotAgain = datastore.GetPlot(unitCode, plotNumber); plotAgain.Slope.Should().Be(slope); plotAgain.Aspect.Should().Be(aspect); plotAgain.Remarks.Should().Be(remarks); } }