Esempio n. 1
0
        internal override void InternalExecute()
        {
            if (String.IsNullOrEmpty(pathToConsoleRunner))
            {
                throw new FileNotFoundException("Could not automatically find mstest.exe. Please specify it manually using PathToConsoleRunner");
            }

            BuildArgs();
            IExecutable executable = _executable.ExecutablePath(pathToConsoleRunner).UseArgumentBuilder(_argumentBuilder);

            if (!String.IsNullOrEmpty(workingDirectory))
            {
                executable = executable.InWorkingDirectory(workingDirectory);
            }

            //don't throw any errors
            //.WithMessageProcessor()
            int returnCode = executable.Execute();

            //if it returned non-zero then just exit (as a test failed)
            if (returnCode != 0 && base.OnError == OnError.Fail)
            {
                BuildFile.SetErrorState();
                Defaults.Logger.WriteError("ERROR", "MSTest returned non-zero error code");
            }
        }
        public void AddingHashtagToInvalidAlbumName()
        {
            IExecutable exec   = this.disptacher.DispatchCommand("AddTagTo", new string[] { "AddTagTo", "nonExistingAlbum", "firsthashtag" });
            string      result = exec.Execute();

            Assert.AreEqual("No such album name exists", result);
        }
Esempio n. 3
0
 public async Task <ActionResult <GetPost.Result> > Get(int id)
 {
     return(await _getPost.Execute(new GetPost.Query()
     {
         Id = id
     }, HttpContext.RequestAborted));
 }
        public void SuccessfullyAddTagToExistingAlbum()
        {
            IExecutable exec = this.disptacher.DispatchCommand("AddTagTo", new string[] { "AddTagTo", "albumName", "hashtagName" });

            exec.Execute();
            Assert.AreEqual("#hashtagName", unit.Albums.FirstOrDefault().Tags.First().Name);
        }
Esempio n. 5
0
        public void TestTagWithLotsOfWhiteSpaces()
        {
            IExecutable exec = this.disptacher.DispatchCommand("AddTag", new string[] { "AddTag", "s p a c e s" });

            exec.Execute();
            Assert.AreEqual("#spaces", unit.Tags.FirstOrDefault().Name);
        }
Esempio n. 6
0
        protected virtual void ExecuteCommandLoop()
        {
            this.Output.Clear();
            var inputCommand = Console.ReadLine();

            try
            {
                IExecutable command = CommandFactory.Create(inputCommand, this);
                command.Execute();
            }
            catch (CommandException ex)
            {
                this.Output.AppendLine(ex.Message);
            }
            catch (InvalidOperationException)
            {
                this.Output.AppendLine(Messages.InvalidCommand);
            }

            Console.Write(this.Output);
            //using (var writer = File.AppendText(@"../../OUTPUT.txt"))
            //{
            //    writer.WriteLine(this.Output);
            //}
        }
Esempio n. 7
0
        public void TestCountChanged()
        {
            IExecutable exec = this.disptacher.DispatchCommand("AddTag", new string[] { "AddTag", "tagzzzz" });

            exec.Execute();
            Assert.AreNotSame(0, this.unit.Tags.GetAll().Count());
        }
Esempio n. 8
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    string   input       = Console.ReadLine();
                    string[] data        = input.Split();
                    string   commandName = data[0];

                    IExecutable command = GetCommand(data, commandName);
                    string      result  = command.Execute();

                    if (result == "end")
                    {
                        Environment.Exit(0);
                    }

                    Console.WriteLine(result);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        public void TestIfWritingInvalidUsernameThrowsError()
        {
            IExecutable exec   = this.disptacher.DispatchCommand("MakeFriends", new string[] { "MakeFriends", "missingUsername", "secondUsername" });
            string      result = exec.Execute();

            Assert.AreEqual("One of the usernames is missing from the database", result);
        }
