public PropertiesResponse VerifyKnownPropertiesResident(PropertiesInput pi)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            using (Transaction trans = doc.TransactionManager.StartTransaction())
            {
                IEnumerable <BlockRefDrawingObject> records = doc.Database.GetLayout(pi.LayoutName).GetBlockReferences().Select(br => new TestBlockRefDrawingObject(doc, br));
                records = records.Where(br => br.BlockName == pi.BlockName);

                if (records.Count() != 1)
                {
                    throw new ArgumentOutOfRangeException();
                }

                BlockRefDrawingObject testObject = records.ElementAt(0);

                PropertiesResponse pr = new PropertiesResponse
                {
                    Client  = testObject.GetProperty <string>("CLIENT1"),
                    Project = testObject.GetProperty <string>("PROJECT1")
                };

                return(pr);
            }
        }
Пример #2
0
 public IReadOnlyCollection <Property> Map(PropertiesResponse properties)
 {
     if (properties == null || properties.Property == null)
     {
         return(new List <Property>());
     }
     return(properties.Property.Select(Map).ToList());
 }
            public CSharpVBBindingConfigProvider CreateTestSubject()
            {
                // Note: where possible, the mocked methods are set up with the expected
                // parameter values i.e. they will only be called if the correct values
                // are passed in.
                Logger = new TestLogger();

                sonarQubeServiceMock = new Mock <ISonarQubeService>();
                sonarQubeServiceMock
                .Setup(x => x.GetRulesAsync(true, profile.Key, It.IsAny <CancellationToken>()))
                .ReturnsAsync(ActiveRulesResponse);

                sonarQubeServiceMock
                .Setup(x => x.GetRulesAsync(false, profile.Key, It.IsAny <CancellationToken>()))
                .ReturnsAsync(InactiveRulesResponse);

                sonarQubeServiceMock
                .Setup(x => x.GetAllPropertiesAsync(ExpectedProjectKey, It.IsAny <CancellationToken>()))
                .ReturnsAsync(PropertiesResponse);

                ruleGenMock = new Mock <Core.CSharpVB.IRuleSetGenerator>();
                ruleGenMock.Setup(x => x.Generate(language.ServerLanguage.Key, It.IsAny <IEnumerable <SonarQubeRule> >(), It.IsAny <IDictionary <string, string> >()))
                .Returns(RuleSetGeneratorResponse)
                .Callback((string _, IEnumerable <SonarQubeRule> rules, IDictionary <string, string> properties) =>
                {
                    CapturedRulesPassedToRuleSetGenerator      = rules;
                    CapturedPropertiesPassedToRuleSetGenerator = properties;
                });

                nugetGenMock = new Mock <Core.CSharpVB.INuGetPackageInfoGenerator>();
                nugetGenMock.Setup(x => x.GetNuGetPackageInfos(It.IsAny <IList <SonarQubeRule> >(), It.IsAny <IDictionary <string, string> >()))
                .Returns(NuGetGeneratorResponse);

                nugetBindingMock = new Mock <INuGetBindingOperation>();
                nugetBindingMock.Setup(x => x.ProcessExport(language, NuGetGeneratorResponse))
                .Returns(NuGetBindingOperationResponse);

                BindingConfiguration = new BindingConfiguration(new BoundSonarQubeProject(new Uri(serverUrl), ExpectedProjectKey, projectName),
                                                                SonarLintMode.Connected, "c:\\test\\");

                var sonarProperties = PropertiesResponse.ToDictionary(x => x.Key, y => y.Value);

                sonarLintConfigGeneratorMock
                .Setup(x => x.Generate(It.IsAny <IEnumerable <SonarQubeRule> >(), sonarProperties, language))
                .Returns(SonarLintConfigurationResponse);

                return(new CSharpVBBindingConfigProvider(sonarQubeServiceMock.Object, nugetBindingMock.Object, Logger,
                                                         // inject the generator mocks
                                                         ruleGenMock.Object,
                                                         nugetGenMock.Object,
                                                         sonarLintConfigGeneratorMock.Object));
            }
        public void VerifyKnownProperties()
        {
            PropertiesInput pi = new PropertiesInput()
            {
                LayoutName = "CIV_A1L",
                BlockName  = "A1 Mask"
            };

            PropertiesResponse respone = RunTest <PropertiesResponse>(nameof(VerifyKnownPropertiesResident), pi);

            Assert.AreEqual("Test Client", respone.Client);
            Assert.AreEqual("Test Project", respone.Project);
        }