コード例 #1
0
 @Test
 public void testCreateViolationOutsideProject() throws Exception {
   violationMaker.setCurrentSource("C:\\Outside\\Example\\Example.Core\\Money.cs");
   Violation violation = violationMaker.createViolation();
   assertNull(violation);
   verifyZeroInteractions(context);
 }
コード例 #2
0
 @Test
 public void testCreateViolationWithSourceInfoAndLineAndColumn() throws Exception {
   violationMaker.setCurrentSource("C:\\Sonar\\Example\\Example.Core\\Money.cs(56,45)");
   Violation violation = violationMaker.createViolation();
   assertThat(violation.getResource().getKey(), is("Example.Core/Money.cs"));
   assertThat(violation.getLineId(), is(56));
 }
コード例 #3
0
 @Test
 public void testCreateViolationWithNoSourceInfoButLocationForMethod() throws Exception {
   violationMaker.registerRuleType(aRule, "Method");
   Violation violation = violationMaker.createViolation();
   assertThat(violation.getResource(), is(aFileMoney));
   assertNull(violation.getLineId());
 }
コード例 #4
0
 @Test
 public void testCreateViolationWithNoMessage() throws Exception {
   violationMaker.setCurrentSource("C:\\Sonar\\Example\\Example.Core\\Money.cs");
   violationMaker.setCurrentMessage("");
   Violation violation = violationMaker.createViolation();
   assertThat(violation.getResource().getKey(), is("Example.Core/Money.cs"));
   assertThat(violation.getMessage(), is("Default Message"));
 }
コード例 #5
0
 @Test
 public void testCreateViolationWithNoSourceInfoButLocationForInnerType() throws Exception {
   violationMaker.registerRuleType(aRule, "Type");
   violationMaker.setCurrentLocation("Example.Core.IMoney/InnerClass");
   Violation violation = violationMaker.createViolation();
   assertThat(violation.getResource(), is(aFileIMoney));
   assertNull(violation.getLineId());
 }
コード例 #6
0
 @Test
 public void testCreateViolationOnAssembly() throws Exception {
   violationMaker.registerRuleType(aRule, "Assembly");
   Violation violation = violationMaker.createViolation();
   assertThat(violation.getResource(), is((Resource) project));
   assertThat(violation.getSeverity(), is(RulePriority.BLOCKER));
   assertNull(violation.getLineId());
 }
コード例 #7
0
 @Test
 public void testCreateViolationWithNoResourceFound() throws Exception {
   violationMaker.registerRuleType(aRule, "Assembly");
   violationMaker.setCurrentTargetName("Foo)");
   violationMaker.setCurrentLocation("Foo");
   Violation violation = violationMaker.createViolation();
   assertThat(violation.getResource(), is((Resource) project));
   assertNull(violation.getLineId());
 }
コード例 #8
0
 @Before
 public void reinitViolationMaker() {
   context = mock(SensorContext.class);
   violationMaker =
       new GendarmeViolationMaker(env, project, context, resourcesBridge, resourceHelper);
   violationMaker.setCurrentRule(aRule);
   violationMaker.setCurrentDefaultViolationMessage("Default Message");
   violationMaker.setCurrentTargetName(
       "Example.Core.IMoney Example.Core.Money::AddMoney(Example.Core.Money)");
   violationMaker.setCurrentTargetAssembly(
       "Example.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
   violationMaker.setCurrentLocation(
       "Example.Core.IMoney Example.Core.Money::AddMoney(Example.Core.Money)");
   violationMaker.setCurrentSource("");
   violationMaker.setCurrentMessage("Message");
 }