Esempio n. 1
0
        public WrapperService CreateSingleService(ServiceENT Obj)
        {
            WrapperService data = new WrapperService();

            data.Service = new ServiceCRUD().CreateSingle(Obj);
            return(data);
        }
Esempio n. 2
0
 internal static void RequireProcessElevated()
 {
     if (!WrapperService.IsProcessElevated())
     {
         Assert.Ignore();
     }
 }
Esempio n. 3
0
        public WrapperService GetSingleService(int id)
        {
            WrapperService data = new WrapperService();

            data.Service = new ServiceCRUD().SelectSingle(id);
            return(data);
        }
Esempio n. 4
0
        public void ReplyTest()
        {
            var reply = new WrapperService().WrapText(new WrapRequest {
                Text = "slowo slowo2 slowo3", NCol = 8
            }, null !);

            Assert.Equal("slowo sl\nowo2 slo\nwo3\n", reply.Result.Text);
        }
Esempio n. 5
0
        /// <summary>
        /// Runs a simle test, which returns the output CLI
        /// </summary>
        /// <param name="args">CLI arguments to be passed</param>
        /// <param name="descriptor">Optional Service descriptor (will be used for initializationpurposes)</param>
        /// <returns>STDOUT if there's no exceptions</returns>
        /// <exception cref="Exception">Command failure</exception>
        public static string CLITest(string[] args, ServiceDescriptor descriptor = null)
        {
            using StringWriter sw = new StringWriter();
            TextWriter tmp = Console.Out;

            Console.SetOut(sw);
            WrapperService.Run(args, descriptor ?? DefaultServiceDescriptor);
            Console.SetOut(tmp);
            Console.Write(sw.ToString());
            return(sw.ToString());
        }
Esempio n. 6
0
        public EventLog locate()
        {
            WrapperService _service = service;

            if (_service != null && !_service.IsShuttingDown)
            {
                return(_service.EventLog);
            }

            // By default return null
            return(null);
        }
Esempio n. 7
0
 public static string CLITest(String[] args, ServiceDescriptor descriptor = null)
 {
     using (StringWriter sw = new StringWriter())
     {
         Arguments arguments = new Arguments();
         arguments.Action = args[0];
         TextWriter tmp = Console.Out;
         Console.SetOut(sw);
         WrapperService.Run(arguments, descriptor ?? DefaultServiceDescriptor);
         Console.SetOut(tmp);
         Console.Write(sw.ToString());
         return(sw.ToString());
     }
 }
Esempio n. 8
0
        public IActionResult CreatService([FromBody] WrapperService Param)
        {
            #region Validate Token
            RequestResponse isAuthorized = new Authorize().RequestTokenAuth(Request);
            if (isAuthorized.Success == false)
            {
                return(BadRequest(isAuthorized));
            }
            #endregion



            WrapperService data = new Services.ServiceService().CreateSingleService(Param.Service);

            return(Ok(data));
        }
Esempio n. 9
0
        public static CLITestResult CLIErrorTest(String[] args, ServiceDescriptor descriptor = null)
        {
            Arguments arguments = new Arguments();

            arguments.Action = args[0];
            StringWriter swOut, swErr;
            Exception    testEx = null;
            TextWriter   tmpOut = Console.Out;
            TextWriter   tmpErr = Console.Error;

            using (swOut = new StringWriter())
                using (swErr = new StringWriter())
                    try
                    {
                        Console.SetOut(swOut);
                        Console.SetError(swErr);
                        WrapperService.Run(arguments, descriptor ?? DefaultServiceDescriptor);
                    }
                    catch (Exception ex)
                    {
                        testEx = ex;
                    }
            finally
            {
                Console.SetOut(tmpOut);
                Console.SetError(tmpErr);
                Console.WriteLine("\n>>> Output: ");
                Console.Write(swOut.ToString());
                Console.WriteLine("\n>>> Error: ");
                Console.Write(swErr.ToString());
                if (testEx != null)
                {
                    Console.WriteLine("\n>>> Exception: ");
                    Console.WriteLine(testEx);
                }
            }

            return(new CLITestResult(swOut.ToString(), swErr.ToString(), testEx));
        }
Esempio n. 10
0
        /// <summary>
        /// Runs a simle test, which returns the output CLI
        /// </summary>
        /// <param name="arguments">CLI arguments to be passed</param>
        /// <param name="descriptor">Optional Service descriptor (will be used for initializationpurposes)</param>
        /// <returns>STDOUT if there's no exceptions</returns>
        /// <exception cref="Exception">Command failure</exception>
        public static string CLITest(string[] arguments, ServiceDescriptor descriptor = null)
        {
            TextWriter tmpOut = Console.Out;
            TextWriter tmpErr = Console.Error;

            using StringWriter swOut = new StringWriter();
            using StringWriter swErr = new StringWriter();

            Console.SetOut(swOut);
            Console.SetError(swErr);
            try
            {
                WrapperService.Run(arguments, descriptor ?? DefaultServiceDescriptor);
            }
            finally
            {
                Console.SetOut(tmpOut);
                Console.SetError(tmpErr);
            }

            Assert.That(swErr.GetStringBuilder().Length, Is.Zero);
            Console.Write(swOut.ToString());
            return(swOut.ToString());
        }
Esempio n. 11
0
        public void GetParameterTest()
        {
            String expectedUsername = "******";

            Assert.AreEqual(expectedUsername, WrapperService.GetParameterByName("-username:pretenduser", "-username:"));
        }