mirror of https://github.com/AMT-Cheif/Stylet.git
Add default FlowDirection and TextAlignment to MessageBoxViweModel
This removes the MessageBoxOptions input to MessageBoxViewModel, and replaces it with explicit FlowDirection and TextAlignment inputs. I think this is fair enough - we weren't using most of the members of MessageBoxOptions, so allowing them to be provided was misleading. Fixes #12
This commit is contained in:
parent
6dd8c072c1
commit
ffb218d666
|
@ -15,14 +15,15 @@ namespace Stylet
|
|||
/// <summary>
|
||||
/// Setup the MessageBoxViewModel with the information it needs
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A System.Windows.MessageBoxResult value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A System.Windows.MessageBoxResult value that specifies the cancel result of the message box</param>
|
||||
/// <param name="options">A System.Windows.MessageBoxOptions value object that specifies the options.</param>
|
||||
/// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
|
||||
/// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
|
||||
/// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
|
||||
/// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
|
||||
/// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
|
||||
void Setup(
|
||||
string messageBoxText,
|
||||
string caption = null,
|
||||
|
@ -30,8 +31,9 @@ namespace Stylet
|
|||
MessageBoxImage icon = MessageBoxImage.None,
|
||||
MessageBoxResult defaultResult = MessageBoxResult.None,
|
||||
MessageBoxResult cancelResult = MessageBoxResult.None,
|
||||
MessageBoxOptions options = MessageBoxOptions.None,
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null);
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null,
|
||||
FlowDirection? flowDirection = null,
|
||||
TextAlignment? textAlignment = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the button clicked by the user, after they've clicked it
|
||||
|
@ -64,6 +66,16 @@ namespace Stylet
|
|||
/// </summary>
|
||||
public static IDictionary<MessageBoxImage, SystemSound> SoundMapping { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default <see cref="System.Windows.FlowDirection"/> to use
|
||||
/// </summary>
|
||||
public static FlowDirection DefaultFlowDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default <see cref="System.Windows.TextAlignment"/> to use
|
||||
/// </summary>
|
||||
public static TextAlignment DefaultTextAlignment { get; set; }
|
||||
|
||||
static MessageBoxViewModel()
|
||||
{
|
||||
ButtonLabels = new Dictionary<MessageBoxResult, string>()
|
||||
|
@ -100,19 +112,23 @@ namespace Stylet
|
|||
{ MessageBoxImage.Exclamation, SystemSounds.Exclamation },
|
||||
{ MessageBoxImage.Information, SystemSounds.Asterisk },
|
||||
};
|
||||
|
||||
DefaultFlowDirection = FlowDirection.LeftToRight;
|
||||
DefaultTextAlignment = TextAlignment.Left;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup the MessageBoxViewModel with the information it needs
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A System.Windows.MessageBoxResult value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A System.Windows.MessageBoxResult value that specifies the cancel result of the message box</param>
|
||||
/// <param name="options">A System.Windows.MessageBoxOptions value object that specifies the options.</param>
|
||||
/// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
|
||||
/// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
|
||||
/// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
|
||||
/// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
|
||||
/// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
|
||||
public void Setup(
|
||||
string messageBoxText,
|
||||
string caption = null,
|
||||
|
@ -120,8 +136,9 @@ namespace Stylet
|
|||
MessageBoxImage icon = MessageBoxImage.None,
|
||||
MessageBoxResult defaultResult = MessageBoxResult.None,
|
||||
MessageBoxResult cancelResult = MessageBoxResult.None,
|
||||
MessageBoxOptions options = MessageBoxOptions.None,
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null)
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null,
|
||||
FlowDirection? flowDirection = null,
|
||||
TextAlignment? textAlignment = null)
|
||||
{
|
||||
this.Text = messageBoxText;
|
||||
this.DisplayName = caption;
|
||||
|
@ -158,8 +175,8 @@ namespace Stylet
|
|||
throw new ArgumentException("CancelButton set to a button which doesn't appear in Buttons");
|
||||
}
|
||||
|
||||
this.FlowDirection = options.HasFlag(MessageBoxOptions.RtlReading) ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
|
||||
this.TextAlignment = (options.HasFlag(MessageBoxOptions.RightAlign) == options.HasFlag(MessageBoxOptions.RtlReading)) ? TextAlignment.Left : TextAlignment.Right;
|
||||
this.FlowDirection = flowDirection ?? DefaultFlowDirection;
|
||||
this.TextAlignment = textAlignment ?? DefaultTextAlignment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -28,22 +28,24 @@ namespace Stylet
|
|||
/// <summary>
|
||||
/// Display a MessageBox
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A System.Windows.MessageBoxResult value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A System.Windows.MessageBoxResult value that specifies the cancel result of the message box</param>
|
||||
/// <param name="options">A System.Windows.MessageBoxOptions value object that specifies the options.</param>
|
||||
/// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
|
||||
/// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
|
||||
/// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
|
||||
/// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
|
||||
/// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
|
||||
/// <returns>The result chosen by the user</returns>
|
||||
MessageBoxResult ShowMessageBox(string messageBoxText, string caption = null,
|
||||
MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "",
|
||||
MessageBoxButton buttons = MessageBoxButton.OK,
|
||||
MessageBoxImage icon = MessageBoxImage.None,
|
||||
MessageBoxResult defaultResult = MessageBoxResult.None,
|
||||
MessageBoxResult cancelResult = MessageBoxResult.None,
|
||||
MessageBoxOptions options = MessageBoxOptions.None,
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null);
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null,
|
||||
FlowDirection? flowDirection = null,
|
||||
TextAlignment? textAlignment = null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -103,25 +105,27 @@ namespace Stylet
|
|||
/// <summary>
|
||||
/// Display a MessageBox
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A System.Windows.MessageBoxResult value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A System.Windows.MessageBoxResult value that specifies the cancel result of the message box</param>
|
||||
/// <param name="options">A System.Windows.MessageBoxOptions value object that specifies the options.</param>
|
||||
/// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
|
||||
/// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
|
||||
/// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
|
||||
/// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
|
||||
/// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
|
||||
/// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
|
||||
/// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
|
||||
/// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
|
||||
/// <returns>The result chosen by the user</returns>
|
||||
public MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "",
|
||||
MessageBoxButton buttons = MessageBoxButton.OK,
|
||||
MessageBoxImage icon = MessageBoxImage.None,
|
||||
MessageBoxResult defaultResult = MessageBoxResult.None,
|
||||
MessageBoxResult cancelResult = MessageBoxResult.None,
|
||||
MessageBoxOptions options = MessageBoxOptions.None,
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null)
|
||||
IDictionary<MessageBoxResult, string> buttonLabels = null,
|
||||
FlowDirection? flowDirection = null,
|
||||
TextAlignment? textAlignment = null)
|
||||
{
|
||||
var vm = this.messageBoxViewModelFactory();
|
||||
vm.Setup(messageBoxText, caption, buttons, icon, defaultResult, cancelResult, options, buttonLabels);
|
||||
vm.Setup(messageBoxText, caption, buttons, icon, defaultResult, cancelResult, buttonLabels, flowDirection, textAlignment);
|
||||
// Don't go through the IoC container to get the View. This means we can simplify it...
|
||||
var messageBoxView = new MessageBoxView();
|
||||
messageBoxView.InitializeComponent();
|
||||
|
|
|
@ -31,31 +31,31 @@ namespace StyletUnitTests
|
|||
[Test]
|
||||
public void SetsTextCorrectly()
|
||||
{
|
||||
this.vm.Setup("this is the text", null, MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup("this is the text", null, MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual("this is the text", this.vm.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeterminesTextIsMultilineCorrectly()
|
||||
{
|
||||
this.vm.Setup("this is the text", null, MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup("this is the text", null, MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.IsFalse(this.vm.TextIsMultiline);
|
||||
|
||||
this.vm.Setup("hello\nworld", null, MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup("hello\nworld", null, MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.IsTrue(this.vm.TextIsMultiline);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetsTitleCorrectly()
|
||||
{
|
||||
this.vm.Setup(null, "this is the title", MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, "this is the title", MessageBoxButton.OK, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual("this is the title", this.vm.DisplayName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisplaysRequestedButtons()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
var buttons = vm.ButtonList.ToList();
|
||||
Assert.AreEqual(2, buttons.Count);
|
||||
Assert.AreEqual("OK", buttons[0].Label);
|
||||
|
@ -67,47 +67,47 @@ namespace StyletUnitTests
|
|||
[Test]
|
||||
public void SetsDefaultButtonToTheRequestedButton()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.None, MessageBoxResult.Cancel, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.None, MessageBoxResult.Cancel, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual(this.vm.ButtonList.ElementAt(1), this.vm.DefaultButton);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetsDefaultToLeftmostButtonIfDefaultRequested()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual(this.vm.ButtonList.ElementAt(0), this.vm.DefaultButton);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThrowsIfTheRequestedDefaultButtonIsNotDisplayed()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => this.vm.Setup(null, null, MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Yes, MessageBoxResult.None, MessageBoxOptions.None, null));
|
||||
Assert.Throws<ArgumentException>(() => this.vm.Setup(null, null, MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Yes, MessageBoxResult.None, null, null, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetsCancelButtonToTheRequestedButton()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.YesNoCancel, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.No, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.YesNoCancel, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.No, null, null, null);
|
||||
Assert.AreEqual(this.vm.ButtonList.ElementAt(1), this.vm.CancelButton);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetsCancelToRighmostButtonIfDefaultRequested()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual(this.vm.ButtonList.ElementAt(1), this.vm.CancelButton);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThrowsIfRequestedCancelButtonIsNotDisplayed()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.No, MessageBoxOptions.None, null));
|
||||
Assert.Throws<ArgumentException>(() => this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.No, null, null, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetsIconCorrectly()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual(SystemIcons.Exclamation, this.vm.ImageIcon);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace StyletUnitTests
|
|||
{
|
||||
var parent = new Mock<IChildDelegate>();
|
||||
this.vm.Parent = parent.Object;
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
|
||||
this.vm.ButtonClicked(MessageBoxResult.No);
|
||||
|
||||
|
@ -129,17 +129,17 @@ namespace StyletUnitTests
|
|||
{
|
||||
var vm = new MyMessageBoxViewModel();
|
||||
// Can't test it actually playing the sound
|
||||
vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.DoesNotThrow(() => vm.OnViewLoaded());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ButtonTextOverridesWork()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, new Dictionary<MessageBoxResult, string>()
|
||||
this.vm.Setup(null, null, MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, new Dictionary<MessageBoxResult, string>()
|
||||
{
|
||||
{ MessageBoxResult.Cancel, "YAY!" },
|
||||
});
|
||||
}, null, null);
|
||||
Assert.AreEqual("OK", this.vm.ButtonList.ElementAt(0).Label);
|
||||
Assert.AreEqual("YAY!", this.vm.ButtonList.ElementAt(1).Label);
|
||||
}
|
||||
|
@ -147,43 +147,29 @@ namespace StyletUnitTests
|
|||
[Test]
|
||||
public void FlowsLeftToRightByDefault()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual(FlowDirection.LeftToRight, this.vm.FlowDirection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FlowsRightToLeftIfRequested()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.RtlReading, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, FlowDirection.RightToLeft, null);
|
||||
Assert.AreEqual(FlowDirection.RightToLeft, this.vm.FlowDirection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AlignsLeftIfLeftToRightByDefault()
|
||||
public void AlignsLeftByDefault()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.None, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, null);
|
||||
Assert.AreEqual(TextAlignment.Left, this.vm.TextAlignment);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AlignsRightIfLeftToRightAndRequested()
|
||||
public void AlignsRightIfRequested()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.RightAlign, null);
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, null, null, TextAlignment.Right);
|
||||
Assert.AreEqual(TextAlignment.Right, this.vm.TextAlignment);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AlignsRightIfRightToLeftByDefault()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.RtlReading, null);
|
||||
Assert.AreEqual(TextAlignment.Right, this.vm.TextAlignment);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AlignsLeftIfRightToLeftAndRequested()
|
||||
{
|
||||
this.vm.Setup(null, null, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxResult.None, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading, null);
|
||||
Assert.AreEqual(TextAlignment.Left, this.vm.TextAlignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,10 +325,10 @@ namespace StyletUnitTests
|
|||
{
|
||||
var wm = new WindowManagerWithoutCreateWindow(this.viewManager.Object, () => this.messageBoxViewModel.Object, this.config.Object);
|
||||
|
||||
try { wm.ShowMessageBox("text", "title", MessageBoxButton.OKCancel, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxResult.Cancel, MessageBoxOptions.RtlReading); }
|
||||
try { wm.ShowMessageBox("text", "title", MessageBoxButton.OKCancel, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxResult.Cancel, null, FlowDirection.RightToLeft, TextAlignment.Right); }
|
||||
catch (TestException) { }
|
||||
|
||||
this.messageBoxViewModel.Verify(x => x.Setup("text", "title", MessageBoxButton.OKCancel, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxResult.Cancel, MessageBoxOptions.RtlReading, null));
|
||||
this.messageBoxViewModel.Verify(x => x.Setup("text", "title", MessageBoxButton.OKCancel, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxResult.Cancel, null, FlowDirection.RightToLeft, TextAlignment.Right));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Loading…
Reference in New Issue