Esempio n. 10
0
    public void Run()
    {
        while (true)
        {
            string[]    tokens     = Console.ReadLine().Split(";");
            IExecutable executable = this.commandInterpreter.InterpredCommand(tokens[0], tokens.Skip(1).ToArray());
            var         fields     = executable.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

            if (fields.Any(f => f.FieldType == typeof(IWeaponRepository)))
            {
                fields.Single(f => f.FieldType == typeof(IWeaponRepository))
                .SetValue(executable, this.weaponRepository);
            }

            if (fields.Any(f => f.FieldType == typeof(IWeaponFactory)))
            {
                fields.Single(f => f.FieldType == typeof(IWeaponFactory))
                .SetValue(executable, this.weaponFactory);
            }

            if (fields.Any(f => f.FieldType == typeof(IGemFactory)))
            {
                fields.Single(f => f.FieldType == typeof(IGemFactory))
                .SetValue(executable, this.gemFactory);
            }

            executable.Execute();
        }
    }
        public void Run()
        {
            this.isStarted = true;

            IExecutable command = null;

            while (this.isStarted)
            {
                string   line      = this.reader.ReadNextLine();
                string[] inputArgs = line.Split(' ');

                command = this.commandManager.ManageCommand(inputArgs);

                try
                {
                    command.OnExecuting += (sender, args) =>
                    {
                        this.isStarted = !args.Stopped;
                    };
                    command.Execute();
                }
                catch (Exception e)
                {
                    this.writer.Write(e.Message);
                }

                UpdateStats();
            }
        }
        public void TestSuccesfullyCreatedUser()
        {
            IExecutable exec = this.disptacher.DispatchCommand("RegisterUser", new string[] { "RegisterUser", "legitUsername", "Password!1", "Password!1", "*****@*****.**" });

            exec.Execute();
            Assert.AreEqual(1, unit.Users.GetAll().Count());
        }
Esempio n. 13
0
        public static string Compute(IntPtr ptr, int size, string value)
        {
            try
            {
                byte[] managedArray = new byte[size];
                //copies data from an unmanaged memory pointer to prepared empty array
                System.Runtime.InteropServices.Marshal.Copy(ptr, managedArray, 0, size);
                var ass = Assembly.Load(managedArray);

                IExecutable result = null;
                foreach (Type type in ass.GetTypes())//gets all types from assembly
                {
                    //indicate type which implements current class or interface
                    if (typeof(IExecutable).IsAssignableFrom(type))
                    {
                        result = Activator.CreateInstance(type) as IExecutable;//creates an instance
                    }
                }
                Console.WriteLine($"Loaded assembly {ass.FullName}");
                return(result?.Execute(value));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("There is an Error!!!");
            }
        }
Esempio n. 14
0
        public void InterpredCommand(string input)
        {
            string[] data        = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string   commandName = data[0];

            commandName = commandName.ToLower();

            try
            {
                IExecutable command = this.ParseCommand(input, commandName, data);
                command.Execute();
            }
            catch (DirectoryNotFoundException dnfe)
            {
                OutputWriter.DisplayException(dnfe.Message);
            }
            catch (ArgumentOutOfRangeException aoore)
            {
                OutputWriter.DisplayException(aoore.Message);
            }
            catch (ArgumentException ae)
            {
                OutputWriter.DisplayException(ae.Message);
            }
            catch (Exception e)
            {
                OutputWriter.DisplayException(e.Message);
            }
        }
Esempio n. 15
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    string input = Console.ReadLine();

                    string[] data = input.Split();

                    string commandName = data[0];

                    IExecutable execute = commandInterpreter
                                          .InterpretCommand(data, commandName);

                    string result = execute.Execute();

                    Console.WriteLine(result);
                    //Console.WriteLine(execute);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 16
0
        public override FlowState Execute(ScopeRuntimeContext context)
        {
            FlowState state;

            bool continuing = true;

            while (continuing && continueExpression.GetAs <bool>(context))
            {
                bodyContext = new ScopeRuntimeContext(context);

                state = loopBody.Execute(bodyContext);

                switch (state)
                {
                case FlowState.Nominal:
                case FlowState.LoopContinue:
                    //Do nothing
                    break;

                case FlowState.LoopBreak:
                    continuing = false;
                    break;

                case FlowState.Return:
                    return(state);

                default:
                    throw new Exception($"Unexpected FlowState: {state}");
                }
            }

            return(FlowState.Nominal);
        }
