public void AllMudComponents_ShouldForwardUserAttributes()
        {
            // Arrange
            using var testContext = new TestContext();
            testContext.AddTestServices();
            testContext.Services.Add(new ServiceDescriptor(typeof(IResizeObserver), new MockResizeObserver()));

            var componentFactory = new MudComponentFactory
            {
                UserAttributes = new Dictionary <string, object> {
                    { "data-testid", "test-123" }
                },
            };

            // Act & Assert
            var mudComponentTypes = GetMudComponentTypes();

            mudComponentTypes.Should().NotBeEmpty();
            foreach (var componentType in mudComponentTypes)
            {
                var component = componentFactory.Create(componentType, testContext);

                component.Markup.Should()
                .NotBeEmpty(because: $"the component {componentType.Name} should at least contain one element");

                var elementsWithUserAttributes = component.FindAll("[data-testid='test-123']");
                elementsWithUserAttributes.Should()
                .NotBeEmpty(because: $"UserAttributes should be forwarded by component {componentType.Name}");
            }
        }
        public void Setup()
        {
            _eventListener = new MockEventListener();

            ctx = new Bunit.TestContext();
            ctx.AddTestServices();
            ctx.Services.AddSingleton <IEventListener>(_eventListener);
        }
Exemple #3
0
 public void Setup()
 {
     ctx = new Bunit.TestContext();
     ctx.AddTestServices();
 }
Exemple #4
0
 public void Setup()
 {
     ctx = new Bunit.TestContext();
     ctx.AddTestServices();
     ctx.Services.AddScoped <IResizeListenerService, MockResizeListenerService>();
 }