우리 프로젝트에서 Db4o를 사용하고 있습니다.자동 테스트 용 Db4o 데이터베이스
테스트 된 오브젝트의 지속성에 대한 자동 테스트가 있습니다. 문제는 데이터베이스를 두 번 열거 나 만들 수 없다는 것입니다. 개체 컨테이너를 가져 오는 두 가지 도우미 메서드가 있습니다. 그러나 메서드가 두 번째 호출 될 때 "ArgumentException : 구성이 이미 사용되었습니다." 던졌습니다. 이전의 객체 보관소를 닫고 처리했습니다.
내가 뭘 잘못 했니?
CODE : 당신은 더 이상 사용되지 db4o는 방법을 사용하는
public static IObjectContainer GetEmptyTestingDatabase() {
var tempDir = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
string dbFilePath = Path.Combine(tempDir, "UNIT-TESTING.db4o");
if (File.Exists(dbFilePath)) {
File.Delete(dbFilePath);
}
var cfg = Db4oFactory.Configure();
cfg.Add(new TransparentPersistenceSupport(new DeactivatingRollbackStrategy()));
cfg.Add(new TransparentActivationSupport());
var db = Db4oFactory.OpenFile(cfg, dbFilePath);
return db;
}
public static IObjectContainer GetMemoryDatabase() {
string dbFileName = Guid.NewGuid().ToString().ToString();
var cfg = Db4oFactory.Configure();
cfg.Storage = new Db4objects.Db4o.IO.PagingMemoryStorage();
cfg.Add(new TransparentPersistenceSupport(new DeactivatingRollbackStrategy()));
cfg.Add(new TransparentActivationSupport());
var db = Db4oFactory.OpenFile(cfg, dbFileName);
return db;
}
감사! 나는 오래된 예를보아야 만한다. – TcKs