Exemplo n.º 1
0
        private void onChange(object sender, FileSystemEventArgs e)
        {
            lock (compileLock)
            {
                if (checkpointObject == null || isCompiling)
                {
                    return;
                }

                var checkpointName = checkpointObject.GetType().Name;

                var reqTypes = checkpointObject.RequiredTypes.Select(t => removeGenerics(t.Name)).ToList();

                // add ourselves as a required type.
                reqTypes.Add(removeGenerics(checkpointName));
                // if we are a TestCase, add the class we are testing automatically.
                reqTypes.Add(TestScene.RemovePrefix(removeGenerics(checkpointName)));

                if (!reqTypes.Contains(Path.GetFileNameWithoutExtension(e.Name)))
                {
                    return;
                }

                if (!reqTypes.SequenceEqual(requiredTypeNames))
                {
                    requiredTypeNames = reqTypes;

                    requiredFiles.Clear();

                    foreach (var d in validDirectories)
                    {
                        requiredFiles.AddRange(Directory
                                               .EnumerateFiles(d, "*.cs", SearchOption.AllDirectories)
                                               .Where(fw => requiredTypeNames.Contains(Path.GetFileNameWithoutExtension(fw))));
                    }
                }

                lastTouchedFile = e.FullPath;

                isCompiling = true;
                Task.Run(recompile)
                .ContinueWith(_ => isCompiling = false);
            }
        }
Exemplo n.º 2
0
        private void updateList(ValueChangedEvent <Assembly> args)
        {
            leftFlowContainer.Clear();

            //Add buttons for each TestCase.
            string namespacePrefix = TestTypes.Select(t => t.Namespace).GetCommonPrefix();

            leftFlowContainer.AddRange(TestTypes.Where(t => t.Assembly == args.NewValue)
                                       .GroupBy(
                                           t =>
            {
                string group = t.Namespace?.Substring(namespacePrefix.Length).TrimStart('.');
                return(string.IsNullOrWhiteSpace(group) ? TestScene.RemovePrefix(t.Name) : group);
            },
                                           t => t,
                                           (group, types) => new TestGroup {
                Name = group, TestTypes = types.ToArray()
            }
                                           ).OrderBy(g => g.Name)
                                       .Select(t => new TestGroupButton(type => LoadTest(type), t)));
        }