Ejemplo n.º 1
0
        private static EmsApiServiceConfiguration GetInvalidLoginConfig()
        {
            EmsApiServiceConfiguration config = m_config.Clone();

            config.UserName = string.Format("Inv@lidUser{0}", Guid.NewGuid());
            return(config);
        }
Ejemplo n.º 2
0
        static TestBase()
        {
            string endpoint = Environment.GetEnvironmentVariable("EmsApiTestEndpoint");

            if (string.IsNullOrEmpty(endpoint))
            {
                throw new InvalidOperationException("Test API Endpoint not set");
            }

            string user = Environment.GetEnvironmentVariable("EmsApiTestUsername");

            if (string.IsNullOrEmpty(user))
            {
                throw new InvalidOperationException("Test API Username not set");
            }

            string pass = Environment.GetEnvironmentVariable("EmsApiTestPassword");

            if (string.IsNullOrEmpty(pass))
            {
                throw new InvalidOperationException("Test API Password not set");
            }

            m_config = new EmsApiServiceConfiguration(useEnvVars: false)
            {
                Endpoint = endpoint,
                UserName = user,
                Password = pass
            };
        }
Ejemplo n.º 3
0
        public void Invalid_configuration_should_throw_exception()
        {
            var service   = new EmsApiService();
            var badConfig = new EmsApiServiceConfiguration()
            {
                UserName = string.Empty,
                Password = null
            };

            Action setConfig = () => service.ServiceConfig = badConfig;

            setConfig.Should().ThrowExactly <EmsApiConfigurationException>();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello from .NET core.");
            var config = new EmsApiServiceConfiguration();

            // Allow the user to override the endpoint, but provide a default.
            Console.Write("Enter Endpoint URL [{0}]: ", config.Endpoint);
            string endpoint = Console.ReadLine();

            if (!string.IsNullOrEmpty(endpoint))
            {
                config.Endpoint = endpoint;
            }

            Console.Write("Enter Username [{0}]: ", config.UserName);
            string user = Console.ReadLine();

            if (!string.IsNullOrEmpty(user))
            {
                config.UserName = user;
            }

            string defaultPw = !string.IsNullOrEmpty(config.Password) ? "********" : string.Empty;

            Console.Write("Enter Password [{0}]: ", defaultPw);
            string password = Console.ReadLine();

            if (!string.IsNullOrEmpty(password))
            {
                config.Password = password;
            }

            using (var api = new EmsApiService(config))
            {
                // List all the connected EMS systems on the command line.
                foreach (EmsSystem ems in api.EmsSystems.GetAll())
                {
                    // Retrieve server details about the system.
                    EmsSystemInfo server = api.EmsSystems.GetSystemInfo(ems.Id.Value);
                    Console.WriteLine(string.Format("{0} - {1} - {2} - EMS version {3} - {4}", ems.Id, ems.Name, ems.Description, server.ServerVersion, server.UtcTimeStamp));
                }
            }

            Console.WriteLine("Press any key to close...");
            Console.ReadKey();
        }
Ejemplo n.º 5
0
        private static EmsApiServiceConfiguration ShowConnectionDialog()
        {
            var config    = new EmsApiServiceConfiguration();
            var viewModel = new LoginViewModel
            {
                Endpoint = config.Endpoint,
                Username = config.UserName,
                Password = config.Password
            };

            var  login  = new LoginView(viewModel);
            bool?result = login.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return(null);
            }

            config.Endpoint = viewModel.Endpoint;
            config.UserName = viewModel.Username;
            config.Password = viewModel.Password;
            return(config);
        }