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 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 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 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); }