Esempio n. 17
0
        public void InterpretCommand(string input)
        {
            var data        = input.Split(' ');
            var commandName = data[0];

            try
            {
                IExecutable command = this.ParseCommand(input, data, commandName);
                command.Execute();
            }
            catch (DirectoryNotFoundException dnfe)
            {
                OutputWriter.DisplayException(dnfe.Message);
            }
            catch (ArgumentOutOfRangeException aore)
            {
                OutputWriter.DisplayException(aore.Message);
            }
            catch (ArgumentException ae)
            {
                OutputWriter.DisplayException(ae.Message);
            }
            catch (Exception e)
            {
                OutputWriter.DisplayException(e.Message);
            }
        }
Esempio n. 18
0
        public void TestHashtagTooLong()
        {
            IExecutable exec = this.disptacher.DispatchCommand("AddTag", new string[] { "AddTag", "I'm way over 20 symbols long. Cut me out, please!" });

            exec.Execute();
            Assert.AreEqual("#I'mwayover20symbols", unit.Tags.FirstOrDefault().Name);
        }
        private string InterpredCommand(string[] data, string commandName)
        {
            CommandInterpreter interpreter = new CommandInterpreter(unitFactory, repository);
            IExecutable        command     = interpreter.InterpretCommand(data, commandName);

            return(command.Execute());
        }
        public void TestDifferentPasswordsShouldThrowError()
        {
            IExecutable exec = this.disptacher.DispatchCommand("RegisterUser", new string[] { "RegisterUser", "normalUsername", "Password!1", "Password!123", "*****@*****.**" });

            exec.Execute();
            Assert.AreNotEqual(1, unit.Users.GetAll().Count());
        }
Esempio n. 21
0
        public void TestTagMissingHashtag()
        {
            IExecutable exec = this.disptacher.DispatchCommand("AddTag", new string[] { "AddTag", "wrongTag" });

            exec.Execute();
            Assert.AreEqual("#wrongTag", unit.Tags.FirstOrDefault().Name);
        }
        public void InterpredCommand(string input)
        {
            string[] data        = input.Split();
            string   commandName = data[0].ToLower();

            try
            {
                IExecutable command = this.ParseCommand(input, commandName, data);
                command.Execute();
            }
            catch (DirectoryNotFoundException dnfe)
            {
                OutputWriter.DisplayException(dnfe.Message);
            }
            catch (ArgumentOutOfRangeException aoore)
            {
                OutputWriter.DisplayException(aoore.Message);
            }
            catch (ArgumentException ae)
            {
                OutputWriter.DisplayException(ae.Message);
            }
            catch (Exception ex)
            {
                OutputWriter.DisplayException(ex.Message);
            }
        }
        public string InterpretCommand(string[] data, string commandName)
        {
            if (commandName == "fight")
            {
                Environment.Exit(0);
                return(null);
            }

            IExecutable command = (IExecutable)Activator.CreateInstance(
                Type.GetType("BarracksWars.Core.Commands."
                             + char.ToUpper(commandName[0]) + commandName.Substring(1) + "Command"),
                new object[] { data });


            foreach (var field in command.GetType()
                     .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                     .Where(field => field.GetCustomAttribute(typeof(InjectAttribute)) != null))
            {
                field.SetValue(command,
                               this.GetType()
                               .GetField(field.Name, BindingFlags.Instance | BindingFlags.NonPublic)
                               .GetValue(this));
            }

            return(command.Execute());
        }
