Guard dialog completion by presentation identity
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Shared;
|
||||
|
||||
/// <summary>Custom completions belong to the dialog whose typed context was issued.</summary>
|
||||
public sealed class DialogContextIdentityTests
|
||||
{
|
||||
/// <summary>A canceled custom context cannot confirm or cancel a subsequently opened dialog.</summary>
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task StaleCustomContext_DoesNotResolveNewDialog(bool staleCancel)
|
||||
{
|
||||
var service = new DialogService();
|
||||
DialogContext<bool> first = null!;
|
||||
var pendingFirst = service.ShowAsync<bool>("First", context => { first = context; return _ => { }; });
|
||||
first.Cancel();
|
||||
Assert.False(await pendingFirst);
|
||||
|
||||
DialogContext<bool> second = null!;
|
||||
var pendingSecond = service.ShowAsync<bool>("Second", context => { second = context; return _ => { }; });
|
||||
if (staleCancel) first.Cancel(); else first.Close(true);
|
||||
Assert.False(pendingSecond.IsCompleted);
|
||||
Assert.Equal("Second", service.Current?.Title);
|
||||
second.Close(true);
|
||||
Assert.True(await pendingSecond);
|
||||
Assert.Null(service.Current);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user