private IEnumerable <IInputInput> _GetInputs(SlimDX.DirectInput.Joystick device) { foreach (DeviceObjectInstance deviceObjectInstance in device.GetObjects()) { JoystickInput input = null; if (_IsButton(deviceObjectInstance)) { input = new Button(deviceObjectInstance.Name, deviceObjectInstance.Usage); } else if (_IsAxis(deviceObjectInstance)) { input = _IsRotationAxis(deviceObjectInstance) ? _CreateRotationAxis(deviceObjectInstance) : _CreateAxis(deviceObjectInstance); } else if (_IsPov(deviceObjectInstance)) { input = new Pov(deviceObjectInstance.Name, deviceObjectInstance.DesignatorIndex); } if (input != null) { yield return(input); } } }
public void Errors_if_target_does_not_exist_in_a_singleton_tree() { var tree = new Tree("x"); var from = "nonexistent"; Assert.Throws <ArgumentException>(() => Pov.FromPov(tree, from)); }
public void Errors_if_target_does_not_exist_in_a_large_tree() { var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")); var from = "nonexistent"; Assert.Throws <ArgumentException>(() => Pov.FromPov(tree, from)); }
public void Errors_if_source_does_not_exist() { var from = "nonexistent"; var to = "x"; var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")); Assert.Throws <ArgumentException>(() => Pov.PathTo(from, to, tree)); }
public void Can_reroot_a_tree_with_a_parent_and_many_siblings() { var tree = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c")); var from = "x"; var expected = new Tree("x", new Tree("parent", new Tree("a"), new Tree("b"), new Tree("c"))); Assert.Equal(expected, Pov.FromPov(tree, from)); }
public void Can_reroot_a_tree_with_new_root_deeply_nested_in_tree() { var tree = new Tree("level-0", new Tree("level-1", new Tree("level-2", new Tree("level-3", new Tree("x"))))); var from = "x"; var expected = new Tree("x", new Tree("level-3", new Tree("level-2", new Tree("level-1", new Tree("level-0"))))); Assert.Equal(expected, Pov.FromPov(tree, from)); }
public void Moves_children_of_the_new_root_to_same_level_as_former_parent() { var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1"))); var from = "x"; var expected = new Tree("x", new Tree("kid-0"), new Tree("kid-1"), new Tree("parent")); Assert.Equal(expected, Pov.FromPov(tree, from)); }
public void Can_reroot_a_complex_tree_with_cousins() { var tree = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1"))); var from = "x"; var expected = new Tree("x", new Tree("kid-1"), new Tree("kid-0"), new Tree("parent", new Tree("sibling-0"), new Tree("sibling-1"), new Tree("grandparent", new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1"))))); Assert.Equal(expected, Pov.FromPov(tree, from)); }
public void Results_in_the_same_tree_if_the_input_tree_is_a_singleton() { var tree = new Tree("x"); var from = "x"; var expected = new Tree("x"); Assert.Equal(expected, Pov.FromPov(tree, from)); }
public void Can_find_path_not_involving_root() { var from = "x"; var to = "sibling-1"; var tree = new Tree("grandparent", new Tree("parent", new Tree("x"), new Tree("sibling-0"), new Tree("sibling-1"))); var expected = new[] { "x", "parent", "sibling-1" }; Assert.Equal(expected, Pov.PathTo(from, to, tree)); }
public void Can_find_path_to_sibling() { var from = "x"; var to = "b"; var tree = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c")); var expected = new[] { "x", "parent", "b" }; Assert.Equal(expected, Pov.PathTo(from, to, tree)); }
public void Can_find_path_from_nodes_other_than_x() { var from = "a"; var to = "c"; var tree = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c")); var expected = new[] { "a", "parent", "c" }; Assert.Equal(expected, Pov.PathTo(from, to, tree)); }
public void Should_not_be_able_to_find_a_missing_node() { var nodes = new[] { singleton, flat, kids, nested, cousins }.Select(graph => Pov.FromPOV("NOT THERE", graph)); Assert.All(nodes, node => { Assert.Null(node); }); }
public void Can_find_path_to_cousin() { var from = "x"; var to = "cousin-1"; var tree = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1"))); var expected = new[] { "x", "parent", "grandparent", "uncle", "cousin-1" }; Assert.Equal(expected, Pov.PathTo(from, to, tree)); }
public override JsonCollection BuildParams() { JsonCollection options = new JsonCollection(false); options.Add("addressControl", AddressControl.Value, AddressControl.HasValue, typeof(bool)); options.Add("addressControlOptions", AddressControlOptions.ToString(), AddressControlOptions != null); options.Add("disableDoubleClickZoom", DisableDoubleClickZoom.Value, DisableDoubleClickZoom.HasValue, typeof(bool)); options.Add("enableCloseButton", EnableCloseButton.Value, EnableCloseButton.HasValue, typeof(bool)); options.Add("imageDateControl", ImageDateControl.Value, ImageDateControl.HasValue, typeof(bool)); options.Add("linksControl", LinksControl.Value, LinksControl.HasValue, typeof(bool)); options.Add("panControl", PanControl.Value, PanControl.HasValue, typeof(bool)); options.Add("panControlOptions", PanControlOptions.ToString(), PanControlOptions != null); options.Add("pano", Pano, !string.IsNullOrEmpty(Pano), typeof(string)); options.Add("panoProvider", PanoProvider, !string.IsNullOrEmpty(PanoProvider)); options.Add("position", Position.ToStringNew(), Position != null); options.Add("pov", Pov.ToString(), Pov != null); options.Add("scrollwheel", Scrollwheel.Value, Scrollwheel.HasValue, typeof(bool)); options.Add("visible", Visible.Value, Visible.HasValue, typeof(bool)); options.Add("zoomControl", ZoomControl.Value, ZoomControl.HasValue, typeof(bool)); options.Add("zoomControlOptions", ZoomControlOptions.ToString(), ZoomControlOptions != null); return(options); }
public void Can_trace_from_a_leaf_to_a_leaf() { Assert.Equal(new[] { "kid-a", "x", "parent", "grandparent", "uncle", "cousin-0" }, Pov.TracePathBetween("kid-a", "cousin-0", cousins)); }
public void Reparent_singleton() { Assert.Equal(singleton_, Pov.FromPOV(x, singleton)); }
public void Reparent_flat() { Assert.Equal(flat_, Pov.FromPOV(x, flat)); }
public void Reparent_nested() { Assert.That(Pov.FromPOV(x, nested), Is.EqualTo(nested_)); }
public void Cannot_trace_between_unconnected_nodes() { Assert.That(Pov.TracePathBetween(x, "NOT THERE", cousins), Is.Null); }
public void Reparent_kids() { Assert.That(Pov.FromPOV(x, kids), Is.EqualTo(kids_)); }
public void Reparent_flat() { Assert.That(Pov.FromPOV(x, flat), Is.EqualTo(flat_)); }
public void Reparent_singleton() { Assert.That(Pov.FromPOV(x, singleton), Is.EqualTo(singleton_)); }
public void Reparent_cousins() { Assert.That(Pov.FromPOV(x, cousins), Is.EqualTo(cousins_)); }
public void Can_trace_a_path_from_x_to_cousin() { Assert.That(Pov.TracePathBetween(x, "cousin-1", cousins), Is.EquivalentTo(new[] { "x", "parent", "grandparent", "uncle", "cousin-1" })); }
public void Can_trace_a_path_from_x_to_cousin() { Assert.Equal(new[] { "x", "parent", "grandparent", "uncle", "cousin-1" }, Pov.TracePathBetween(x, "cousin-1", cousins)); }
public void Can_trace_from_a_leaf_to_a_leaf() { Assert.That(Pov.TracePathBetween("kid-a", "cousin-0", cousins), Is.EquivalentTo(new[] { "kid-a", "x", "parent", "grandparent", "uncle", "cousin-0" })); }
public void Reparent_from_POV_of_non_existent_node() { Assert.That(Pov.FromPOV(x, leaf("foo")), Is.Null); }
private static Graph <T> leaf <T>(T v) => Pov.CreateGraph(v, new Graph <T> [0]);
public void Reparent_cousins() { Assert.Equal(cousins_, Pov.FromPOV(x, cousins)); }