public async void CallsToInterfaceAreResolved() { CallgraphDTO dto = await Utils.Extract("../callcluster-dotnet.sln"); CommunityDTO project = dto.community .Community("callcluster-dotnet") .Namespace("callcluster_dotnet"); long?visitClassDeclaration = project ?.Community("CSharpCallgraphWalker") ?.Function("VisitClassDeclaration(ClassDeclarationSyntax)", dto); long?called = project ?.Community("CallgraphCollector") ?.Function("AddClass(INamedTypeSymbol)", dto); CallgraphAssert.CallPresent( dto, visitClassDeclaration.Value, called.Value ); var addClassInstances = dto.functions .Where(f => f.name == "AddClass(INamedTypeSymbol)" && f.written) .ToList(); Assert.Equal(1, addClassInstances.Count()); }
public async void CarCanBeLambo() { CallgraphDTO dto = await Utils.Extract("inheritance/complex-project.csproj"); CommunityDTO project = dto.community.Namespace("complex_project"); long?turnOnCarId = project ?.Community("Program") ?.Function("TurnOnCar(Car)", dto); Assert.NotNull(turnOnCarId); long?turnOnMotorId = project ?.Community("MotorizedTransport") ?.Function("TurnOn()", dto); Assert.NotNull(turnOnMotorId); long?turnOnLamboId = project ?.Community("Lambo") ?.Function("TurnOn()", dto); Assert.NotNull(turnOnLamboId); CallgraphAssert.CallPresent(dto, turnOnCarId.Value, turnOnMotorId.Value); CallgraphAssert.CallPresent(dto, turnOnCarId.Value, turnOnLamboId.Value); CallgraphAssert.CallsFrom(dto, turnOnCarId.Value, 2); }
public async void TurnOnTurnableCallsAllImplementations() { CallgraphDTO dto = await Utils.Extract("interfaces/interfaces.csproj"); CommunityDTO project = dto.community.Namespace("interfaces"); long?turnOnProgram = project ?.Community("Program") ?.Function("TurnOnTurnable(ITurnable)", dto); long?turnOnTurnable = project ?.Community("ITurnable") ?.Function("TurnOn()", dto); long?turnOnMicrowave = project ?.Community("Microwave") ?.Function("TurnOn()", dto); long?turnOnTelevision = project ?.Community("Television") ?.Function("TurnOn()", dto); CallgraphAssert.CallPresent(dto, turnOnProgram.Value, turnOnTurnable.Value); CallgraphAssert.CallPresent(dto, turnOnProgram.Value, turnOnMicrowave.Value); CallgraphAssert.CallPresent(dto, turnOnProgram.Value, turnOnTelevision.Value); CallgraphAssert.CallsFrom(dto, turnOnProgram.Value, 3); }
public async void BreakBreakableCallsAllImplementations() { CallgraphDTO dto = await Utils.Extract("interfaces/interfaces.csproj"); long?breakProgram = dto.community ?.Namespace("interfaces") ?.Community("Program") ?.Function("BreakThings(IBreakable)", dto); CallgraphAssert.CallsFrom(dto, breakProgram.Value, 6);//interface, tv, microwave, Delicate, Glass, Pottery }
public async void GrandsonConstructorCallsParent() { CallgraphDTO dto = await Utils.Extract("constructors/constructors.csproj"); string grandson = "Grandson()"; string child = "Child(Int32)"; string mainString = "Main(String, String)"; CallgraphAssert.CallPresent(dto, grandson, child); CallgraphAssert.CallPresent(dto, grandson, mainString); CallgraphAssert.CallsFrom(dto, grandson, 2); }
public async void MainConstructorCallsMethods() { CallgraphDTO dto = await Utils.Extract("constructors/constructors.csproj"); string main = "Main()"; string doThis = "DoThis()"; string doThat = "DoThat()"; CallgraphAssert.CallPresent(dto, main, doThis); CallgraphAssert.CallPresent(dto, main, doThat); CallgraphAssert.CallsFrom(dto, main, 2); }
public async void DoThatCallsThreeConstructors() { CallgraphDTO dto = await Utils.Extract("constructors/constructors.csproj"); string main = "Main()"; string mainString = "Main(String, String)"; string mainInt = "Main(Int32, Int32)"; string doThat = "DoThat()"; CallgraphAssert.CallPresent(dto, doThat, main); CallgraphAssert.CallPresent(dto, doThat, mainString); CallgraphAssert.CallPresent(dto, doThat, mainInt); CallgraphAssert.CallsFrom(dto, doThat, 3); }
public async void ReferencesDectected() { CallgraphDTO dto = await Utils.Extract("functional/functional.csproj"); string mapNumbers = "MapNumbers()"; string method = "AsNumbersMethod(Int32, Int32)"; string func = "AsNumberPrivate(Int32)"; string transform = "Transform(Int32, Int32)"; string newThing = "Thing()"; CallgraphAssert.CallPresent(dto, mapNumbers, method); CallgraphAssert.CallPresent(dto, mapNumbers, func); CallgraphAssert.CallPresent(dto, mapNumbers, transform); CallgraphAssert.CallPresent(dto, mapNumbers, newThing); }
public async void OverridenCallsSpecific() { CallgraphDTO dto = await Utils.Extract("inheritance/complex-project.csproj"); CommunityDTO project = dto.community.Namespace("complex_project"); long? turnOnProgram = project ?.Community("Program") ?.Function("TurnOnLambo(Lambo)", dto); long?turnOnLambo = project ?.Community("Lambo") ?.Function("TurnOn()", dto); CallgraphAssert.CallsFrom(dto, turnOnProgram.Value); CallgraphAssert.CallPresent(dto, turnOnProgram.Value, turnOnLambo.Value); }
public async void CallsToAnotherGenericMethod() { CallgraphDTO dto = await Utils.Extract("../callcluster-dotnet.sln"); CommunityDTO project = dto.community.Namespace("callcluster_dotnet"); long?getCallDTOs = project ?.Community("CallgraphCollector") ?.Function("GetCallDTOs()", dto); long?descendantsOf = project ?.Community("Tree") ?.Function("DescendantsOf(T)", dto); CallgraphAssert.CallPresent(dto, getCallDTOs.Value, descendantsOf.Value); }
public async void CallsToGenericMethods() { CallgraphDTO dto = await Utils.Extract("../callcluster-dotnet.sln"); CommunityDTO project = dto.community.Namespace("callcluster_dotnet"); long?addClassMethod = project ?.Community("CallgraphCollector") ?.Function("AddClass(INamedTypeSymbol)", dto); long?addTreeMethod = project ?.Community("Tree") ?.Function("Add(T, T)", dto); CallgraphAssert.CallPresent(dto, addClassMethod.Value, addTreeMethod.Value); }
public async void WaterVehicleCanBeShip() { CallgraphDTO dto = await Utils.Extract("inheritance/complex-project.csproj"); CommunityDTO project = dto.community.Namespace("complex_project"); long?turnOnProgramId = project ?.Community("Program") ?.Function("TurnOnWaterVehicle(WaterVehicle)", dto); Assert.NotNull(turnOnProgramId); long?turnOnWaterVehicleId = project ?.Community("WaterVehicle") ?.Function("TurnOn()", dto); Assert.NotNull(turnOnWaterVehicleId); long?turnOnSmallShipId = project ?.Community("SmallShip") ?.Function("TurnOn()", dto); Assert.NotNull(turnOnSmallShipId); long?turnOnBigShipId = project ?.Community("BigShip") ?.Function("TurnOn()", dto); Assert.NotNull(turnOnBigShipId); CallgraphAssert.CallPresent(dto, turnOnProgramId.Value, turnOnSmallShipId.Value ); CallgraphAssert.CallPresent(dto, turnOnProgramId.Value, turnOnBigShipId.Value ); CallgraphAssert.CallPresent(dto, turnOnProgramId.Value, turnOnWaterVehicleId.Value ); CallgraphAssert.CallsFrom(dto, turnOnProgramId.Value, 3); }
public async void GeneralCallsAll() { CallgraphDTO dto = await Utils.Extract("inheritance/complex-project.csproj"); CommunityDTO project = dto.community.Namespace("complex_project"); long? turnOnProgram = project ?.Community("Program") ?.Function("TurnOnTransport(MotorizedTransport)", dto); long?turnOnLambo = project ?.Community("Lambo") ?.Function("TurnOn()", dto); long?turnOnMotor = project ?.Community("MotorizedTransport") ?.Function("TurnOn()", dto); CallgraphAssert.CallsFrom(dto, turnOnProgram.Value, 5); CallgraphAssert.CallPresent(dto, turnOnProgram.Value, turnOnLambo.Value); CallgraphAssert.CallPresent(dto, turnOnProgram.Value, turnOnMotor.Value); }
public async void NotOverridenOnlyCallsBase() { CallgraphDTO dto = await Utils.Extract("inheritance/complex-project.csproj"); CommunityDTO project = dto.community.Namespace("complex_project"); long?turnOnCopterId = project ?.Community("Program") ?.Function("TurnOnCopter(Helicopter)", dto); Assert.NotNull(turnOnCopterId); long?turnOnMotorId = project ?.Community("MotorizedTransport") ?.Function("TurnOn()", dto); Assert.NotNull(turnOnMotorId); var children = dto.community.communities.ToList(); CallgraphAssert.CallPresent(dto, turnOnCopterId.Value, turnOnMotorId.Value); CallgraphAssert.CallsFrom(dto, turnOnCopterId.Value, 1); }
public async void CallsFromTestingToExtractor() { CallgraphDTO dto = await Utils.Extract("../callcluster-dotnet.sln"); CommunityDTO extractor = dto.community.Community("callcluster-dotnet"); CommunityDTO tests = dto.community.Community("callcluster-dotnet.Tests"); long?realExtract = extractor .Namespace("callcluster_dotnet") ?.Community("Program") ?.Function("Extract(String)", dto); long?testingExtract = tests .Namespace("callcluster_dotnet") ?.Community("Tests") ?.Community("Utils") ?.Function("Extract(String)", dto); var extracts = dto.functions.Where(f => f.name == "Extract(String)").ToList(); Assert.Equal(2, extracts.Count()); CallgraphAssert.CallPresent(dto, testingExtract.Value, realExtract.Value); }