public void AddTwoEntityInFile() { // Arrange FileHelper.DeleteFile(_filePath); var engine = new EngineDb(_filePath); var firstCar = Car.Create(2007, "Renault"); var secondCar = Car.Create(2018, "Audi"); // Act engine.AddEntity(firstCar); engine.AddEntity(secondCar); engine.SaveAll(); Car[] results = new Car[2]; results[0] = engine.Find <Car>(1); results[1] = engine.Find <Car>(2); // Assert Assert.NotNull(results[0]); Assert.Equal("Renault", results[0].Brand); Assert.NotNull(results[1]); Assert.Equal("Audi", results[1].Brand); }
static void Main(string[] args) { // Arrange if (File.Exists(_filePath)) { File.Delete(_filePath); } var engine = new EngineDb(_filePath); Task task1 = Task.Factory.StartNew(() => { for (int i = 0; i < 10000; i++) { var car = Car.Create(i, "Audi"); // Act engine.AddEntity(car); } }); Task task2 = Task.Factory.StartNew(() => { for (int i = 0; i < 10000; i++) { var car = Car.Create(i, "Renauld"); // Act engine.AddEntity(car); } }); Task.WaitAll(task1, task2); engine.SaveAll(); Car[] results = new Car[2]; results[0] = engine.Find <Car>(1); results[1] = engine.Find <Car>(2); }
public void AddEntityInFile() { // Arrange FileHelper.DeleteFile(_filePath); var engine = new EngineDb(_filePath); var firstCar = Car.Create(2007, "Renault"); // Act engine.AddEntity(firstCar); engine.SaveAll(); var entity1Result = engine.Find <Car>(1); // Assert Assert.NotNull(entity1Result); }
public void LargeAddRead() { // Arrange FileHelper.DeleteFile(_filePath); var engine = new EngineDb(_filePath); for (int i = 0; i < 1000; i++) { var car = Car.Create(i, "Audi"); // Act engine.AddEntity(car); } engine.SaveAll(); Car[] results = new Car[2]; results[0] = engine.Find <Car>(1); results[1] = engine.Find <Car>(2); }