Default orientation is Horiz

This commit is contained in:
Tig
2024-07-22 13:24:24 -06:00
parent 16b374bae4
commit 2097a17213
3 changed files with 11 additions and 10 deletions

View File

@@ -46,7 +46,7 @@
/// </example>
public class OrientationHelper
{
private Orientation _orientation = Orientation.Vertical;
private Orientation _orientation;
private readonly IOrientation _owner;
/// <summary>

View File

@@ -108,6 +108,7 @@ public class RadioGroup : View, IDesignable, IOrientation
});
_orientationHelper = new (this);
_orientationHelper.Orientation = Orientation.Vertical;
_orientationHelper.OrientationChanging += (sender, e) => OrientationChanging?.Invoke (this, e);
_orientationHelper.OrientationChanged += (sender, e) => OrientationChanged?.Invoke (this, e);

View File

@@ -17,7 +17,7 @@ public class OrientationHelperTests
orientationHelper.OrientationChanged += (sender, e) => { changedEventInvoked = true; };
// Act
orientationHelper.Orientation = Orientation.Horizontal;
orientationHelper.Orientation = Orientation.Vertical;
// Assert
Assert.True (changingEventInvoked, "OrientationChanging event was not invoked.");
@@ -42,7 +42,7 @@ public class OrientationHelperTests
var orientationHelper = new OrientationHelper (mockIOrientation.Object);
// Act
orientationHelper.Orientation = Orientation.Horizontal;
orientationHelper.Orientation = Orientation.Vertical;
// Assert
Assert.True (onChangingOverrideCalled, "OnOrientationChanging override was not called.");
@@ -55,7 +55,7 @@ public class OrientationHelperTests
// Arrange
Mock<IOrientation> mockIOrientation = new Mock<IOrientation> ();
var orientationHelper = new OrientationHelper (mockIOrientation.Object);
orientationHelper.Orientation = Orientation.Vertical; // Set initial orientation
orientationHelper.Orientation = Orientation.Horizontal; // Set initial orientation
var changingEventInvoked = false;
var changedEventInvoked = false;
@@ -63,7 +63,7 @@ public class OrientationHelperTests
orientationHelper.OrientationChanged += (sender, e) => { changedEventInvoked = true; };
// Act
orientationHelper.Orientation = Orientation.Vertical; // Set to the same value
orientationHelper.Orientation = Orientation.Horizontal; // Set to the same value
// Assert
Assert.False (changingEventInvoked, "OrientationChanging event was invoked.");
@@ -79,10 +79,10 @@ public class OrientationHelperTests
orientationHelper.OrientationChanging += (sender, e) => { e.Cancel = true; }; // Cancel the change
// Act
orientationHelper.Orientation = Orientation.Horizontal;
orientationHelper.Orientation = Orientation.Vertical;
// Assert
Assert.Equal (Orientation.Vertical, orientationHelper.Orientation); // Initial orientation is Vertical
Assert.Equal (Orientation.Horizontal, orientationHelper.Orientation); // Initial orientation is Horizontal
}
[Fact]
@@ -97,11 +97,11 @@ public class OrientationHelperTests
var orientationHelper = new OrientationHelper (mockIOrientation.Object);
// Act
orientationHelper.Orientation = Orientation.Horizontal;
orientationHelper.Orientation = Orientation.Vertical;
// Assert
Assert.Equal (
Orientation.Vertical,
orientationHelper.Orientation); // Initial orientation is Vertical, and it should remain unchanged due to cancellation
Orientation.Horizontal,
orientationHelper.Orientation); // Initial orientation is Horizontal, and it should remain unchanged due to cancellation
}
}