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);
        }
示例#2
0
        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);
        }
示例#3
0
        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
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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 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 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);
        }