diff --git a/JournalApp.Tests/CalendarTests.razor b/JournalApp.Tests/CalendarTests.razor index b73b909..792803a 100644 --- a/JournalApp.Tests/CalendarTests.razor +++ b/JournalApp.Tests/CalendarTests.razor @@ -20,7 +20,7 @@ [Fact] public void SwitchYear() { - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.OpenToDateString, "20000101") ); @@ -51,7 +51,7 @@ [Fact] public async Task CalendarViewMoodBlockCount() { - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.OpenToDateString, "20230101") ); cut.Instance.SelectedYear.Should().Be(2023); @@ -82,7 +82,7 @@ _culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Wednesday; Thread.CurrentThread.CurrentCulture = _culture; - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.OpenToDateString, "20230101") ); cut.Instance.SelectedYear.Should().Be(2023); diff --git a/JournalApp.Tests/DataPointViewTests.razor b/JournalApp.Tests/DataPointViewTests.razor index 61201ce..e4ece1e 100644 --- a/JournalApp.Tests/DataPointViewTests.razor +++ b/JournalApp.Tests/DataPointViewTests.razor @@ -87,7 +87,7 @@ var point = DataPoint.Create(day, category); point.SleepHours = 8.5m; - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.Point, point) ); @@ -122,7 +122,7 @@ var day = Day.Create(new(2024, 01, 01)); var point = DataPoint.Create(day, category); - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.Point, point) ); @@ -150,7 +150,7 @@ var day = Day.Create(new(2024, 01, 01)); var point = DataPoint.Create(day, category); - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.Point, point) ); @@ -187,7 +187,7 @@ var day = Day.Create(new(2024, 01, 01)); var point = DataPoint.Create(day, category); - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.Point, point) ); @@ -208,7 +208,7 @@ var day = Day.Create(new(2024, 01, 01)); var point = DataPoint.Create(day, category); - var cut = RenderComponent(p => + var cut = Render(p => p.Add(x => x.Point, point) ); diff --git a/JournalApp.Tests/JaTestContext.cs b/JournalApp.Tests/JaTestContext.cs index 4a68366..0f0bfa5 100644 --- a/JournalApp.Tests/JaTestContext.cs +++ b/JournalApp.Tests/JaTestContext.cs @@ -4,7 +4,7 @@ namespace JournalApp.Tests; -public abstract class JaTestContext : TestContext, IAsyncLifetime +public abstract class JaTestContext : BunitContext, IAsyncLifetime { private SqliteConnection _dbConnection; @@ -21,13 +21,15 @@ public virtual Task InitializeAsync() return Task.CompletedTask; } - public virtual async Task DisposeAsync() + public new virtual async Task DisposeAsync() { if (_dbConnection != null) { await _dbConnection.CloseAsync(); await _dbConnection.DisposeAsync(); } + + await base.DisposeAsync(); } public void AddDbContext() diff --git a/JournalApp.Tests/JournalApp.Tests.csproj b/JournalApp.Tests/JournalApp.Tests.csproj index 52e937f..0aaedda 100644 --- a/JournalApp.Tests/JournalApp.Tests.csproj +++ b/JournalApp.Tests/JournalApp.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/JournalApp.Tests/ManageCategoriesTests.razor b/JournalApp.Tests/ManageCategoriesTests.razor index ef97b30..1f6f317 100644 --- a/JournalApp.Tests/ManageCategoriesTests.razor +++ b/JournalApp.Tests/ManageCategoriesTests.razor @@ -207,7 +207,7 @@ return db.Categories.Single(c => c.Guid == new Guid(guid)); } - var cut = RenderComponent(); + var cut = Render(); for (int i = 6; i > 1; i--) { diff --git a/JournalApp.Tests/SafetyPlanTests.razor b/JournalApp.Tests/SafetyPlanTests.razor index 410edae..04dc563 100644 --- a/JournalApp.Tests/SafetyPlanTests.razor +++ b/JournalApp.Tests/SafetyPlanTests.razor @@ -13,7 +13,7 @@ Purpose = "My purpose is to finish these tests", }; - var cut = RenderComponent(); + var cut = Render(); // Assert state. cut.Instance.Plan.Purpose.Should().Be("My purpose is to finish these tests"); @@ -31,7 +31,7 @@ Purpose = "My purpose is to finish these tests", }; - var cut = RenderComponent(); + var cut = Render(); // Assert initial state. cut.Instance.Plan.Purpose.Should().Be("My purpose is to finish these tests"); @@ -40,10 +40,13 @@ // Change via textarea and property to test both. cut.Find(".safety-plan-item-purpose textarea").Input("Actually it's puppies"); cut.Instance.Plan.ProfessionalContacts = "988 (USA)"; + + // Manually save state (normally triggered by navigation or window deactivation) + preferenceService.SafetyPlan = cut.Instance.Plan; // Leave and come back. - DisposeComponents(); - cut = RenderComponent(); + cut.Dispose(); + cut = Render(); // Assert that all changes persisted. preferenceService.SafetyPlan.Purpose.Should().Be("Actually it's puppies");