Example #1
0
 public void SetUp()
 {
     server = new AmbienceServer(new AmbienceServerConfiguration()
     {
         Port = PortNumber,
         DatabasePath = "AmbientTest.db",
         Credential = { UserName = UserName, Password = Password }
     });
     server.Start();
 }
Example #2
0
 public void SetUp()
 {
     server = new AmbienceServer(new AmbienceServerConfiguration()
     {
         Port         = PortNumber,
         DatabasePath = "AmbientTest.db",
         Credential   = { UserName = UserName, Password = Password }
     });
     server.Start();
 }
Example #3
0
        public void SetUp()
        {
            File.Delete("AmbienceClientTest.db");

            server = new AmbienceServer(new AmbienceServerConfiguration()
            {
                Port         = PortNumber,
                DatabasePath = "AmbienceClientTest.db"
            });
            server.Start();
        }
        public void SetUp()
        {
            File.Delete("AmbienceClientTest.db");

            server = new AmbienceServer(new AmbienceServerConfiguration()
            {
                Port = PortNumber,
                DatabasePath = "AmbienceClientTest.db"
            });
            server.Start();
        }
Example #5
0
        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 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"));
            }
        }
Example #7
0
        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 = "******" }
                }));
            }
        }
Example #8
0
        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"));
            }
        }
Example #9
0
        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 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 } }));
            }
        }
Example #14
0
 protected override void OnStart(string[] args)
 {
     server = new AmbienceServer(configuration);
     server.Start();
 }
Example #15
0
 protected override void OnStart(string[] args)
 {
     server = new AmbienceServer(configuration);
     server.Start();
 }