public void calculate_segment_is_directional_Is_multi_action() { var map = new HOTASAxis(); map.IsDirectional = true; map.IsMultiAction = true;//should create action button map for each segment map.ButtonMap.Clear(); map.ReverseButtonMap.Clear(); map.CalculateSegmentRange(3); Assert.NotEmpty(map.Segments); Assert.Equal(3, map.Segments.Count); Assert.NotEmpty(map.ButtonMap); Assert.Equal("Axis Button 1", map.ButtonMap[0].MapName); Assert.Equal("Axis Button 2", map.ButtonMap[1].MapName); Assert.Equal("Axis Button 3", map.ButtonMap[2].MapName); Assert.NotEmpty(map.ReverseButtonMap); Assert.Equal("Reverse Axis Button 1", map.ReverseButtonMap[0].MapName); Assert.Equal("Reverse Axis Button 2", map.ReverseButtonMap[1].MapName); Assert.Equal("Reverse Axis Button 3", map.ReverseButtonMap[2].MapName); map.CalculateSegmentRange(4); Assert.Equal(4, map.Segments.Count); Assert.Equal("Axis Button 4", map.ButtonMap[3].MapName); Assert.Equal(4, map.Segments.Count); Assert.Equal("Reverse Axis Button 4", map.ReverseButtonMap[3].MapName); }
public void get_button_from_raw_value_backward_directional_not_multi_action() { var map = new HOTASAxis(); map.IsDirectional = true; map.IsMultiAction = false; map.CalculateSegmentRange(4); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(800); map.SetAxis(700);//set direction backward Assert.Equal("Reverse Axis Button 1", map.GetButtonMapFromRawValue(16383).MapName); Assert.Equal("Reverse Axis Button 1", map.GetButtonMapFromRawValue(32766).MapName); Assert.Equal("Reverse Axis Button 1", map.GetButtonMapFromRawValue(49149).MapName); Assert.Equal("Reverse Axis Button 1", map.GetButtonMapFromRawValue(65535).MapName); }
public void calculate_segment_is_directional_is_multi_action_less_segments_than_buttons() { var map = new HOTASAxis(); map.IsDirectional = true; map.IsMultiAction = true;//should create action button map for each segment map.ButtonMap.Clear(); map.ReverseButtonMap.Clear(); map.ReverseButtonMap.Add(new HOTASButton() { MapName = "kept" }); map.ReverseButtonMap.Add(new HOTASButton() { MapName = "removed 1" }); map.ReverseButtonMap.Add(new HOTASButton() { MapName = "removed 2" }); map.CalculateSegmentRange(1); Assert.NotEmpty(map.Segments); Assert.Single(map.Segments); Assert.NotEmpty(map.ButtonMap); Assert.NotEmpty(map.ReverseButtonMap); Assert.Equal("kept", map.ReverseButtonMap[0].MapName); }
public void calculate_segment_is_directional_not_multi_action_existing_buttons() { var map = new HOTASAxis(); map.IsDirectional = true; map.IsMultiAction = false;//should leave a single action button map list map.ButtonMap.Add(new HOTASButton() { MapName = "kept" }); map.ButtonMap.Add(new HOTASButton() { MapName = "removed" }); map.ReverseButtonMap.Add(new HOTASButton() { MapName = "kept" }); map.ReverseButtonMap.Add(new HOTASButton() { MapName = "removed" }); map.CalculateSegmentRange(2); Assert.NotEmpty(map.Segments); Assert.Equal(2, map.Segments.Count); Assert.Single(map.ButtonMap); Assert.Equal("kept", map.ButtonMap[0].MapName); Assert.Single(map.ReverseButtonMap); Assert.Equal("kept", map.ReverseButtonMap[0].MapName); }
public void get_segment_from_raw_value_not_found() { var map = new HOTASAxis(); map.CalculateSegmentRange(4); Assert.Equal(4, map.Segments.Count); Assert.Equal(0, map.GetSegmentFromRawValue(65536)); }
public void clear_segments() { var map = new HOTASAxis(); map.CalculateSegmentRange(4); Assert.Equal(4, map.Segments.Count); map.ClearSegments(); Assert.Empty(map.Segments); }
public void segment_boundary_test() { var map = new HOTASAxis(); map.CalculateSegmentRange(4); map.Segments[0].Value = 34000;//adjusting the first segment passed the second segment will pump the second segment up by 655 passed the new value of the first segment Assert.Equal(34655, map.Segments[1].Value); map.Segments[3].Value = ushort.MaxValue + 100;//can't push the last segment any further Assert.Equal(64880, map.Segments[3].Value); }
public void calculate_segment_range_no_segments() { var map = new HOTASAxis(); map.ButtonMap.Add(new HOTASButton()); map.ReverseButtonMap.Add(new HOTASButton()); map.CalculateSegmentRange(0); Assert.Empty(map.Segments); Assert.Empty(map.ButtonMap); Assert.Empty(map.ReverseButtonMap); }
public void get_button_from_raw_value_forward_directional_is_multi_action() { var map = new HOTASAxis(); map.IsDirectional = true; map.IsMultiAction = true; map.CalculateSegmentRange(4); Assert.Equal("Axis Button 1", map.GetButtonMapFromRawValue(16383).MapName); Assert.Equal("Axis Button 2", map.GetButtonMapFromRawValue(32766).MapName); Assert.Equal("Axis Button 3", map.GetButtonMapFromRawValue(49149).MapName); Assert.Equal("Axis Button 4", map.GetButtonMapFromRawValue(65535).MapName); }
public void get_segment_from_raw_value() { var map = new HOTASAxis(); map.CalculateSegmentRange(4); Assert.Equal(4, map.Segments.Count); Assert.Equal(1, map.GetSegmentFromRawValue(0)); Assert.Equal(1, map.GetSegmentFromRawValue(16383)); Assert.Equal(2, map.GetSegmentFromRawValue(16384)); Assert.Equal(2, map.GetSegmentFromRawValue(32766)); Assert.Equal(3, map.GetSegmentFromRawValue(32767)); Assert.Equal(3, map.GetSegmentFromRawValue(49149)); Assert.Equal(4, map.GetSegmentFromRawValue(49150)); Assert.Equal(4, map.GetSegmentFromRawValue(65535)); }
public void calculate_segment_not_directional_not_multi_action() { var map = new HOTASAxis(); map.IsDirectional = false; map.IsMultiAction = false;//should create single action button map list map.ButtonMap.Clear(); map.ReverseButtonMap.Clear(); map.CalculateSegmentRange(2); Assert.NotEmpty(map.Segments); Assert.Equal(2, map.Segments.Count); Assert.NotEmpty(map.ButtonMap); Assert.Equal("Axis Button 1", map.ButtonMap[0].MapName); Assert.Empty(map.ReverseButtonMap); }