public void Test_EditPropertyGroupNodeAction_AddRemove([Values] TestingMode mode) { IConstantNodeModel constant = GraphModel.CreateConstantNode("toto", typeof(Vector3).GenerateTypeHandle(Stencil), Vector2.zero); GetPropertyGroupNodeModel property = GraphModel.CreateGetPropertyGroupNode(Vector2.zero); GraphModel.CreateEdge(property.InstancePort, constant.OutputPort); Type type = typeof(GameObject); MemberInfo memberInfo = type.GetMembers()[0]; var newMember = new TypeMember { Path = new List <string> { memberInfo.Name }, Type = memberInfo.GetUnderlyingType().GenerateTypeHandle(Stencil) }; TestPrereqActionPostreq(mode, () => { Assert.That(GetNodeCount(), Is.EqualTo(2)); Assert.That(GetEdgeCount(), Is.EqualTo(1)); Assert.That(property.GetPortsForMembers().Count(), Is.EqualTo(0)); Assert.That(property.OutputsByDisplayOrder.Count(), Is.EqualTo(0)); return(new EditPropertyGroupNodeAction( EditPropertyGroupNodeAction.EditType.Add, property, newMember)); }, () => { Assert.That(GetNodeCount(), Is.EqualTo(2)); Assert.That(GetEdgeCount(), Is.EqualTo(1)); Assert.That(property.GetPortsForMembers().Count(), Is.EqualTo(1)); Assert.That(property.OutputsByDisplayOrder.Count(), Is.EqualTo(1)); }); TestPrereqActionPostreq(mode, () => { Assert.That(GetNodeCount(), Is.EqualTo(2)); Assert.That(GetEdgeCount(), Is.EqualTo(1)); Assert.That(property.GetPortsForMembers().Count(), Is.EqualTo(1)); Assert.That(property.OutputsByDisplayOrder.Count(), Is.EqualTo(1)); return(new EditPropertyGroupNodeAction( EditPropertyGroupNodeAction.EditType.Remove, property, newMember)); }, () => { Assert.That(GetNodeCount(), Is.EqualTo(2)); Assert.That(GetEdgeCount(), Is.EqualTo(1)); Assert.That(property.GetPortsForMembers().Count(), Is.EqualTo(0)); Assert.That(property.OutputsByDisplayOrder.Count(), Is.EqualTo(0)); }); }
public static IEnumerable <SyntaxNode> BuildGetPropertyNode(this RoslynTranslator translator, GetPropertyGroupNodeModel model, IPortModel portModel) { var instancePort = model.InstancePort; var input = !instancePort.Connected ? SyntaxFactory.ThisExpression() : translator.BuildPort(instancePort).SingleOrDefault(); if (input == null) { yield break; } var member = model.Members.FirstOrDefault(m => m.GetId() == portModel.UniqueId); if (member.Path == null || member.Path.Count == 0) { yield break; } var access = RoslynBuilder.MemberReference(input, member.Path[0]); for (int i = 1; i < member.Path.Count; i++) { access = RoslynBuilder.MemberReference(access, member.Path[i]); } yield return(access); }