public static void TestNullDefault() { string name = "asdg"; Id <Parameter> id = Id <Parameter> .Parse("F2EA9FA2-61C4-45A0-BFA7-906349445AD8"); DynamicEnumParameter.Source source = new DynamicEnumParameter.Source(); ParameterType type = ParameterType.Parse("623014BC-EA1D-4230-9B33-DEA1BD43C0E2"); DynamicEnumParameter p = new DynamicEnumParameter(name, id, source, type, null, false); Assert.That(p.Corrupted, Is.True); Assert.That(p.Local, Is.False); Assert.That(p.Name, Is.EqualTo(name)); Assert.That(p.Id, Is.EqualTo(id)); Assert.That(p.TypeId, Is.EqualTo(type)); Assert.That(p.Options, Is.EquivalentTo(source.Options)); Assert.That(source.Options, Is.Empty); var actions2 = p.SetValueAction("fdjk"); actions2.Value.Redo(); CheckValue(p, "fdjk"); actions2.Value.Undo(); Assert.That(p.Corrupted, Is.True); }
public void New() { var jumpsource = new DynamicEnumParameter.Source(); IdProvider idprovider = new IdProvider(); var nodes = new List <ConversationNode>(); if (!(m_datasource is DummyDataSource)) //TODO: This could be handled more elegantly { nodes.Add(m_nodeFactory().MakeNode(m_datasource.GetNode(SpecialNodes.START_GUID)(idprovider.Next()), new Point(50, 50), new Size(10, 10))); } var file = new ConversationFile(idprovider, nodes, new List <NodeGroup>(), null, jumpsource); Select(file); Refresh.Execute(); }
public static void Test() { IEnumerable <GraphAndUI <NodeUIData> > nodes = Enumerable.Empty <GraphAndUI <NodeUIData> >(); List <NodeGroup> groups = new List <NodeGroup>(); MemoryStream rawData = new MemoryStream(); DocumentPath file = DocumentPath.FromPath("DeleteMe.txt", new DirectoryInfo(".")); ISerializer <TData> serializer = null; ReadOnlyCollection <LoadError> errors = new ReadOnlyCollection <LoadError>(new List <LoadError>()); INodeFactory nodeFactory = null; GenerateAudio generateAudio = null; var source = new DynamicEnumParameter.Source(); Func <IDynamicEnumParameter, object, DynamicEnumParameter.Source> getDocumentSource = (a, b) => source; IAudioLibrary audioProvider = new DummyAudioLibrary(); List <List <ConversationNode> > states = new List <List <ConversationNode <INodeGui> > > { new List <ConversationNode>() }; Random r = new Random(0); UpToDateFile.BackEnd backend = new UpToDateFile.BackEnd(); var id = Id <FileInProject> .Parse("6a1bd06a-0028-4099-a375-475f1a5320db"); using (ConversationFile conversationFile = new ConversationFile(id, nodes, groups, rawData, file, serializer, errors, nodeFactory, generateAudio, getDocumentSource, audioProvider, backend)) { for (int i = 0; i < 10; i++) { var node = MakeNode(); var state = states[i].ToList(); state.Add(node); conversationFile.Add(new[] { node }, Enumerable.Empty <NodeGroup>(), null); CheckState(conversationFile, state); states.Add(state); } Action <ConversationNode> CheckNode = node => { var connector = conversationFile.UIInfo(node.Data.Connectors.First(), false); Assert.That(connector.Area.Value, Is.EqualTo(TopPosition(node.Renderer.Area))); }; for (int n = 0; n < 10000; n++) { var node = states.Last().Last(); node.Renderer.MoveTo(new PointF((float)r.NextDouble() * 1000, (float)r.NextDouble() * 1000)); CheckNode(node); } for (int i = 9; i >= 0; i--) { conversationFile.UndoableFile.UndoQueue.Undo(); var state = states[i]; CheckState(conversationFile, state); } for (int i = 1; i <= 10; i++) { conversationFile.UndoableFile.UndoQueue.Redo(); var state = states[i]; CheckState(conversationFile, state); } } Assert.Inconclusive(); }
public void MergeInto(DynamicEnumParameter.Source newSource) { //Do nothing. This object maintains its own source and nothing needs to know about it //This method can, however, be called so that, for example, the editor can switch parameters to a junk data source. }
public void AddJumpTo(DynamicEnumParameter.Source jumpSource) { AddNode(); }
public GraphData(Id <NodeTemp> nodeId, Id <NodeTypeTemp> nodeTypeId, IEnumerable <NodeDataGeneratorParameterData> parameterData) { NodeId = nodeId; NodeTypeId = nodeTypeId; var allConnectorsDefinition = new ConnectorDefinitionData(null, null, null, null, false); var outputs = new List <Output>(); var parameters = new List <IParameter>(); DecimalParameter.Definition d = new DecimalParameter.Definition(null, null); ParameterType decimalType = ParameterType.Basic.Parse("721796b6-a242-4723-82e9-35201097e675"); ParameterType dynamicEnumType = ParameterType.Basic.Parse("6d2d52c8-5934-4ba8-8d4e-7081fe57f662"); DynamicEnumParameter.Source source = new DynamicEnumParameter.Source(); IEnumeration enumeration = new DummyEnumeration(); ParameterType integerEnumType = ParameterType.Basic.Parse("de108fdb-db50-4cd5-aad5-0ea791f04721"); IntegerParameter.Definition i = new IntegerParameter.Definition(null, null); AudioParameter = new AudioParameter("Audio", Id <Parameter> .Parse("3ac8d0ca-c9f6-4e06-b18c-c1366e1af7d3")); BooleanParameter = new BooleanParameter("Boolean", Id <Parameter> .Parse("0e12e8e3-4c95-43a5-a733-d2d1fbbb780c"), "false"); DecimalParameter = new DecimalParameter("Decimal", Id <Parameter> .Parse("765e616a-f165-4053-a15c-14ed593429af"), decimalType, d, "1.0"); DynamicEnumParameter = new DynamicEnumParameter("DynamicEnum", Id <Parameter> .Parse("7c5b019c-79d0-4ef0-b848-0a2c68908f34"), source, dynamicEnumType, "shnae", false); EnumParameter = new EnumParameter("Enum", Id <Parameter> .Parse("e576713b-5d45-48d0-8a4e-661f1fedcafd"), enumeration, enumeration.DefaultValue.ToString()); IntegerParameter = new IntegerParameter("Int", Id <Parameter> .Parse("275d75f3-fe4e-42b1-bfaf-e841ba591999"), integerEnumType, i, "1"); LocalizedStringParameter = new LocalizedStringParameter("Localized stirng", Id <Parameter> .Parse("f332e619-e9a3-421f-9851-d95a00b62da9"), ParameterType.Basic.Parse("4547dbf2-46cc-4c84-ac6e-81ab185575dc")); SetParameter = new SetParameter("Set", Id <Parameter> .Parse("2d6235ea-c8a1-447a-b9d8-692f6329be33"), enumeration, null); StringParameter = new StringParameter("string", Id <Parameter> .Parse("4752d30e-e1ab-47ba-bc15-b2e6ecfa5416")); StringParameter2 = new StringParameter("string2", Id <Parameter> .Parse("dcd4a349-b0a8-4fa3-8989-2d10469b1a17")); if (nodeTypeId == TYPE1) { outputs.Add(new Output(Id <TConnector> .Parse("0956c9d3-c230-49a2-874a-7e3747b58cff"), allConnectorsDefinition, this, null, DummyRules.Instance)); parameters.Add(AudioParameter); parameters.Add(BooleanParameter); parameters.Add(DecimalParameter); parameters.Add(DynamicEnumParameter); parameters.Add(EnumParameter); } else if (nodeTypeId == TYPE2) { outputs.Add(new Output(Id <TConnector> .Parse("da2b4ded-378e-4484-89f0-1328a42f00e3"), allConnectorsDefinition, this, null, DummyRules.Instance)); outputs.Add(new Output(Id <TConnector> .Parse("2bf2ca93-6b81-4a9a-814f-809a8bef332f"), allConnectorsDefinition, this, null, DummyRules.Instance)); parameters.Add(IntegerParameter); parameters.Add(LocalizedStringParameter); parameters.Add(SetParameter); parameters.Add(StringParameter); } else if (nodeTypeId == TYPE3) { outputs.Add(new Output(Id <TConnector> .Parse("c3f67c87-a3fd-428d-90a2-90cb87906eb2"), allConnectorsDefinition, this, null, DummyRules.Instance)); parameters.Add(StringParameter); parameters.Add(StringParameter2); } else { Assert.Fail("Unexpected Id"); } if (parameterData != null) { foreach (var data in parameterData) { parameters.Where(p => p.Id == data.Guid).Single().TryDeserialiseValue(data.Value); } } Connectors = outputs; Parameters = parameters; }
public static void Test() { string name = "asdg"; Id <Parameter> id = Id <Parameter> .Parse("F2EA9FA2-61C4-45A0-BFA7-906349445AD8"); DynamicEnumParameter.Source source = new DynamicEnumParameter.Source(); ParameterType type = ParameterType.Parse("623014BC-EA1D-4230-9B33-DEA1BD43C0E2"); DynamicEnumParameter p = new DynamicEnumParameter(name, id, source, type, "shane", true); Assert.That(p.Local, Is.True); Assert.That(p.Name, Is.EqualTo(name)); Assert.That(p.Id, Is.EqualTo(id)); Assert.That(p.TypeId, Is.EqualTo(type)); Assert.That(p.Options, Is.EquivalentTo(source.Options)); Assert.That(source.Options, Is.EquivalentTo(new[] { "shane" })); CheckValue(p, "shane"); DynamicEnumParameter another = new DynamicEnumParameter("another", Id <Parameter> .Parse("08573582-A196-454A-B911-5F291EFC3C69"), source, ParameterType.Parse("6D14FFB5-3F2A-4865-9B6D-0F215B6F0EFC"), "asd", true); Action <string[]> CheckOptions = options => { Assert.That(p.Options, Is.EquivalentTo(source.Options)); Assert.That(another.Options, Is.EquivalentTo(source.Options)); Assert.That(source.Options, Is.EquivalentTo(options)); }; CheckOptions(new[] { "shane", "asd" }); Assert.That(() => p.SetValueAction(null), Throws.ArgumentException); var action = p.SetValueAction("set"); Assert.That(action, Is.Not.Null); CheckValue(p, "shane"); CheckOptions(new[] { "shane", "asd" }); action.Value.Redo(); CheckValue(p, "set"); CheckOptions(new[] { "set", "asd" }); action.Value.Undo(); CheckValue(p, "shane"); CheckOptions(new[] { "shane", "asd" }); Assert.Throws <ArgumentNullException>(() => { p.TryDeserialiseValue(null); }); CheckValue(p, "shane"); p.TryDeserialiseValue("dasfafd"); CheckValue(p, "dasfafd"); CheckOptions(new[] { "dasfafd", "asd" }); DynamicEnumParameter.Source source2 = new DynamicEnumParameter.Source(); DynamicEnumParameter third = new DynamicEnumParameter("another", Id <Parameter> .Parse("7DF52211-236E-4848-8117-6B15C51A21EB"), source2, ParameterType.Parse("B117246A-3092-41A5-AEB1-93F7E1F77E32"), "asd2", true); p.MergeInto(source2); Assert.That(p.Options, Is.EquivalentTo(source2.Options)); Assert.That(third.Options, Is.EquivalentTo(source2.Options)); Assert.That(another.Options, Is.EquivalentTo(source.Options)); Assert.That(source.Options, Is.EquivalentTo(new[] { "asd" })); Assert.That(source2.Options, Is.EquivalentTo(new[] { "dasfafd", "asd2" })); }