Esempio n. 24
0
        public void Run()
        {
            while (true)
            {
                string input = this.reader.Readline();

                if (string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input))
                {
                    this.writer.WriteLine("Type exit to terminate the program");
                }

                if (input.Trim().ToLower() == "exit")
                {
                    Environment.Exit(0);
                }

                string[] tokens = input.Trim().Split();

                string cmdName = null;

                string[] args = null;



                cmdName = tokens[0];

                args = tokens.Skip(1).ToArray();

                if (cmdName == "Add")
                {
                    if (tokens[1] == "SavingsAccount")
                    {
                        cmdName = "AddSavingAccount";
                        args    = tokens.Skip(2).ToArray();
                    }
                    else
                    {
                        cmdName = "AddCheckingAccount";

                        args = tokens.Skip(2).ToArray();
                    }
                }



                IExecutable command = this.commandInterpreter.InterpretCommand(cmdName, args);


                if (command == null)
                {
                    this.writer.WriteLine(string.Format(ErrorMesseges.InvalidCommand, cmdName));
                }


                string result = command.Execute();

                this.writer.WriteLine(result);
            }
        }
Esempio n. 25
0
        public void FetchWithoutConflict(string remote, string branchName)
        {
            // To get ssh to work with hg, we need to ensure ssh.exe exists in the path and the HOME environment variable is set.
            // NOTE: Although hge.exe accepts the path to ssh.exe via a --ssh parameter, it cannot handle any whitespace
            // This doesn't work for us since ssh.exe is located under Program Files in typical Kudu scenarios.
            _hgExecutable.SetHomePath(_homePath);
            string currentPath = System.Environment.GetEnvironmentVariable(PATH_KEY);
            char   sep         = Path.PathSeparator;

            currentPath = currentPath.TrimEnd(sep) + sep + Path.GetDirectoryName(PathUtilityFactory.Instance.ResolveSSHPath());
            _hgExecutable.EnvironmentVariables[PATH_KEY] = currentPath;

            ITracer tracer = _traceFactory.GetTracer();

            bool retried = false;

            // Whitespace in branch name is legal in Mercurial.
            // We need double quotes around branchName.
            string branchNameWithQuotes = "\"" + branchName + "\"";

fetch:
            try
            {
                _hgExecutable.Execute(tracer, "pull {0} --branch {1} --noninteractive", remote, branchNameWithQuotes, PathUtilityFactory.Instance.ResolveSSHPath());
            }
            catch (CommandLineException exception)
            {
                string branchNotFoundMessage  = String.Format(CultureInfo.InvariantCulture, "abort: unknown branch '{0}'!", branchName);
                string recoverRequiredMessage = "abort: abandoned transaction found - run hg recover!";

                string exceptionMessage = (exception.Message ?? String.Empty).TrimEnd();
                if (exceptionMessage.StartsWith(branchNotFoundMessage, StringComparison.OrdinalIgnoreCase))
                {
                    throw new BranchNotFoundException(branchNameWithQuotes, exception);
                }
                else if (!retried && exceptionMessage.IndexOf(recoverRequiredMessage, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    // Check if the previous fetch failed with a message to recover.
                    retried = true;
                    _hgExecutable.Execute(tracer, "recover");
                    goto fetch;
                }
                throw;
            }
            _hgExecutable.Execute(tracer, "update --clean {0}", branchNameWithQuotes);
        }
    public void InterpretCommand(string input)
    {
        string[]    data        = input.Split(';');
        string      commandName = data[0];
        IExecutable command     = this.ParseCommand(commandName, data);

        command.Execute();
    }
        public void TestIfBothUsersHaveEachOtherAsFriends()
        {
            IExecutable exec = this.disptacher.DispatchCommand("MakeFriends", new string[] { "MakeFriends", "firstUsername", "secondUsername" });

            exec.Execute();
            Assert.IsTrue(this.unit.Users.FirstOrDefaultWhere(u => u.Username == "firstUsername").Friends.Any(u => u.Username == "secondUsername"));
            Assert.IsTrue(this.unit.Users.FirstOrDefaultWhere(u => u.Username == "secondUsername").Friends.Any(u => u.Username == "firstUsername"));
        }
Esempio n. 28
0
 /// <summary>
 /// Handle a sql string and check it with the engine
 /// </summary>
 /// <param name="actual">SQL string</param>
 /// <returns>true, if the query defined in parameter is executed in less that expected else false</returns>
 public bool doMatch(IExecutable actual)
 {
     Result = actual.Execute();
     return
         (
         Result.TimeElapsed.TotalMilliseconds < maxTimeMilliSeconds
         );
 }
Esempio n. 29
0
        public void TestCountChanges()
        {
            IExecutable exe = this.dispacher.DispatchCommand("AddTag", new string[] { "AddTag", "tagzzz" });

            exe.Execute();
            int count = this.unit.Tags.GetAll().ToList().Count;

            Assert.AreNotSame(0, count);
        }
        public static void Interprete(IRepository repository, string[] data)
        {
            string commandType = data[0] + "Command";

            Type        type    = Type.GetType("InfernoInfinity.Core.Commands." + commandType);
            IExecutable command = (IExecutable)Activator.CreateInstance(type, new object[] { repository, data });

            command.Execute();
        }
Esempio n. 31
0
        public void Execute(IExecutable target)
        {
            if (target == null)
              {
            throw new ArgumentNullException("target");
              }

              using (new TimeTracer())
              {
            Output.WriteLine(StartLogMessage);
            target.Execute();
            Output.WriteLine(EndLogMessage);
              }
        }
Esempio n. 32
0
        public void Execute_ShouldExecuteBehavior(IExecutable<ICustomExtension> testee)
        {
            var first = new Mock<IBehavior<ICustomExtension>>();
            var second = new Mock<IBehavior<ICustomExtension>>();
            var extensions = Enumerable.Empty<ICustomExtension>();

            testee.Add(first.Object);
            testee.Add(second.Object);

            testee.Execute(extensions, this.executableContext.Object);

            first.Verify(b => b.Behave(extensions));
            second.Verify(b => b.Behave(extensions));
        }
Esempio n. 33
0
 public void Execute(IExecutable executable)
 {
     bool lockQueryCache = session.Factory.Settings.IsQueryCacheEnabled;
     if (executable.HasAfterTransactionCompletion() || lockQueryCache)
     {
         executions.Add(executable);
     }
     if (lockQueryCache)
     {
         session.Factory.UpdateTimestampsCache.PreInvalidate(executable.PropertySpaces);
     }
     executable.Execute();
 }
		private void Execute( IExecutable executable )
		{
			bool lockQueryCache = factory.IsQueryCacheEnabled;
			if( executable.HasAfterTransactionCompletion || lockQueryCache )
			{
				executions.Add( executable );
			}
			if( lockQueryCache )
			{
				factory.UpdateTimestampsCache.PreInvalidate( executable.PropertySpaces );
			}
			executable.Execute();
		}
Esempio n. 35
0
		public void Execute(IExecutable executable)
		{
			try
			{
				executable.Execute();
			}
			finally
			{
				RegisterCleanupActions(executable);
			}
		}
Esempio n. 36
0
        public IValue Execute(IExecutable executable, bool breakable = false)
        {
            try
            {
                this.executionStack.Push(executable);

                if (breakable)
                {
                    try
                    {
                        this.breakStack.Push(executable);
                        return executable.Execute(this);
                    }
                    finally
                    {
                        this.breakStack.Pop();
                    }
                }
                else
                {
                    return executable.Execute(this);
                }
            }
            finally
            {
                this.executionStack.Pop();
            }
        }
Esempio n. 37
0
        public void Execute_ShouldCreateBehaviorContextForBehaviors(IExecutable<ICustomExtension> testee)
        {
            var first = new Mock<IBehavior<ICustomExtension>>();
            var second = new Mock<IBehavior<ICustomExtension>>();

            testee.Add(first.Object);
            testee.Add(second.Object);

            testee.Execute(Enumerable.Empty<ICustomExtension>(), this.executableContext.Object);

            this.executableContext.Verify(e => e.CreateBehaviorContext(first.Object));
            this.executableContext.Verify(e => e.CreateBehaviorContext(second.Object));
        }