public void SetUp() { server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = "AmbientTest.db", Credential = { UserName = UserName, Password = Password } }); server.Start(); }
public void SetUp() { File.Delete("AmbienceClientTest.db"); server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = "AmbienceClientTest.db" }); server.Start(); }
public void ServerStoresDbInSpecifiedLocation() { File.Delete("AmbienceClientTest.db"); using (AmbienceServer server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = "AmbienceClientTest.db" })) { server.Start(); Assert.IsTrue(File.Exists("AmbienceClientTest.db")); } }
public void ServerGrantsAccessToAuthorizedUser() { File.Delete("AmbienceClientTest.db"); using (AmbienceServer server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = @"AmbienceClientTest.db", Credential = { UserName = "******", Password = "******" } })) { server.Start(); Assert.DoesNotThrow(() => AmbienceClient.Connect(new AmbienceClientConfiguration() { Port = PortNumber, Credential = { UserName = "******", Password = "******" } })); } }
public void ServerCreatesDbFolderWhenNeeded() { if (Directory.Exists("DbFolder")) { Directory.Delete("DbFolder", true); } using (AmbienceServer server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = @"DbFolder\AmbienceClientTest.db" })) { server.Start(); Assert.IsTrue(Directory.Exists("DbFolder")); Assert.IsTrue(File.Exists(@"DbFolder\AmbienceClientTest.db")); } }
public void ServerDeniesAccessToUnauthorizedUser(string userName, string password) { File.Delete("AmbienceClientTest.db"); using (AmbienceServer server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = @"AmbienceClientTest.db", Credential = { UserName = "******", Password = "******" } })) { server.Start(); Assert.Throws <AmbienceException>(() => AmbienceClient.Connect(new AmbienceClientConfiguration() { Port = PortNumber, Credential = { UserName = userName, Password = password } })); } }
private int RunAsApplication(AmbienceServerConfiguration configuration) { ManualResetEvent waitHandle = new ManualResetEvent(false); Console.Cancel += delegate { waitHandle.Set(); }; Console.IsCancelationEnabled = true; ShowBanner(); using (AmbienceServer server = new AmbienceServer(configuration)) { Console.WriteLine("Starting..."); server.Start(); Console.WriteLine("Running... (Press Ctrl-C to stop)"); waitHandle.WaitOne(); Console.WriteLine("Stopping..."); server.Stop(); Console.WriteLine("Stopped."); } return(ResultCode.Success); }
public void ServerCreatesDbFolderWhenNeeded() { if (Directory.Exists("DbFolder")) Directory.Delete("DbFolder", true); using (AmbienceServer server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = @"DbFolder\AmbienceClientTest.db" })) { server.Start(); Assert.IsTrue(Directory.Exists("DbFolder")); Assert.IsTrue(File.Exists(@"DbFolder\AmbienceClientTest.db")); } }
public void ServerDeniesAccessToUnauthorizedUser(string userName, string password) { File.Delete("AmbienceClientTest.db"); using (AmbienceServer server = new AmbienceServer(new AmbienceServerConfiguration() { Port = PortNumber, DatabasePath = @"AmbienceClientTest.db", Credential = { UserName = "******", Password = "******" } })) { server.Start(); Assert.Throws<AmbienceException>(() => AmbienceClient.Connect(new AmbienceClientConfiguration() { Port = PortNumber, Credential = { UserName = userName, Password = password } })); } }
protected override void OnStart(string[] args) { server = new AmbienceServer(configuration); server.Start(); }