|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using BasicTestApp; |
| 5 | +using Microsoft.AspNetCore.Components.E2ETest; |
| 6 | +using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; |
| 7 | +using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; |
| 8 | +using Microsoft.AspNetCore.E2ETesting; |
| 9 | +using Microsoft.JSInterop; |
| 10 | +using OpenQA.Selenium; |
| 11 | +using Xunit.Abstractions; |
| 12 | + |
| 13 | +namespace Microsoft.AspNetCore.Components.E2ETests.Tests; |
| 14 | + |
| 15 | +public class InteropValueTypesTest: ServerTestBase<BlazorWasmTestAppFixture<Program>> |
| 16 | +{ |
| 17 | + public InteropValueTypesTest( |
| 18 | + BrowserFixture browserFixture, |
| 19 | + BlazorWasmTestAppFixture<Program> serverFixture, |
| 20 | + ITestOutputHelper output) |
| 21 | + : base(browserFixture, serverFixture, output) |
| 22 | + { |
| 23 | + } |
| 24 | + |
| 25 | + protected override void InitializeAsyncCore() |
| 26 | + { |
| 27 | + Navigate(ServerPathBase); |
| 28 | + Browser.MountTestComponent<InteropValueTypesComponent>(); |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void CanRetrieveStoredGuidAsString() |
| 33 | + { |
| 34 | + Browser.Exists(By.Id("done-with-interop")); |
| 35 | + |
| 36 | + var stringGuidElement = Browser.Exists(By.Id("string-get-by-interop")); |
| 37 | + |
| 38 | + Browser.NotEqual(string.Empty, () => stringGuidElement.Text); |
| 39 | + Browser.NotEqual(default, () => Guid.Parse(stringGuidElement.Text)); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + public void CanRetrieveStoredGuidAsGuid() |
| 44 | + { |
| 45 | + Browser.Exists(By.Id("done-with-interop")); |
| 46 | + |
| 47 | + var guidElement = Browser.Exists(By.Id("guid-get-by-interop")); |
| 48 | + |
| 49 | + Browser.NotEqual(default, () => Guid.Parse(guidElement.Text)); |
| 50 | + } |
| 51 | + |
| 52 | + [Fact] |
| 53 | + public void CanRetrieveStoredGuidAsNullableGuid() |
| 54 | + { |
| 55 | + Browser.Exists(By.Id("done-with-interop")); |
| 56 | + |
| 57 | + var nullableGuidElement = Browser.Exists(By.Id("nullable-guid-get-by-interop")); |
| 58 | + |
| 59 | + Browser.NotEqual(default, () => Guid.Parse(nullableGuidElement.Text)); |
| 60 | + } |
| 61 | + |
| 62 | + [Fact] |
| 63 | + public void CanRetrieveNullAsNullableGuid() |
| 64 | + { |
| 65 | + Browser.Exists(By.Id("done-with-interop")); |
| 66 | + |
| 67 | + var nullableGuidElement = Browser.Exists(By.Id("null-loaded-into-nullable")); |
| 68 | + |
| 69 | + Browser.Equal(false.ToString(), () => nullableGuidElement.Text); |
| 70 | + } |
| 71 | +} |
0 commit comments