public static POCOMultiTypeObject CreateWithID(bool nullableSetNull = false) { 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 Setup() { var bogus = new Bogus.Randomizer(); BufferSegment headerBufferSegment = new BufferSegment(Constants.PAGE_SIZE); var headerPage = HeaderPage.CreateHeaderPage(headerBufferSegment); BufferSegment bufferSegment = new BufferSegment(Constants.PAGE_SIZE); PageHeader header = new PageHeader(1, PageType.Data); header.ToBuffer(bufferSegment.Span, 0); File.Delete(@"C:\Neuer Ordner\test.db"); PageService pageService = new PageService(FileDiskService.Create(new DatatentSettings() { InMemory = false, Path = @"C:\Neuer Ordner\test.db" })); _dataService = new DataService(new NopCompressionService(), pageService); _objects = new List <TestObject>(50); foreach (var i in Enumerable.Range(0, 50)) { TestObject testObject = new TestObject(); testObject.IntProp = bogus.Int(); testObject.StringProp = bogus.String2(1000); _objects.Add(testObject); } }
public async Task SimpleInsertAndGetWithCheckpointTest() { var bogus = new Bogus.Randomizer(); using BufferSegment headerBufferSegment = new BufferSegment(Constants.PAGE_SIZE); var headerPage = HeaderPage.CreateHeaderPage(headerBufferSegment); using BufferSegment bufferSegment = new BufferSegment(Constants.PAGE_SIZE); PageHeader header = new PageHeader(1, PageType.Data); header.ToBuffer(bufferSegment.Span, 0); PageService pageService = new PageService(new InMemoryDiskService()); DataService dataService = new DataService(new NopCompressionService(), pageService); TestObject testObject = new TestObject(); testObject.IntProp = bogus.Int(); testObject.StringProp = bogus.String2(1000); var address = await dataService.Insert(testObject); address.SlotId.ShouldBe((byte)1); address.PageId.ShouldBe((ushort)1); await pageService.CheckPoint(); var obj = await dataService.Get <TestObject>(address); obj.ShouldNotBeNull(); obj.ShouldBe(testObject); // there should be no second page var secondPage = await pageService.GetPage <BasePage>(2); secondPage.ShouldBeNull(); }
public async Task LargeInsertTest() { var bogus = new Bogus.Randomizer(); using BufferSegment headerBufferSegment = new BufferSegment(Constants.PAGE_SIZE); var headerPage = HeaderPage.CreateHeaderPage(headerBufferSegment); using BufferSegment bufferSegment = new BufferSegment(Constants.PAGE_SIZE); PageHeader header = new PageHeader(1, PageType.Data); header.ToBuffer(bufferSegment.Span, 0); PageService pageService = new PageService(new InMemoryDiskService()); DataService dataService = new DataService(new NopCompressionService(), pageService); TestObject testObject = new TestObject(); testObject.IntProp = bogus.Int(); testObject.StringProp = bogus.String2(1000); for (int i = 0; i < 10000; i++) { var address = await dataService.Insert(testObject); address.SlotId.ShouldBeGreaterThan((byte)0); address.PageId.ShouldBeGreaterThan((byte)0); if (i > 254) { address.PageId.ShouldBeGreaterThan((uint)1); } var resObject = await dataService.Get <TestObject>(address); resObject.ShouldBe(testObject); } }
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); } }
public async Task SimpleInsertTest() { var bogus = new Bogus.Randomizer(); using BufferSegment headerBufferSegment = new BufferSegment(Constants.PAGE_SIZE); var headerPage = HeaderPage.CreateHeaderPage(headerBufferSegment); using BufferSegment bufferSegment = new BufferSegment(Constants.PAGE_SIZE); PageHeader header = new PageHeader(1, PageType.Data); header.ToBuffer(bufferSegment.Span, 0); PageService pageService = new PageService(new InMemoryDiskService()); DataService dataService = new DataService(new NopCompressionService(), pageService); TestObject testObject = new TestObject(); testObject.IntProp = bogus.Int(); testObject.StringProp = bogus.String2(1000); var address = await dataService.Insert(testObject); address.SlotId.ShouldBe((byte)1); address.PageId.ShouldBe((ushort)1); }