Ejemplo n.º 1
0
        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}");
            }
        }
Ejemplo n.º 2
0
        public void Setup()
        {
            _eventListener = new MockEventListener();

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