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 static long?Function(this CommunityDTO com, string name, CallgraphDTO cg) { var ret = com.functions .Select((fid) => (long?)fid) .Select((long?fid) => (f: cg.functions.ElementAt((int)fid), fid)); return(ret.FirstOrDefault(x => x.f.name == name).fid); }
public ActionResult AddCommunity(CommunityDTO community) { CommunityService.AddCommunity(community); return(Json(new AjaxResult <object> { code = 0, msg = "添加成功" })); }
public CreateCommunityCommand(CommunityDTO community) { if (community == null) { throw new Exception("Exception"); } CommunityDTO = community; }
CommunityDTO ToDTO(CommunityEntity community) { CommunityDTO dto = new CommunityDTO(); dto.BulitYear = community.BuiltYear; dto.CreateDateTime = community.CreateDateTIme; dto.Id = community.Id; dto.Loaction = community.Location; dto.Name = community.Name; dto.RegionId = community.RegionId; dto.Traffic = community.Traffic; return(dto); }
private CommunityDTO ToDTO(CommunityEntity com) { CommunityDTO dto = new CommunityDTO() { BuiltYear = com.BuiltYear, CreateDateTime = com.CreateDateTime, Id = com.Id, Location = com.Location, Name = com.Name, RegionId = com.RegionId, Traffic = com.Traffic }; return(dto); }
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 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 CommunityDTO DTO(CommunityEntity entity) { CommunityDTO community = new CommunityDTO() { BuiltYear = entity.BuiltYear, Id = entity.Id, CreateDateTime = entity.CreateDateTime, Location = entity.Location, Name = entity.Name, RegionId = entity.RegionId, Traffic = entity.Traffic, RegionName = entity.Region.Name }; return(community); }
public static CommunityDTO Namespace(this CommunityDTO com, string name) { if (com.type == "root" || com.type == "Assembly" || com.type == "NetModule" ) { return(com.communities .Select(c => c.Namespace(name)) .FirstOrDefault(ns => ns != null)); } else { return(com.communities .FirstOrDefault(c => c.name == name && c.type == "Namespace")); } }
public void AddCommunity(CommunityDTO community) { using (WarmHomeContext db = new WarmHomeContext()) { BaseService <CommunityEntity> service = new BaseService <CommunityEntity>(db); CommunityEntity entity = new CommunityEntity() { RegionId = community.RegionId, Name = community.Name, Location = community.Location, BuiltYear = community.BuiltYear, Traffic = community.Traffic }; db.Communities.Add(entity); db.SaveChanges(); } }
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 Task <IActionResult> AddCommunityPost([FromForm] AddCommunityModel model) { var community = new CommunityDTO() { Address = model.Address, EpiCenter = new EpicenterDTO() { Latitude = model.Latitude, Longitude = model.Longitude, SRID = 4326, Radius = model.Radius }, InfoUrl = model.InfoUrl, Name = model.Name, PictureUrl = model.PictureUrl }; var command = new CreateCommunityCommand(community); var result = await Mediator.Send(command); return(RedirectToAction("ManageCommunity", new { id = result })); }
public void UpdateCommunity(CommunityDTO community) { using (WarmHomeContext db = new WarmHomeContext()) { BaseService <CommunityEntity> service = new BaseService <CommunityEntity>(db); var data = service.GetById(community.Id); if (data == null) { throw new ArgumentException("此" + community.Id + "的小区不存在"); } data.Location = community.Location; data.Name = community.Name; data.RegionId = community.RegionId; data.Traffic = community.Traffic; data.BuiltYear = community.BuiltYear; db.SaveChanges(); } }
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 ActionResult Edit(CommunityDTO community) { try { CommunityService.UpdateCommunity(community); return(Json(new AjaxResult <object> { code = 0, msg = "编辑成功" })); } catch (Exception ex) { Log.ErrorFormat("编辑小区失败:" + ex.Message); return(Json(new AjaxResult <object> { code = 0, msg = "编辑失败" })); } }
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); }
public async Task <IActionResult> Create([FromBody] CommunityDTO communityDTO) { return(Ok(await Mediator.Send(new CreateCommunityCommand(communityDTO)))); }
public static CommunityDTO Community(this CommunityDTO com, string name) { return(com.communities.FirstOrDefault(c => c.name == name)); }