Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var host = ConfigurationManager.AppSettings["host"];
            var port = Convert.ToUInt16(ConfigurationManager.AppSettings["port"]);

            var wsConf = new WilmaServiceConfig(host, port);
            var ws = new WilmaService(wsConf, new Logger());

            ws.GetVersionInformationAsync().ContinueWith(res => { Console.WriteLine(res.Result); });
            ws.GetActualLoadInformationAsync().ContinueWith(res => { Console.WriteLine(res.Result); });
            ws.GetMessageLoggingStatusAsync().ContinueWith(res => { Console.WriteLine(res.Result); });

            ws.SetMessageLoggingStatusAsync(WilmaService.MessageLoggingControlStatus.On).ContinueWith(res => { if (res.Result) { ws.GetMessageLoggingStatusAsync().ContinueWith(res1 => { Console.WriteLine(res1.Result); }); } });

            ws.SetOperationModeAsync(WilmaService.OperationModes.WILMA).ContinueWith(res1 => { ws.GetOperationModeAsync().ContinueWith(res => { Console.WriteLine(res.Result); }); });

            ws.SetLocalhostBlockingStatusAsync(WilmaService.LocalhostControlStatuses.On).ContinueWith(res1 => { ws.GetLocalhostBlockingStatusAsync().ContinueWith(res => { Console.WriteLine(res.Result); }); });

            ws.GetStubConfigInformationAsync().ContinueWith(res => { Console.WriteLine(res.Result); });

            ws.ChangeStubConfigStatusAsync("EPAMNEWS", WilmaService.StubConfigStatus.Enabled).ContinueWith(res => { Console.WriteLine(res.Result); });
            ws.ChangeStubConfigOrderAsync("EPAMNEWS", WilmaService.StubConfigOrder.Up).ContinueWith(res => { Console.WriteLine(res.Result); });
            ws.DropStubConfigAsync("EPAMNEWS").ContinueWith(res => { Console.WriteLine(res.Result); });

            ws.PersistActualStubConfigAsync().ContinueWith(res => { Console.WriteLine(res.Result); });

            Upload(@"trial", ws.UploadConditionCheckerAsync).ContinueWith(res => { Console.WriteLine(res.Result); });
            Upload(@"trial", ws.UploadTemplateAsync).ContinueWith(res => { Console.WriteLine(res.Result); });
            Upload(@"trial", ws.UploadTemplateFormatterAsync).ContinueWith(res => { Console.WriteLine(res.Result); });
            Upload(@"trial", ws.UploadStubConfigurationAsync).ContinueWith(res => { Console.WriteLine(res.Result); });

            // ws.ShutdownApplicationAsync().ContinueWith(res => { Console.WriteLine("Wilma shuted down: {0}", res.Result);});

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void GivenHostAndPort_CreateWilmaServiceConfig_StoredHostAndPortEqual()
        {
            var host = "alma.hu";
            ushort port = 9875;
            var res = new WilmaServiceConfig(host, port);

            res.Host.ShouldBeEquivalentTo(host);
            res.Port.ShouldBeEquivalentTo(port);
        }
Exemplo n.º 3
0
        /// <summary>
        /// WilmaService constructor.
        /// </summary>
        /// <param name="config">WilmaServiceConfig stores host and port.</param>
        /// <param name="logger">Object implements ILogger interface, this methods are called for logging.</param>
        /// <param name="httpClient">HttpClient.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when config or logger is null.</exception>
        public WilmaService(WilmaServiceConfig config, ILogger logger, HttpClient httpClient)
        {
            _logger = logger;
            if (_logger == null)
            {
                throw new ArgumentNullException("ILogger is null.");
            }
            _logger.Info("WilmaService created.");

            if (config == null)
            {
                _logger.Error("WilmaServiceConfig is NULL.");
                throw new ArgumentNullException("WilmaServiceConfig is NULL.");
            }

            _config     = config;
            _httpClient = httpClient;
        }
Exemplo n.º 4
0
 /// <summary>
 /// WilmaService constructor.
 /// </summary>
 /// <param name="config">WilmaServiceConfig stores host and port.</param>
 /// <param name="logger">Object implements ILogger interface, this methods are called for logging.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when config or logger is null.</exception>
 public WilmaService(WilmaServiceConfig config, ILogger logger)
     : this(config, logger, new HttpClient())
 {
 }
Exemplo n.º 5
0
        /// <summary>
        /// WilmaService constructor.
        /// </summary>
        /// <param name="config">WilmaServiceConfig stores host and port.</param>
        /// <param name="logger">Object implements ILogger interface, this methods are called for logging.</param>
        /// <param name="httpClient">HttpClient.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when config or logger is null.</exception>
        public WilmaService(WilmaServiceConfig config, ILogger logger, HttpClient httpClient)
        {
            _logger = logger;
            if (_logger == null)
            {
                throw new ArgumentNullException("ILogger is null.");
            }
            _logger.Info("WilmaService created.");

            if (config == null)
            {
                _logger.Error("WilmaServiceConfig is NULL.");
                throw new ArgumentNullException("WilmaServiceConfig is NULL.");
            }

            _config = config;
            _httpClient = httpClient;
        }
Exemplo n.º 6
0
        public void NoILogger_WilmaServiceCreate_ThrowArgumentNullException()
        {
            var wsc = new WilmaServiceConfig("host", 1);

            Action ac = () => { new WilmaService(wsc, (ILogger)null); };
            ac.ShouldThrow<ArgumentNullException>();
        }
Exemplo n.º 7
0
 /// <summary>
 /// WilmaService constructor.
 /// </summary>
 /// <param name="config">WilmaServiceConfig stores host and port.</param>
 /// <param name="logger">Object implements ILogger interface, this methods are called for logging.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when config or logger is null.</exception>
 public WilmaService(WilmaServiceConfig config, ILogger logger)
     : this(config, logger, new HttpClient())
 {
 }