public static void Main(string[] args)
        {
            PrintGreeting();

            if (args.Length == 0)
            {
                PrintUsage();
                Environment.Exit(0);
            }

            string slnFile = Path.GetFullPath(args[0]);

            if (!File.Exists(slnFile))
            {
                Console.WriteLine("Specified parameter is expected to be an existing Visual Studio solution file.");
                Console.WriteLine("Parameter: {0}", args[0]);
                Environment.Exit(-1);
            }

            Console.WriteLine("Analyzing solution {0}", slnFile);
            Console.WriteLine();

            ISolution     solution = SolutionReader.Read(slnFile);
            List <IIssue> issues   = new List <IIssue>();

            foreach (IRule rule in RulesRepository.GetAllRules())
            {
                issues.AddRange(rule.Apply(solution));
            }

            if (issues.Count == 0)
            {
                Console.WriteLine("No issues were found.");
            }
            else
            {
                string lastFile = null;
                foreach (IIssue issue in issues.OrderBy(x => x.File))
                {
                    if (lastFile != issue.File)
                    {
                        Console.WriteLine("File: {0}", issue.File);
                        lastFile = issue.File;
                    }

                    Console.WriteLine("[{0}] {1}", issue.Code, issue.Text);
                }

                Environment.ExitCode = -1;
            }
        }
Example #2
0
        public async Task WhenVersionIsNewer_ShouldUpdateTheRules()
        {
            // Arrange
            var versions     = new ReplaySubject <string>(1);
            var versionsMock = new Mock <IRulesetVersionProvider>();

            versionsMock.Setup(x => x.OnVersion()).Returns(versions);

            var driverMock = new Mock <IRulesDriver>();

            var repository = new RulesRepository(driverMock.Object, versionsMock.Object, TimeSpan.Zero, TimeSpan.FromMinutes(1));

            // Act/Assert
            driverMock.Setup(x => x.GetRuleset(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(
                         new Dictionary <string, RuleDefinition> {
                { "test_rule1", new RuleDefinition() }
            }));
            versions.OnNext("10001");

            var result = await repository.GetAllRules();

            Assert.Equal("10001", repository.CurrentLabel);
            Assert.Equal("test_rule1", result.Keys.Single());

            driverMock.Setup(x => x.GetRuleset(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(
                         new Dictionary <string, RuleDefinition> {
                { "test_rule2", new RuleDefinition() }
            }));
            versions.OnNext("10002");
            await Task.Delay(10);

            result = await repository.GetAllRules();

            Assert.Equal("10002", repository.CurrentLabel);
            Assert.Equal("test_rule2", result.Keys.Single());
        }
Example #3
0
        public StudentViewModel()
        {
            StatusItems.Add(new SelectListItem
            {
                Text  = "Confirmed",
                Value = "Confirmed"
            });
            StatusItems.Add(new SelectListItem
            {
                Text  = "Waiting",
                Value = "Waiting"
            });

            //get Courses list
            CoursesRepository coursesRepository = new CoursesRepository();

            CoursesList = coursesRepository.GetAllCourses();

            RulesRepository rulesRepository = new RulesRepository();

            RulesList = rulesRepository.GetAllRules();
        }
Example #4
0
        public async Task WhenGivenEmptyRules_ShouldReturnExpectedVersionAndEmptyRules()
        {
            // Arrange
            var versions = new ReplaySubject <string>(1);

            versions.OnNext("10001");
            var versionsMock = new Mock <IRulesetVersionProvider>();

            versionsMock.Setup(x => x.OnVersion()).Returns(versions);

            var driverMock = new Mock <IRulesDriver>();

            driverMock.Setup(x => x.GetRuleset(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new Dictionary <string, RuleDefinition>()));

            var repository = new RulesRepository(driverMock.Object, versionsMock.Object, TimeSpan.Zero, TimeSpan.FromMinutes(1));

            // Act
            var result = await repository.GetAllRules();

            // Assert
            Assert.Equal("10001", repository.CurrentLabel);
            Assert.Empty(result);
        }