public void jsonStore_Updates_range_of_records_with_string_id() { var InstrumentStore = new JsonStore <InstrumentDocuments>(); var myBatch = new List <InstrumentDocuments>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" }); } InstrumentStore.Add(myBatch); // Re-load, and update: var companies = InstrumentStore.TryLoadData(); for (int i = 0; i < qtyToAdd; i++) { companies.ElementAt(i).Type = "Banjo " + i; } InstrumentStore.Update(companies); // Reload, and check updated names: companies = InstrumentStore.TryLoadData().Where(c => c.Type.StartsWith("Banjo")).ToList(); Assert.IsTrue(companies.Count == qtyToAdd); }
public void JsonGeneratorTest() { List <Message <SimpleObject> > stream1 = new List <Message <SimpleObject> >(); List <Message <SimpleObject> > stream2 = new List <Message <SimpleObject> >(); IStreamMetadata metadata1 = null; IStreamMetadata metadata2 = null; using (var p = Pipeline.Create("JsonGeneratorTest")) { var generator = JsonStore.Open(p, StoreName, InputPath); generator.OpenStream <SimpleObject>("Stream1").Do((d, e) => stream1.Add(new Message <SimpleObject>(d, e.OriginatingTime, e.Time, e.SourceId, e.SequenceId))); generator.OpenStream <SimpleObject>("Stream2").Do((d, e) => stream2.Add(new Message <SimpleObject>(d, e.OriginatingTime, e.Time, e.SourceId, e.SequenceId))); metadata1 = generator.GetMetadata("Stream1"); ValidateMetadata(metadata1, "Stream1", 1, TypeName, PartitionName, PartitionPath, FirstTime, LastTime, FirstTime, LastTime, 388, 0, 2); metadata2 = generator.GetMetadata("Stream2"); ValidateMetadata(metadata2, "Stream2", 2, TypeName, PartitionName, PartitionPath, FirstTime, LastTime, FirstTime, LastTime, 388, 0, 2); p.Run(); } Assert.AreEqual(stream1.Count, 2); Assert.AreEqual(stream2.Count, 2); ValidateMessage(stream1[0], FirstTime, (data) => ValidateSimpleObject(data, Data)); ValidateMessage(stream1[1], LastTime, (data) => ValidateSimpleObject(data, Data)); ValidateMessage(stream2[0], FirstTime, (data) => ValidateSimpleObject(data, Data)); ValidateMessage(stream2[1], LastTime, (data) => ValidateSimpleObject(data, Data)); }
public void jsonStore_Deletes_range_of_records_with_string_id() { var InstrumentStore = new JsonStore <InstrumentDocuments>(); var myBatch = new List <InstrumentDocuments>(); int qtyToAdd = 10; for (int i = 0; i < qtyToAdd; i++) { myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" }); } InstrumentStore.Add(myBatch); // Re-load from back-end: var companies = InstrumentStore.TryLoadData(); int qtyAdded = companies.Count; // Select 5 for deletion: int qtyToDelete = 5; var deleteThese = new List <InstrumentDocuments>(); for (int i = 0; i < qtyToDelete; i++) { deleteThese.Add(companies.ElementAt(i)); } // Delete: InstrumentStore.Delete(deleteThese); int remaining = InstrumentStore.TryLoadData().Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete); }
public void WhenOverwritingAnExistingObjectUsingPut_TheNewerObjectIsReturned() { // Arrange var store = new JsonStore(_rootFileLocation); var id = Guid.NewGuid(); var initialItemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", "value" } } }; _ = store.Put(initialItemToStore); // Act var itemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", "newValue" } } }; _ = store.Put(itemToStore); var storedItem = store.Get(id); // Assert Assert.Equal("newValue", storedItem.Properties["key"].ToString()); }
public async Task AggregateIntegrationTest() { var store = new JsonStore( new HardDrive(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\StackoverflowRecentQuestions")); var web = new WebRequester(); var getter = new RecentQuestionsGetter(store, web); QuestionsWhenUnrestricted = await HandleStackexchangeThrottle(async() => await getter.GetSince(0), store); QuestionsWhenUnrestrictedPage2 = await HandleStackexchangeThrottle(async() => await getter.GetSince(0, 2), store); QuestionsWithEitherJavaOrCSharpSince2017 = await HandleStackexchangeThrottle( async() => await getter.GetSince(Year2017, 1, "stackoverflow", new[] { "c#", "java" }), store); TestsPassed = true; var methods = GetType().GetMethods(); foreach (var method in methods) { if (method.Name.IndexOf("Test") == 0) { await AggregateResult(method.Name.Substring(4), web); } } if (!TestsPassed) { Assert.Fail(TestsFailedString); } }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { var dir = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data")); var store = new JsonStore<EventDescriptor>(dir, "store", "events"); container.Register<IDataStore<EventDescriptor>, JsonStore<EventDescriptor>>(store); container.Register<IStore>(new Store(store, new JsonSerializer())); }
public void can_add_and_save_and_load_again() { using (var fs = new FileSystemTester()) { var set = new FileMetadataCache(); var store = new JsonStore(); var filename = "file-change-set.json"; var file = fs.Touch("file.txt"); set.Add(file); fs.Write(filename, s => store.Save(s, set)); var loadedSet = fs.Read(filename, store.Load<FileMetadataCache>); Assert.IsNotNull(loadedSet); Assert.AreEqual(1, loadedSet.Files.Count); var fileinfo = loadedSet.Files.ElementAt(0); Assert.AreEqual(file.Name, Path.GetFileName(fileinfo.FilePath)); Assert.AreEqual(file.Length, fileinfo.Length); Assert.AreEqual(file.LastWriteTimeUtc, fileinfo.LastWriteTimeUtc); } }
static void Main(string[] args) { var store = new JsonStore <Item>("dbDirectory", "dbName", "itemTable"); var items = new BiggyList <Item>(store); //items.Add(new Item { Id = 1, Name = "item one" }); //items.Add(new Item { Id = 2, Name = "item two" }); //items.Contains() foreach (var item in items) { WriteLine($"{item.Id} - {item.Name}"); } var contains = items.Contains(new Item { Id = 1, Name = "item one" }); WriteLine("Contains: " + contains); var firstOrDefault = items.FirstOrDefault(i => i.Id == 1); WriteLine("FirstOrDefault: " + firstOrDefault.Name); ReadLine(); }
public void TestGet() { con = JsonStore.Create(new ResourcesIO("LibUnity.DataStoreTest/environment")); Assert(con.Get <int>("test_config.var1") == 0, "get test_config.var1 is 0"); Assert(con.Get <long>("test_config.var2") == 533157870896947200, "get test_config.var1 is 0"); //Assert(con.Get<int>("test_config.var1") == 0, "get test_config.var1 is 0"); }
public static GetRecentQuestionsConsoleAdapter Create(JsonStore store, IWebRequester web, SingleStore <Action <string[]> > currentQuestion) { var getter = new GetRecentQuestionsConsoleAdapter(store, web, currentQuestion); getter.Initialize(); return(getter); }
public void init() { var InstrumentStore = new JsonStore <InstrumentDocuments>(); string filePath = InstrumentStore.DbPath; File.Delete(filePath); }
public void init() { _propertyStore = new JsonStore <Property>(); string path = _propertyStore.DbPath; File.Delete(path); }
public GetRecentQuestionsConsoleAdapter(JsonStore store, IWebRequester web, SingleStore <Action <string[]> > currentQuestion) { _store = store; _throttle = new ThrottleChecker(_store); _web = web; _currentQuestion = currentQuestion; }
public async Task OptionIsDisabled() { // load the file var store = new JsonStore <Person>(_options); var person = await store.ReadAsync(); // change it using another instance var options2 = new JsonStoreOptions(_options) { ThrowOnSavingChangedFile = false }; var store2 = new JsonStore <Person>(options2); person.FullName = Guid.NewGuid().ToString("N"); await store2.SaveAsync(person); // change it again and try to save var newPerson = Constants.GetPerson(); newPerson.FullName = Guid.NewGuid().ToString("N"); await store2.SaveAsync(newPerson); // ensure the file was saved var readContent = await store2.ReadAsync(); Assert.Equal(newPerson, readContent); }
public void WhenPuttingPropertiesWithComplexValueTypes_TheyAreReturnedCorrectly() { // Arrange var store = new JsonStore(_rootFileLocation); var id = Guid.NewGuid(); var complexValue = new ExampleComplexSerializableType { StringValue = "example", IntegerValue = 12345 }; var itemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", complexValue } } }; // Act _ = store.Put(itemToStore); var retrievedItem = store.Get(id); // Assert var jsonKeyToCheck = retrievedItem.Properties["key"]; var deserializedValue = JsonSerializer.Deserialize <ExampleComplexSerializableType>(((JsonElement)jsonKeyToCheck).GetRawText()); Assert.Equal(complexValue.StringValue, deserializedValue.StringValue); Assert.Equal(complexValue.IntegerValue, deserializedValue.IntegerValue); }
public DownloadRepository() { var dbPath = EnsurePath(".DB"); JsonStore = new JsonStore <DownloadRecord>(dbPath); _sinks = new List <IDownloadEventSink>(); }
public void WhenPuttingThenGettingMultipleTimes_TheOriginalResultShouldBeTheSame() { // Arrange var store = new JsonStore(_rootFileLocation); var id = Guid.NewGuid(); var initialItemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", "value" } } }; // Act _ = store.Put(initialItemToStore); var retrievedFirstTime = store.Get(id); _ = store.Put(retrievedFirstTime); var retrievedSecondTime = store.Get(id); _ = store.Put(retrievedSecondTime); var retrievedThirdTime = store.Get(id); // Assert (using serialization as a quick way to deep check the values of dictionary) var itemToStorePropertiesAsJson = JsonSerializer.Serialize(initialItemToStore.Properties); var storedPropertiesAsJson = JsonSerializer.Serialize(retrievedThirdTime.Properties); Assert.Equal(initialItemToStore.Id, retrievedThirdTime.Id); Assert.Equal(itemToStorePropertiesAsJson, storedPropertiesAsJson); }
public void AfterAnObjectIsStored_RetrievingItMatches() { // Arrange var store = new JsonStore(_rootFileLocation); var id = Guid.NewGuid(); var itemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", "value" } } }; _ = store.Put(itemToStore); // Act var storedItem = store.Get(id); // Assert (using serialization as a quick way to deep check the values of dictionary) var itemToStorePropertiesAsJson = JsonSerializer.Serialize(itemToStore.Properties); var storedPropertiesAsJson = JsonSerializer.Serialize(storedItem.Properties); Assert.Equal(itemToStore.Id, storedItem.Id); Assert.Equal(itemToStorePropertiesAsJson, storedPropertiesAsJson); }
public void AfterOverwritingAnExistingObjectUsingPut_OnlyOneFileExistsOnDisk() { // Arrange var store = new JsonStore(_rootFileLocation); var id = Guid.NewGuid(); var initialItemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", "value" } } }; _ = store.Put(initialItemToStore); // Act var itemToStore = new StorableBase { Id = id, Properties = new Dictionary <string, object> { { "key", "newValue" } } }; _ = store.Put(itemToStore); // Assert Assert.Single(Directory.GetFiles(_rootFileLocation)); }
private void load(JsonStore jsonStore) { Add(world = jsonStore.Deserialize <World>("Json/world.json")); //world.Spin(1000, RotationDirection.Clockwise).Loop(); //world.Anchor = Anchor.Centre; //world.Origin = Anchor.Centre; world.OnLoadComplete += _ => Schedule(worldLoadComplete); }
// Start is called before the first frame update void Start() { store = new JsonStore(); // var t = SaveAsync(); var t = LoadAsync(); t.Wait(); }
public void WhenDeletingAnObjectWhichDoesNotExist_ANotFoundExceptionIsThrown() { // Arrange var store = new JsonStore(_rootFileLocation); // Assert Assert.Throws <KeyNotFoundException>(() => { store.Delete(Guid.NewGuid()); }); }
public void jsonStore_Inserts_record_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var newInstrument = new InstrumentDocuments { Id = "USA123", Category = "String", Type = "Guitar" }; InstrumentStore.Add(newInstrument); var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault(i => i.Id == "USA123"); Assert.IsTrue(foundInstrument != null && foundInstrument.Id == "USA123"); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { var dir = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data")); var store = new JsonStore <EventDescriptor>(dir, "store", "events"); container.Register <IDataStore <EventDescriptor>, JsonStore <EventDescriptor> >(store); container.Register <IStore>(new Store(store, new JsonSerializer())); }
public DroneService() { this.log = DroneLogManager.GetLog(); this.store = new JsonStore(); this.compiler = new DroneCompiler(); this.loader = new DroneLoader(); this.taskRunner = new DroneTaskRunner(new DroneTaskHandlerFactory()); }
public VehicleRepository(JsonStore<Vehicle> storage) { if (storage == null) { throw new ArgumentException("JsonStore"); } Storage = storage; AllItems = new BiggyList<Vehicle>(Storage); }
public void InitializeTest() { var migrationHandlerProvider = new DefaultMigrationHandlerProvider(); migrationHandlerProvider.AddMigrationHandler(new V1DtoMigrationHandler()); migrationHandlerProvider.AddMigrationHandler(new V2DtoMigrationHandler()); JsonStore.ConfigureMigrationHandlerProvider(migrationHandlerProvider); }
public void testSet() { con = JsonStore.Create(new ResourcesIO("LibUnity.DataStoreTest/environment")); con.Set <long>("test_config.var1", 10000); Assert(con.Get <long>("test_config.var1") == 10000, "get test_config.var1 is 10000"); con.Set <long>("test_config.var2", 10); Assert(con.Get <long>("test_config.var2") == 10, "get test_config.var1 is 10000"); }
public JsonStoreWithNoFile() { _fileName = Guid.NewGuid().ToString(); var options = new JsonStoreOptions { NamingStrategy = new StaticNamingStrategy(_fileName) }; _store = new JsonStore <Person>(options); }
// Default constructor public Manager() { // Path to the app's read-write file system location var localData = HttpContext.Current.Server.MapPath("~/App_Data"); // Open (or create) the data store store = new JsonStore <PersonFull>(localData, "company", "persons"); // Assign (or create) the collection(s) persons = new BiggyList <PersonFull>(store); }
private void load(JsonStore jsonStore, TileStore textureStore) { TileAtlas tileAtlas = new TileAtlas(textureStore, jsonStore, "Json/tiles.json"); Add(new TileAtlasWindow { State = Visibility.Visible, TileAtlas = tileAtlas, }); }
public void MigratingV1ToVXWithNoUpgradePath_ShouldThrowAnException() { //Arrange: var v1 = new V1Dto(5, "String Value"); var v1Json = JsonStore.Serialize(v1); Action action = () => JsonStore.Deserialize <VXDto>(v1Json); //Act: action.Should().Throw <InvalidOperationException>(); }
// Default constructor public Manager() { // Path to the app's read-write file system location var localData = HttpContext.Current.Server.MapPath("~/App_Data"); // Open (or create) the data store store = new JsonStore<PersonFull>(localData, "company", "persons"); // Assign (or create) the collection(s) persons = new BiggyList<PersonFull>(store); }
public void OnNext() { if (matchIndex < matchIDs.Length - 1) { matchIndex += 1; var jsonStr = JsonStore.Load(JsonStore.SaveTag.Score, matchIDs[matchIndex]); board = MatchScoreboard.FromJson(jsonStr); ShowBoard(); } }
public void OnPrevious() { if (matchIndex > 0) { matchIndex -= 1; var jsonStr = JsonStore.Load(JsonStore.SaveTag.Score, matchIDs[matchIndex]); board = MatchScoreboard.FromJson(jsonStr); ShowBoard(); } }
public void TestGetFailed() { con = JsonStore.Create(new ResourcesIO("LibUnity.DataStoreTest/environment")); Assert(!IsGetSuccess <string>(con, "test_config2.var"), "exception when wrong config name"); Assert(IsGetSuccess <int>(con, "test_config.var1"), "success when valid type"); Assert(!IsGetSuccess <string>(con, "test_config.var1"), "exception when wrong type"); Assert(IsGetSuccess <double>(con, "test_config.var_float"), "success when cast enable type"); Assert(!IsGetSuccess <float>(con, "test_config.var_float"), "exception when wrong type"); Assert(!IsGetSuccess <string>(con, "test_config.var3333"), "exception when not exist path"); }
public void jsonStore_Inserts_range_of_records_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var myBatch = new List<InstrumentDocuments>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" }); } InstrumentStore.Add(myBatch); var companies = InstrumentStore.TryLoadData(); Assert.IsTrue(companies.Count == qtyToAdd); }
public void can_save_and_load() { using(var fs = new FileSystemTester()) { var set = new FileMetadataCache(); var store = new JsonStore(); var filename = "file-change-set.json"; fs.Write(filename, s => store.Save(s, set)); fs.Read(filename, store.Load<FileMetadataCache>); } }
public void jsonStore_Updates_record_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var newInstrument = new InstrumentDocuments { Id = "USA456", Category = "String", Type = "Guitar" }; InstrumentStore.Add(newInstrument); // Now go fetch the record again and update: string newType = "Banjo"; var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault(i => i.Id == "USA456"); foundInstrument.Type = newType; InstrumentStore.Update(foundInstrument); Assert.IsTrue(foundInstrument != null && foundInstrument.Type == newType); }
public void jsonStore_Deletes_record_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var newInstrument = new InstrumentDocuments { Id = "USA789", Category = "String", Type = "Guitar" }; InstrumentStore.Add(newInstrument); // Load from back-end: var companies = InstrumentStore.TryLoadData(); int qtyAdded = companies.Count; // Delete: var foundInstrument = companies.FirstOrDefault(i => i.Id == "USA789"); InstrumentStore.Delete(foundInstrument); int remaining = InstrumentStore.TryLoadData().Count; Assert.IsTrue(qtyAdded == 1 && remaining == 0); }
public void jsonStore_Updates_range_of_records_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var myBatch = new List<InstrumentDocuments>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" }); } InstrumentStore.Add(myBatch); // Re-load, and update: var companies = InstrumentStore.TryLoadData(); for (int i = 0; i < qtyToAdd; i++) { companies.ElementAt(i).Type = "Banjo " + i; } InstrumentStore.Update(companies); // Reload, and check updated names: companies = InstrumentStore.TryLoadData().Where(c => c.Type.StartsWith("Banjo")).ToList(); Assert.IsTrue(companies.Count == qtyToAdd); }
public void modifiying_file_in_set_causes_has_changes_to_return_true() { using (var fs = new FileSystemTester()) { var set = new FileMetadataCache(); var store = new JsonStore(); var filename = "file-change-set.json"; var file = fs.Touch("file.txt"); set.Add(file); fs.Write(filename, s => store.Save(s, set)); var loadedSet = fs.Read(filename, store.Load<FileMetadataCache>); Assert.IsFalse(loadedSet.HasChanges()); fs.Touch(file.FullName); Assert.IsTrue(loadedSet.HasChanges()); } }
public DroneCompiler() { this.log = DroneLogManager.GetLog(); this.store = new JsonStore(); }
public void jsonStore_Deletes_range_of_records_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var myBatch = new List<InstrumentDocuments>(); int qtyToAdd = 10; for (int i = 0; i < qtyToAdd; i++) { myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" }); } InstrumentStore.Add(myBatch); // Re-load from back-end: var companies = InstrumentStore.TryLoadData(); int qtyAdded = companies.Count; // Select 5 for deletion: int qtyToDelete = 5; var deleteThese = new List<InstrumentDocuments>(); for (int i = 0; i < qtyToDelete; i++) { deleteThese.Add(companies.ElementAt(i)); } // Delete: InstrumentStore.Delete(deleteThese); int remaining = InstrumentStore.TryLoadData().Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete); }
public static void Main(string[] args) { var sw = new Stopwatch(); sw.Start(); var itemStore = new JsonStore<Client>(); sw.Stop(); Console.WriteLine("Initialized new Json store in {0} ms", sw.ElapsedMilliseconds); itemStore.DeleteAll(); int qtyToAdd = 1000; var newItems = new List<Client>(); for (int i = 0; i < qtyToAdd; i++) { newItems.Add(new Client { ClientId = i, FirstName = "First Name " + i, LastName = "Last Name " + i, Email = "sender" + i + "@Example.com" }); } var singleItem = newItems.ElementAt(0); sw.Reset(); sw.Start(); itemStore.Add(singleItem); sw.Stop(); Console.WriteLine("Inserted single item in {0} ms", sw.ElapsedMilliseconds); int savedId = singleItem.ClientId; sw.Reset(); sw.Start(); var savedItems = itemStore.TryLoadData(); sw.Stop(); Console.WriteLine("Loaded {0} items in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); singleItem = savedItems.FirstOrDefault(itm => itm.ClientId == savedId); singleItem.LastName = "Updated Last"; singleItem.FirstName = "Updated First"; singleItem.Email = "*****@*****.**"; sw.Reset(); sw.Start(); itemStore.Update(singleItem); sw.Stop(); Console.WriteLine("Updated single item in {0} ms", sw.ElapsedMilliseconds); var notReferenceEqualItem = new Client { ClientId = singleItem.ClientId, FirstName = "Copy First", LastName = "Copy Last", Email = "Copy Email" }; sw.Reset(); sw.Start(); itemStore.Update(notReferenceEqualItem); sw.Stop(); Console.WriteLine("Updated copy of single item in {0} ms", sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); savedItems = itemStore.TryLoadData(); sw.Stop(); Console.WriteLine("Loaded {0} items in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); singleItem = savedItems.FirstOrDefault(itm => itm.ClientId == savedId); sw.Reset(); sw.Start(); itemStore.Delete(singleItem); sw.Stop(); Console.WriteLine("Deleted single item in {0} ms", sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); itemStore.Add(newItems); sw.Stop(); Console.WriteLine("Inserted {0} item in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); savedItems = itemStore.TryLoadData(); sw.Stop(); Console.WriteLine("Loaded {0} items in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); foreach (var item in savedItems) { int itemIndex = savedItems.IndexOf(item); item.LastName = string.Format("Updated Last {0}", itemIndex); item.FirstName = string.Format("Updated First {0}", itemIndex); item.Email = string.Format("Updated email {0}", itemIndex); } sw.Reset(); sw.Start(); itemStore.Update(savedItems); sw.Stop(); Console.WriteLine("Updated {0} items in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); savedItems = itemStore.TryLoadData(); sw.Stop(); Console.WriteLine("Loaded {0} updated items in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); itemStore.Delete(savedItems); sw.Stop(); Console.WriteLine("Deleted {0} updated items in {1} ms", savedItems.Count, sw.ElapsedMilliseconds); Console.Read(); }
public void init() { _propertyStore = new JsonStore<Property>(); string path = _propertyStore.DbPath; File.Delete(path); }
public void jsonStore_Deletes_all_records_with_string_id() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); var myBatch = new List<InstrumentDocuments>(); int qtyToAdd = 10; for (int i = 0; i < qtyToAdd; i++) { myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" }); } InstrumentStore.Add(myBatch); // Re-load from back-end: var companies = InstrumentStore.TryLoadData(); int qtyAdded = companies.Count; // Delete: InstrumentStore.DeleteAll(); int remaining = InstrumentStore.TryLoadData().Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0); }
public void init() { var InstrumentStore = new JsonStore<InstrumentDocuments>(); string filePath = InstrumentStore.DbPath; File.Delete(filePath); }
public CityJsonRepository(JsonDbCore dbCore) { var store = new JsonStore<CityModel>(dbCore); this._cities = new BiggyList<CityModel>(store); }