public void TestPerformance() { var server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=performancetest.dat") { IdentifyableTechnicalName = "server" }; var client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; var svc = new ServicesManager(); svc.Start(); svc.AddService(server); svc.AddService(client); svc.StartServices(); var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000; i++) { User user = new User("User" + i, "Password", "*****@*****.**"); client.Db.Store(user); } client.Db.Commit(); sw.Stop(); svc.Stop(); }
public void RemoveRole(Db4OStorageClient storage) { // adds an authorization for the current object. var record = from AuthorizationRole p in storage.Db where (p.Role == _role) select p; if (record.Count() == 0) { throw new Exception(string.Format("can't role {0} as it does not exist.", _role)); } storage.Db.Store(this); storage.Db.Commit(); }
public void SetUp() { server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=performancetest.dat") { IdentifyableTechnicalName = "server" }; client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; svc = new ServicesManager(); svc.Start(); svc.AddService(server); svc.AddService(client); svc.StartServices(); }
static Database() { Server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=performancetest.dat") { IdentifyableTechnicalName = "server" }; Storage = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; var svc = new ServicesManager(); svc.Start(); svc.AddService(Server); svc.AddService(Storage); svc.StartServices(); }
public void SaveActionObjectTest() { var server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4573;file=actionstorage.dat") { IdentifyableTechnicalName = "server" }; server.Start(); var client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4573;server=localhost") { IdentifyableTechnicalName = "client" }; client.Start(); var fx = new ACMatFx(); fx.Blend = TextureBlendType.SourceAlphaSaturation; fx.Type = MatFxType.DualTexturingCamera; ToActionLiteralPart(fx); client.Db.Store(fx); client.Db.Commit(); client.Stop(); server.Stop(); }
public void TestAuthorization() { var server = new Db4OStorageServer("provider=db4o;user=awmanaged;password=awmanaged;port=4572;file=authorization.dat") { IdentifyableTechnicalName = "server" }; var client = new Db4OStorageClient("provider=db4o;user=awmanaged;password=awmanaged;port=4572;server=localhost") { IdentifyableTechnicalName = "client" }; var svc = new ServicesManager(); svc.Start(); svc.AddService(server); svc.AddService(client); svc.Start(); var records = from User p in client.Db where p.NameToLower == "unittest" select p; User user; if (records.Count() == 0) { user = new User("unittest", "unittest", "*****@*****.**"); var result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.Success); result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.UserExists); var user2 = new User("unittest2", "unittest", "*****@*****.**"); result = user2.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.EmailExists); } else { user = records.Single(); var result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.UserExists); user = new User("unittest2", "unittest", "*****@*****.**"); result = user.RegisterUser(client.Db); Assert.IsTrue(result == RegistrationResult.EmailExists); user = records.Single(); } Assert.IsTrue(user.IsAuthenticated(client.Db)); user = new User("unittest", "wrongpass"); Assert.IsFalse(user.IsAuthenticated(client.Db)); records = from User p in client.Db where p.NameToLower == "unittest" select p; user = records.Single(); var auth = new Authorization <User>(client.Db, user, "administrator"); auth.AddAuthorization(); Assert.IsTrue(auth.HasAuthorization()); auth.RemoveAuthorization(); auth = new Authorization <User>(client.Db, user, "backup-operator"); Assert.IsFalse(auth.HasAuthorization()); auth.AddAuthorization(); Assert.IsTrue(auth.HasAuthorization()); var roles = Authorization <User> .GetAuthorizations(client, user); Assert.IsTrue(roles.Count == 1 && roles[0] == "backup-operator"); auth.RemoveAuthorization(); svc.Stop(); }