public void SliceList() { var data = new Dictionary <string, object>(); data.Add("name", "Partition List"); controller.CommandQueue.Enqueue(Tuple.Create <object, object>(controller.DynamoViewModel.CreateNodeCommand, data)); controller.ProcessCommandQueue(); //Create a List //For a list of 0..20, this will have 21 elements //Slicing by 5 should return 6 lists, the last containing one element var list = Utils.MakeFSharpList(Enumerable.Range(0, 21).Select(x => FScheme.Value.NewNumber(x)).ToArray()); var sliceNode = (dynSlice)controller.DynamoModel.Nodes.First(x => x is dynSlice); var args = FSharpList <FScheme.Value> .Empty; args = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewNumber(5), args); args = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewList(list), args); var res = sliceNode.Evaluate(args); //confirm we have a list Assert.IsTrue(res.IsList); //confirm the correct number of sublists Assert.AreEqual(5, ((FScheme.Value.List)res).Item.Count()); //test if you pass in an empty list //should return just one list - the original args = FSharpList <FScheme.Value> .Empty; args = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewNumber(5), args); args = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewList(FSharpList <FScheme.Value> .Empty), args); res = sliceNode.Evaluate(args); Assert.AreEqual(0, ((FScheme.Value.List)res).Item.Count()); //test if you pass in a list wwith less elements than the //slice, you should just get back the same list list = Utils.MakeFSharpList(Enumerable.Range(0, 1).Select(x => FScheme.Value.NewNumber(x)).ToArray()); args = FSharpList <FScheme.Value> .Empty; args = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewNumber(5), args); args = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewList(list), args); res = sliceNode.Evaluate(args); Assert.AreEqual(1, ((FScheme.Value.List)res).Item.Count()); }
public void CanOpenGoodFile() { string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string openPath = Path.Combine(directory, @"..\..\test\dynamo_elements_samples\working\multiplicationAndAdd\multiplicationAndAdd.dyn"); controller.CommandQueue.Enqueue(Tuple.Create <object, object>(controller.DynamoViewModel.OpenCommand, openPath)); controller.ProcessCommandQueue(); Assert.AreEqual(5, controller.DynamoViewModel.CurrentSpace.Nodes.Count); }