Exemple #1
0
        private static void Main()
        {
            if (string.IsNullOrWhiteSpace(YourName.Authors))
            {
                Console.WriteLine("Enter your surnames at YourName.cs in AUTHORS constant");
                Thread.Sleep(3000);
                return;
            }
            var testPackage = new TestPackage(Assembly.GetExecutingAssembly().Location);

            using (var engine = new TestEngine())
                using (var testRunner = engine.GetRunner(testPackage))
                    if (TestsAreValid(testRunner))
                    {
                        var incorrectImplementations = ChallengeHelpers.GetIncorrectImplementationTypes();
                        var statuses = GetIncorrectImplementationsResults(testRunner, incorrectImplementations);
                        var res      = new List <ImplementationStatus>();
                        foreach (var status in statuses)
                        {
                            res.Add(status);
                            WriteImplementationStatusToConsole(status);
                        }
                        if (!string.IsNullOrWhiteSpace(YourName.Authors))
                        {
                            PostResults(res);
                        }
                    }
        }
Exemple #2
0
        public void Generate()
        {
            var impls = ChallengeHelpers.GetIncorrectImplementationTypes();
            var code  = string.Join(Environment.NewLine,
                                    impls.Select(imp => $"public class {imp.Name}_Tests : {nameof(IncorrectImplementation_TestsBase)} {{}}")
                                    );

            Console.WriteLine(code);
        }
Exemple #3
0
        public void CheckAllTestsAreInPlace()
        {
            var implTypes   = ChallengeHelpers.GetIncorrectImplementationTypes();
            var testedImpls = ChallengeHelpers.GetIncorrectImplementationTests()
                              .Select(t => t.CreateStatistics())
                              .ToArray();

            foreach (var impl in implTypes)
            {
                Assert.NotNull(testedImpls.SingleOrDefault(t => t.GetType().FullName == impl.FullName),
                               "Single implementation of tests for {0} not found. Regenerate tests with test above!", impl.FullName);
            }
        }
Exemple #4
0
        private static IEnumerable <ImplementationStatus> GetIncorrectImplementationsResults(
            ITestRunner testRunner, IEnumerable <Type> implementations)
        {
            var implTypeToTestsType = ChallengeHelpers.GetIncorrectImplementationTests()
                                      .ToDictionary(t => t.CreateStatistics().GetType(), t => t.GetType());

            foreach (var implementation in implementations)
            {
                var failed = GetFailedTests(testRunner,
                                            implementation,
                                            implTypeToTestsType[implementation])
                             .ToArray();
                yield return(new ImplementationStatus(implementation.Name, failed));
            }
        }
Exemple #5
0
        private static IList <ImplementationStatus> GetIncorrectImplementationsResults(
            ITestRunner testRunner, IEnumerable <Type> implementations)
        {
            var result = new List <ImplementationStatus>();
            var implTypeToTestsType = ChallengeHelpers.GetIncorrectImplementationTests()
                                      .ToDictionary(t => t.CreateStatistics().GetType(), t => t.GetType());

            foreach (var implementation in implementations)
            {
                var failed = GetFailedTests(testRunner,
                                            implementation,
                                            implTypeToTestsType[implementation])
                             .ToList();
                var name = implementation.Name.PadRight(20, ' ');
                result.Add(new ImplementationStatus(name, failed.Count));
            }
            return(result);
        }
Exemple #6
0
        private static void Main()
        {
            names = LoadOrRequestName();
            var testPackage = new TestPackage(Assembly.GetExecutingAssembly().Location);

            using (var engine = new TestEngine())
                using (var testRunner = engine.GetRunner(testPackage))
                    if (TestsAreValid(testRunner))
                    {
                        var incorrectImplementations = ChallengeHelpers.GetIncorrectImplementationTypes();
                        var statuses = GetIncorrectImplementationsResults(testRunner, incorrectImplementations);
                        PostResults(statuses);
                        foreach (var status in statuses)
                        {
                            WriteImplementationStatusToConsole(status);
                        }
                    }
        }
Exemple #7
0
        private static void Main()
        {
            if (WordsStatistics_Tests.Authors == "<ВАШИ ФАМИЛИИ>")
            {
                Console.WriteLine("Укажите ваши фамилии в классе WordStatistics_Tests в поле Authors!");
                Thread.Sleep(3000);
            }
            var testPackage = new TestPackage(Assembly.GetExecutingAssembly().Location);

            using (var engine = new TestEngine())
                using (var testRunner = engine.GetRunner(testPackage))
                    if (TestsAreValid(testRunner))
                    {
                        var incorrectImplementations = ChallengeHelpers.GetIncorrectImplementationTypes();
                        var statuses = GetIncorrectImplementationsResults(testRunner, incorrectImplementations);
                        var res      = new List <ImplementationStatus>();
                        foreach (var status in statuses)
                        {
                            res.Add(status);
                            WriteImplementationStatusToConsole(status);
                        }
                        PostResults(res);
                    }
        }