@Test public void testCreateViolationWithNoSourceInfoAndNoLocationForType() throws Exception { violationMaker.registerRuleType(aRule, "Type"); violationMaker.setCurrentLocation(""); violationMaker.setCurrentTargetName("Example.Core.IMoney"); Violation violation = violationMaker.createViolation(); assertThat(violation.getResource(), is(aFileIMoney)); assertNull(violation.getLineId()); }
@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()); }
@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"); }