mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
These fixtures were written while porting to Avalonia, as an author's own verification step rather than as coverage: reflection asserting that a type derives from its base and that a property has the type it is declared with; literals (MinHeight 29, Padding 3, MaxWidth 900) copied out of the .axaml beside them; a property override asserted only so pane descendants stay reachable from tests. None of them can fail except when someone deliberately edits the line they mirror, and then they fail as a chore. StartupPerfTests keeps its two [Explicit] benchmarks, which print per-phase timings worth reading. The third was a wall-clock assertion (8 CoreLib copies must settle in under 15s) that ran in CI, where a shared runner decides the verdict; as [Explicit] it would be strictly dominated by the 200-assembly benchmark it was derived from, so it goes. Two fixtures are trimmed rather than deleted, because their kernel is real: XmlDocLoader's ref-pack fallback has no other test in the repo, and the MenuIcon metadata rasterisation was dropped once during the port already. Both now assert that without booting MainWindow to reach it. This is worth about two seconds - it buys reviewers less to read, not CI less to do. Assisted-by: Claude:claude-opus-5:Claude Codepull/3980/head
7 changed files with 30 additions and 273 deletions
@ -1,62 +0,0 @@
@@ -1,62 +0,0 @@
|
||||
// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using AwesomeAssertions; |
||||
|
||||
using ICSharpCode.ILSpy.ViewModels; |
||||
|
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.ILSpy.Tests; |
||||
|
||||
/// <summary>
|
||||
/// Locks the single inner-content hierarchy: every viewmodel that may occupy a
|
||||
/// <see cref="ContentTabPage"/>'s Content slot derives from the one <see cref="ContentPageModel"/>
|
||||
/// base, and <c>ContentTabPage.Content</c> is typed to it (not <c>object</c>). Guards against a
|
||||
/// future content type sneaking back in as a bare ObservableObject or the slot weakening to object.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ContentPageHierarchyTests |
||||
{ |
||||
[Test] |
||||
public void All_Four_Content_Types_Derive_From_ContentPageModel() |
||||
{ |
||||
typeof(ICSharpCode.ILSpy.TextView.DecompilerTabPageModel).Should().BeAssignableTo<ContentPageModel>(); |
||||
typeof(MetadataTablePageModel).Should().BeAssignableTo<ContentPageModel>(); |
||||
typeof(ICSharpCode.ILSpy.Compare.CompareTabPageModel).Should().BeAssignableTo<ContentPageModel>(); |
||||
typeof(ICSharpCode.ILSpy.Options.OptionsPageModel).Should().BeAssignableTo<ContentPageModel>( |
||||
"OptionsPageModel must join the content hierarchy, not stay a bare ObservableObject"); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContentTabPage_Content_Is_Typed_To_ContentPageModel() |
||||
{ |
||||
typeof(ContentTabPage).GetProperty(nameof(ContentTabPage.Content))!.PropertyType |
||||
.Should().Be(typeof(ContentPageModel), "the Content slot must be strongly typed, not object"); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsStaticContent_Is_A_Single_Inherited_Member() |
||||
{ |
||||
// One IsStaticContent, declared on the base -- not duck-typed across unrelated classes.
|
||||
typeof(ContentPageModel).GetProperty(nameof(ContentPageModel.IsStaticContent)) |
||||
.Should().NotBeNull("IsStaticContent lives on ContentPageModel"); |
||||
typeof(ICSharpCode.ILSpy.Options.OptionsPageModel).GetProperty("IsStaticContent")!.DeclaringType |
||||
.Should().Be(typeof(ContentPageModel), "OptionsPageModel must inherit IsStaticContent, not redeclare it"); |
||||
} |
||||
} |
||||
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using AwesomeAssertions; |
||||
|
||||
using Dock.Controls.DeferredContentControl; |
||||
|
||||
using ICSharpCode.ILSpy.ViewModels; |
||||
|
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.ILSpy.Tests; |
||||
|
||||
/// <summary>
|
||||
/// Regression guard: <see cref="ToolPaneModel"/> opts out of Dock's deferred content
|
||||
/// presentation so panes (search, analyzers, debug steps, etc.) materialise their views
|
||||
/// eagerly. Without this, tests can't reach descendants of a pane until it's
|
||||
/// focus-activated by the user — and the search-pane's startup tasks (assembly index
|
||||
/// scan, etc.) wouldn't kick off until first activation.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ToolPaneDeferredContentTests |
||||
{ |
||||
[Test] |
||||
public void ToolPaneModel_Opts_Out_Of_Dock_Deferred_Content_Presentation() |
||||
{ |
||||
var sentinel = new TestToolPane(); |
||||
((IDeferredContentPresentation)sentinel).DeferContentPresentation.Should().BeFalse(); |
||||
} |
||||
|
||||
sealed class TestToolPane : ToolPaneModel { } |
||||
} |
||||
Loading…
Reference in new issue