using System.Reflection;
using System.Runtime.ExceptionServices;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.RenderTree;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.AdminUI.Browsing;
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Raw;
using ZB.MOM.WW.OtOpcUa.Commons.Browsing;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Raw;
// BL0006: the test renderer needs RenderTree types (same suppression as RawBrowseModalStaleOpenTests).
#pragma warning disable BL0006
///
/// G2-F3: after a rebirth request the browse modal re-reads the tree itself (the session's
/// RequestRebirthAsync now waits for the births), instead of telling the operator to re-expand it.
///
[Trait("Category", "Unit")]
public sealed class RawBrowseRebirthRefreshTests : IDisposable
{
private const BindingFlags Private = BindingFlags.NonPublic | BindingFlags.Instance;
private readonly List _renderers = new();
public void Dispose()
{
foreach (var r in _renderers) r.Dispose();
}
[Fact]
public async Task A_completed_rebirth_rekeys_the_tree_and_keeps_the_outcome()
{
var svc = new RebirthBrowserService { Result = Task.FromResult(2) };
var modal = NewOpenModal(svc);
var before = Get(modal, "_treeGeneration");
await ConfirmAsync(modal);
Get(modal, "_treeGeneration").ShouldBe(before + 1);
Get(modal, "_rebirthOutcome")!.ShouldContain("The tree was refreshed");
Get