From 14bde85263a5c14b101d5e9d48c8972fc17cede5 Mon Sep 17 00:00:00 2001 From: Rudi Herouard Date: Tue, 10 Mar 2026 06:20:59 +0100 Subject: [PATCH 01/21] Fix song select navigation with home/end keys (#36879) It's a continuation of https://github.com/ppy/osu/pull/36293, but for the home and end keys. Now when using home or end keys, it selects respectively the first or last item in the carousel, instead of just scrolling. ## Before: https://github.com/user-attachments/assets/6ab08d2f-1da4-4740-9d9e-574d7a8a10c9 ## After: https://github.com/user-attachments/assets/30bab836-0006-4830-b4e9-2d85017a15e6 --- .../Carousel/Carousel.ScrollContainer.cs | 24 +++++++++++++++- osu.Game/Graphics/Carousel/Carousel.cs | 28 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Carousel/Carousel.ScrollContainer.cs b/osu.Game/Graphics/Carousel/Carousel.ScrollContainer.cs index 5f1488513a..625c246c4e 100644 --- a/osu.Game/Graphics/Carousel/Carousel.ScrollContainer.cs +++ b/osu.Game/Graphics/Carousel/Carousel.ScrollContainer.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Utils; @@ -31,10 +32,12 @@ namespace osu.Game.Graphics.Carousel /// Implementation of scroll container which handles very large vertical lists by internally using double precision /// for pre-display Y values. /// - protected partial class ScrollContainer : UserTrackingScrollContainer, IKeyBindingHandler + protected partial class ScrollContainer : UserTrackingScrollContainer, IKeyBindingHandler, IKeyBindingHandler { public Action? OnPageUp { get; init; } public Action? OnPageDown { get; init; } + public Action? OnListStart { get; init; } + public Action? OnListEnd { get; init; } public readonly Container Panels; @@ -146,6 +149,25 @@ namespace osu.Game.Graphics.Carousel return base.OnKeyDown(e); } + public new bool OnPressed(KeyBindingPressEvent e) + { + if (IsHandlingKeyboardScrolling) + { + switch (e.Action) + { + case PlatformAction.MoveBackwardLine: + OnListStart?.Invoke(); + return true; + + case PlatformAction.MoveForwardLine: + OnListEnd?.Invoke(); + return true; + } + } + + return base.OnPressed(e); + } + public bool OnPressed(KeyBindingPressEvent e) { switch (e.Action) diff --git a/osu.Game/Graphics/Carousel/Carousel.cs b/osu.Game/Graphics/Carousel/Carousel.cs index 13d3c22c19..5164068d53 100644 --- a/osu.Game/Graphics/Carousel/Carousel.cs +++ b/osu.Game/Graphics/Carousel/Carousel.cs @@ -319,6 +319,8 @@ namespace osu.Game.Graphics.Carousel RelativeSizeAxes = Axes.Both, OnPageUp = () => Scheduler.AddOnce(traverseFromKey, new TraversalOperation(TraversalType.Page, -1)), OnPageDown = () => Scheduler.AddOnce(traverseFromKey, new TraversalOperation(TraversalType.Page, 1)), + OnListStart = () => Scheduler.AddOnce(traverseFromKey, new TraversalOperation(TraversalType.Edge, -1)), + OnListEnd = () => Scheduler.AddOnce(traverseFromKey, new TraversalOperation(TraversalType.Edge, 1)), }; Items.BindCollectionChanged((_, args) => @@ -554,6 +556,10 @@ namespace osu.Game.Graphics.Carousel traverseKeyboardPage(traversal.Direction); break; + case TraversalType.Edge: + traverseKeyboardEdge(traversal.Direction); + break; + case TraversalType.Set: traverseSetSelection(traversal.Direction); break; @@ -572,6 +578,7 @@ namespace osu.Game.Graphics.Carousel Keyboard, Set, Page, + Edge, Group } @@ -682,6 +689,27 @@ namespace osu.Game.Graphics.Carousel } } + /// + /// Select the first or last item in the carousel. + /// + /// Positive for last item, negative for first item. + private void traverseKeyboardEdge(int direction) + { + if (carouselItems == null || carouselItems.Count == 0) + return; + + var item = direction > 0 + ? carouselItems.LastOrDefault(x => x.IsVisible) + : carouselItems.FirstOrDefault(x => x.IsVisible); + + if (item != null && !CheckModelEquality(item.Model, currentKeyboardSelection.Model)) + { + setKeyboardSelection(item.Model); + ScrollToSelection(); + playTraversalSound(); + } + } + /// /// Select the next valid group selection relative to a current selection. /// This is generally for keyboard based traversal. From caffc7238bd493d34d6efb92ce860d691a6a77ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 10 Mar 2026 07:12:43 +0100 Subject: [PATCH 02/21] Do not forcibly log out user if user retrieval fails with a server error code (#36897) * Do not forcibly log out user if user retrieval fails with a server error code This behaviour caused users to get forcibly logged out of the game during yesterday's redis outage. From one case where logs were provided (https://discord.com/channels/188630481301012481/1097318920991559880/1480201862610423933): - User had repeated timeouts on API requests; consequently, API went into failing state - On one of the login retries `/api/v2/me` returned a 500 with no error details (`{"error":"null}` JSON response) which resulted in an instant logout as per https://github.com/ppy/osu/blob/7263551aa868911a7d9148cf2cb16f9e0325f531/osu.Game/Online/API/APIAccess.cs#L323-L324 This PR intends to only forcibly log the user out if the returned error code indicates a client error. If it is a server error, the login is preserved and a normal retry loop proceeds. This can be tested with a local web instance via following steps: 1. Start `osu-web` and a client instance connected to it. 2. Log in on the client instance. 3. Kill (`^C`) `osu-web`. 4. Trigger a few requests in the client and wait for enough of them to fail for the API to change to `Failing` state. 5. Apply ```diff diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index db34639abf2..392a844882a 100644 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -581,6 +581,8 @@ class UsersController extends Controller */ public function me($mode = null) { + abort(500); + $user = \Auth::user(); $currentMode = $mode ?? $user->playmode; ``` 6. Start `osu-web` again. 7. On master this will log the user out forcibly. On this PR, the user will remain in `Failing` state. 8. Undo patch from step (5) (restarting web is not required). 9. On this PR, the client will be logged back in. * Update framework --------- Co-authored-by: Dean Herbert --- osu.Android.props | 2 +- osu.Game/Online/API/APIAccess.cs | 2 +- osu.Game/Online/API/APIException.cs | 6 +++++- osu.Game/Online/API/APIRequest.cs | 2 +- osu.Game/Online/API/OAuth.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index e8daf49130..85c0378ece 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -10,7 +10,7 @@ true - + diff --git a/osu.iOS.props b/osu.iOS.props index 0f4e8bb3a3..0338bbfec4 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -17,6 +17,6 @@ -all - + From 321e6989061246275f30ef80030fe560109291fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 10 Mar 2026 08:02:13 +0100 Subject: [PATCH 03/21] Improve support for import & export flows on Android via using system file picker & share sheet (#36901) https://github.com/user-attachments/assets/57d0bc9d-f081-4d04-8cb6-422a83f1a1d3 https://github.com/user-attachments/assets/208f0676-a735-4055-a422-e6a2c3847220 --- - [x] Depends on https://github.com/ppy/osu-framework/pull/6717 to work - Closes https://github.com/ppy/osu/issues/21076 - Closes https://github.com/ppy/osu/issues/22676 - Closes https://github.com/ppy/osu/issues/28666 --------- Co-authored-by: Dean Herbert --- osu.Android/AndroidManifest.xml | 21 ++++++++----------- osu.Android/Resources/xml/filepaths.xml | 6 ++++++ .../Sections/General/QuickActionSettings.cs | 20 +++++++----------- .../Sections/Maintenance/GeneralSettings.cs | 7 +++++++ osu.Game/Screens/Edit/Editor.cs | 9 +++----- 5 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 osu.Android/Resources/xml/filepaths.xml diff --git a/osu.Android/AndroidManifest.xml b/osu.Android/AndroidManifest.xml index a85e711cf2..d334888a5f 100644 --- a/osu.Android/AndroidManifest.xml +++ b/osu.Android/AndroidManifest.xml @@ -5,16 +5,13 @@ android:supportsRtl="true" android:label="osu!" android:icon="@mipmap/ic_launcher" - android:roundIcon="@mipmap/ic_launcher" /> - - - - - + android:roundIcon="@mipmap/ic_launcher"> + + + + diff --git a/osu.Android/Resources/xml/filepaths.xml b/osu.Android/Resources/xml/filepaths.xml new file mode 100644 index 0000000000..a2356c4aab --- /dev/null +++ b/osu.Android/Resources/xml/filepaths.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs b/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs index 4f988d667f..02c1dfb8df 100644 --- a/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Threading.Tasks; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -58,20 +57,15 @@ namespace osu.Game.Overlays.Settings.Sections.General }, }); - bool supportsExport = RuntimeInfo.OS != RuntimeInfo.Platform.Android; - - if (supportsExport) + Add(new SettingsButtonV2 { - Add(new SettingsButtonV2 - { - Text = GeneralSettingsStrings.ExportLogs, - BackgroundColour = colours.YellowDarker.Darken(0.5f), - Keywords = new[] { @"bug", "report", "logs", "files" }, - Action = () => Task.Run(exportLogs), - }); + Text = GeneralSettingsStrings.ExportLogs, + BackgroundColour = colours.YellowDarker.Darken(0.5f), + Keywords = new[] { @"bug", "report", "logs", "files" }, + Action = () => Task.Run(exportLogs), + }); - exportStorage = (storage as OsuStorage)?.GetExportStorage() ?? storage.GetStorageForDirectory(@"exports"); - } + exportStorage = (storage as OsuStorage)?.GetExportStorage() ?? storage.GetStorageForDirectory(@"exports"); } [Resolved] diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 2c79daffb6..e8345c1946 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -47,5 +47,12 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance } }); } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + selector?.Dispose(); + } } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 2360febccb..452419ca45 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -1287,12 +1287,9 @@ namespace osu.Game.Screens.Edit Hotkey = new Hotkey(GlobalAction.EditorDiscardUnsavedChanges) }; - if (RuntimeInfo.OS != RuntimeInfo.Platform.Android) - { - var export = createExportMenu(); - saveRelatedMenuItems.AddRange(export.Items); - yield return export; - } + var export = createExportMenu(); + saveRelatedMenuItems.AddRange(export.Items); + yield return export; if (RuntimeInfo.IsDesktop) { From 054ae2983d2a9184e215970489939ae17996ed51 Mon Sep 17 00:00:00 2001 From: Krzysztof Gutkowski Date: Tue, 10 Mar 2026 08:28:06 +0100 Subject: [PATCH 04/21] Extract user overlay actions button component (#36236) This PR extracts the classes used for the actions dropdown on the user profile overlay to separate components, in preparation to be used on the team overlay (#32584). Kinda RFC since I'm not sure if this is the best way to do this. Co-authored-by: Dean Herbert --- .../Header/Components/ProfileActionPopover.cs | 40 +++++ .../Header/Components/ProfileActionsButton.cs | 62 +++++++ .../Header/Components/ProfilePopoverAction.cs | 104 +++++++++++ .../Header/Components/UserActionsButton.cs | 168 +----------------- 4 files changed, 215 insertions(+), 159 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Header/Components/ProfileActionPopover.cs create mode 100644 osu.Game/Overlays/Profile/Header/Components/ProfileActionsButton.cs create mode 100644 osu.Game/Overlays/Profile/Header/Components/ProfilePopoverAction.cs diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileActionPopover.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileActionPopover.cs new file mode 100644 index 0000000000..11f82772db --- /dev/null +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileActionPopover.cs @@ -0,0 +1,40 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.UserInterfaceV2; + +namespace osu.Game.Overlays.Profile.Header.Components +{ + public abstract partial class ProfileActionPopover : OsuPopover + { + [Resolved] + private OverlayColourProvider colourProvider { get; set; } = null!; + + private FillFlowContainer container = null!; + + protected ProfileActionPopover() + : base(false) + { + } + + [BackgroundDependencyLoader] + private void load() + { + Background.Colour = colourProvider.Background6; + + AllowableAnchors = [Anchor.BottomCentre, Anchor.TopCentre]; + + Child = container = new FillFlowContainer + { + Width = 160, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Horizontal = 5, Vertical = 10 }, + }; + } + + public ProfilePopoverAction[] Actions { set => container.Children = value; } + } +} diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileActionsButton.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileActionsButton.cs new file mode 100644 index 0000000000..ff6a279be2 --- /dev/null +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileActionsButton.cs @@ -0,0 +1,62 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.Containers; +using osuTK; + +namespace osu.Game.Overlays.Profile.Header.Components +{ + public abstract partial class ProfileActionsButton : OsuHoverContainer, IHasPopover + { + private Box background = null!; + + protected override IEnumerable EffectTargets => [background]; + + [Resolved] + private OverlayColourProvider colourProvider { get; set; } = null!; + + [BackgroundDependencyLoader] + private void load() + { + IdleColour = colourProvider.Background2; + HoverColour = colourProvider.Background1; + + Size = new Vector2(40); + Masking = true; + CornerRadius = 20; + + Child = new CircularContainer + { + Masking = true, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + new SpriteIcon + { + Size = new Vector2(12), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.EllipsisV, + }, + } + }; + + Action = this.ShowPopover; + } + + public abstract Popover GetPopover(); + } +} diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfilePopoverAction.cs b/osu.Game/Overlays/Profile/Header/Components/ProfilePopoverAction.cs new file mode 100644 index 0000000000..5dd8b80502 --- /dev/null +++ b/osu.Game/Overlays/Profile/Header/Components/ProfilePopoverAction.cs @@ -0,0 +1,104 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Framework.Localisation; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; + +namespace osu.Game.Overlays.Profile.Header.Components +{ + public partial class ProfilePopoverAction : OsuClickableContainer + { + private readonly IconUsage icon; + private readonly LocalisableString caption; + + private Box background = null!; + private CircularContainer indicator = null!; + + public ProfilePopoverAction(IconUsage icon, LocalisableString caption) + { + this.icon = icon; + this.caption = caption; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + RelativeSizeAxes = Content.RelativeSizeAxes = Axes.X; + AutoSizeAxes = Content.AutoSizeAxes = Axes.Y; + + Masking = true; + CornerRadius = 4; + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5, + Alpha = 0, + }, + indicator = new Circle + { + Width = 4, + Height = 14, + X = 10, + Colour = colourProvider.Highlight1, + Anchor = Anchor.CentreLeft, + Origin = Anchor.Centre, + Alpha = 0, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Padding = new MarginPadding { Horizontal = 25, Vertical = 5 }, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new SpriteIcon + { + Icon = icon, + Size = new Vector2(11), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + new OsuSpriteText + { + Text = caption, + Font = OsuFont.Style.Body, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + UseFullGlyphHeight = false, + } + } + } + }; + } + + protected override bool OnHover(HoverEvent e) + { + updateState(); + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + updateState(); + base.OnHoverLost(e); + } + + private void updateState() + { + background.Alpha = indicator.Alpha = IsHovered ? 1 : 0; + } + } +} diff --git a/osu.Game/Overlays/Profile/Header/Components/UserActionsButton.cs b/osu.Game/Overlays/Profile/Header/Components/UserActionsButton.cs index 1a2593cff7..7c4e47206a 100644 --- a/osu.Game/Overlays/Profile/Header/Components/UserActionsButton.cs +++ b/osu.Game/Overlays/Profile/Header/Components/UserActionsButton.cs @@ -1,78 +1,26 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Framework.Input.Events; -using osu.Framework.Localisation; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osu.Game.Users; -using osuTK; namespace osu.Game.Overlays.Profile.Header.Components { - public partial class UserActionsButton : OsuHoverContainer, IHasPopover + public partial class UserActionsButton : ProfileActionsButton { public readonly Bindable User = new Bindable(); - private Box background = null!; - - protected override IEnumerable EffectTargets => [background]; - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } = null!; - [Resolved] private IAPIProvider api { get; set; } = null!; - [BackgroundDependencyLoader] - private void load() - { - IdleColour = colourProvider.Background2; - HoverColour = colourProvider.Background1; - - Size = new Vector2(40); - Masking = true; - CornerRadius = 20; - - Child = new CircularContainer - { - Masking = true, - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, - new SpriteIcon - { - Size = new Vector2(12), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.Solid.EllipsisV, - }, - } - }; - - Action = this.ShowPopover; - } - protected override void LoadComplete() { base.LoadComplete(); @@ -80,132 +28,34 @@ namespace osu.Game.Overlays.Profile.Header.Components User.BindValueChanged(_ => Alpha = User.Value?.User.OnlineID == api.LocalUser.Value.OnlineID ? 0 : 1, true); } - public Popover GetPopover() => new UserActionPopover(User.Value!.User); + public override Popover GetPopover() => new UserActionPopover(User.Value!.User); - private partial class UserActionPopover : OsuPopover + private partial class UserActionPopover : ProfileActionPopover { private readonly APIUser user; public UserActionPopover(APIUser user) - : base(false) { this.user = user; } [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider, IAPIProvider api, IDialogOverlay? dialogOverlay) + private void load(IAPIProvider api, IDialogOverlay? dialogOverlay) { - Background.Colour = colourProvider.Background6; - bool userBlocked = api.LocalUserState.Blocks.Any(b => b.TargetID == user.Id); - AllowableAnchors = [Anchor.BottomCentre, Anchor.TopCentre]; - - Child = new FillFlowContainer + Actions = new[] { - Width = 160, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Horizontal = 5, Vertical = 10 }, - Children = new Drawable[] + new ProfilePopoverAction(FontAwesome.Solid.Ban, userBlocked ? UsersStrings.BlocksButtonUnblock : UsersStrings.BlocksButtonBlock) { - new UserAction(FontAwesome.Solid.Ban, userBlocked ? UsersStrings.BlocksButtonUnblock : UsersStrings.BlocksButtonBlock) + Action = () => { - Action = () => - { - dialogOverlay?.Push(userBlocked ? ConfirmBlockActionDialog.Unblock(user) : ConfirmBlockActionDialog.Block(user)); - this.HidePopover(); - } + dialogOverlay?.Push(userBlocked ? ConfirmBlockActionDialog.Unblock(user) : ConfirmBlockActionDialog.Block(user)); + this.HidePopover(); } } }; } } - - private partial class UserAction : OsuClickableContainer - { - private readonly IconUsage icon; - private readonly LocalisableString caption; - - private Box background = null!; - private CircularContainer indicator = null!; - - public UserAction(IconUsage icon, LocalisableString caption) - { - this.icon = icon; - this.caption = caption; - } - - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - RelativeSizeAxes = Content.RelativeSizeAxes = Axes.X; - AutoSizeAxes = Content.AutoSizeAxes = Axes.Y; - - Masking = true; - CornerRadius = 4; - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background5, - Alpha = 0, - }, - indicator = new Circle - { - Width = 4, - Height = 14, - X = 10, - Colour = colourProvider.Highlight1, - Anchor = Anchor.CentreLeft, - Origin = Anchor.Centre, - Alpha = 0, - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Padding = new MarginPadding { Horizontal = 25, Vertical = 5 }, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5, 0), - Children = new Drawable[] - { - new SpriteIcon - { - Icon = icon, - Size = new Vector2(11), - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }, - new OsuSpriteText - { - Text = caption, - Font = OsuFont.Style.Body, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - UseFullGlyphHeight = false, - } - } - } - }; - } - - protected override bool OnHover(HoverEvent e) - { - updateState(); - return true; - } - - protected override void OnHoverLost(HoverLostEvent e) - { - updateState(); - base.OnHoverLost(e); - } - - private void updateState() - { - background.Alpha = indicator.Alpha = IsHovered ? 1 : 0; - } - } } } From 1b488949e13568c23faa0d88b18c8036f4a7dbc8 Mon Sep 17 00:00:00 2001 From: Denis Titovets Date: Tue, 10 Mar 2026 10:28:27 +0300 Subject: [PATCH 05/21] Localise some more `PopupDialog`s (#36890) changes can be reviewed commit by commit --------- Co-authored-by: Dean Herbert --- osu.Game/Localisation/ButtonSystemStrings.cs | 5 + osu.Game/Localisation/DialogStrings.cs | 96 +++++++++++++++++++ osu.Game/Localisation/EditorDialogsStrings.cs | 20 ++++ osu.Game/Online/Chat/ExternalLinkOpener.cs | 4 +- osu.Game/Overlays/Comments/DrawableComment.cs | 11 ++- osu.Game/Overlays/Dialog/ConfirmDialog.cs | 9 +- osu.Game/Screens/Edit/BookmarkResetDialog.cs | 4 +- .../DeleteDifficultyConfirmationDialog.cs | 6 +- osu.Game/Screens/Edit/Editor.cs | 2 +- .../Screens/Edit/SaveRequiredPopupDialog.cs | 7 +- .../Menu/ConfirmDiscardChangesDialog.cs | 9 +- osu.Game/Screens/Menu/ConfirmExitDialog.cs | 25 +++-- osu.Game/Screens/Menu/MainMenu.cs | 2 +- .../ConfirmExitMultiplayerMatchDialog.cs | 17 ++++ .../Matchmaking/Match/ScreenMatchmaking.cs | 3 +- .../RankedPlay/RankedPlayScreen.cs | 3 +- .../Multiplayer/Match/MatchStartControl.cs | 3 +- .../Multiplayer/MultiplayerMatchSubScreen.cs | 2 +- .../Playlists/ClosePlaylistDialog.cs | 3 +- .../Select/BeatmapClearScoresDialog.cs | 5 +- 20 files changed, 191 insertions(+), 45 deletions(-) create mode 100644 osu.Game/Screens/OnlinePlay/Components/ConfirmExitMultiplayerMatchDialog.cs diff --git a/osu.Game/Localisation/ButtonSystemStrings.cs b/osu.Game/Localisation/ButtonSystemStrings.cs index 2bce75c010..ecb067e0ff 100644 --- a/osu.Game/Localisation/ButtonSystemStrings.cs +++ b/osu.Game/Localisation/ButtonSystemStrings.cs @@ -93,6 +93,11 @@ Your experience will not be perfect, and may even feel subpar compared to games Please bear with us as we continue to improve the game for you!"); + /// + /// "Understood" + /// + public static LocalisableString MobileDisclaimerOkButton => new TranslatableString(getKey(@"mobile_disclaimer_ok_button"), @"Understood"); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Localisation/DialogStrings.cs b/osu.Game/Localisation/DialogStrings.cs index f50268dd03..05a7055cd6 100644 --- a/osu.Game/Localisation/DialogStrings.cs +++ b/osu.Game/Localisation/DialogStrings.cs @@ -49,6 +49,102 @@ namespace osu.Game.Localisation /// public static LocalisableString StableDirectoryLocationCancelButton => new TranslatableString(getKey(@"stable_directory_location_cancel_button"), @"Actually I don't have osu!stable installed."); + /// + /// "All local scores on {0}" + /// + public static LocalisableString BeatmapClearScoresBodyText(string difficulty) => new TranslatableString(getKey(@"beatmap_clear_scores_body_text"), @"All local scores on {0}", difficulty); + + /// + /// "Are you sure you want to close the following playlist:" + /// + public static LocalisableString ClosePlaylistHeaderText => new TranslatableString(getKey(@"close_playlist_header_text"), @"Are you sure you want to close the following playlist:"); + + /// + /// "Are you sure you want to abort the match?" + /// + public static LocalisableString ConfirmAbortMatchHeaderText => new TranslatableString(getKey(@"confirm_abort_match_header_text"), @"Are you sure you want to abort the match?"); + + /// + /// "Are you sure you want to exit osu!?" + /// + public static LocalisableString ConfirmExitHeaderText => new TranslatableString(getKey(@"confirm_exit_header_text"), @"Are you sure you want to exit osu!?"); + + /// + /// "Last chance to turn back" + /// + public static LocalisableString ConfirmDialogBodyText => new TranslatableString(getKey(@"confirm_exit_body_text"), @"Last chance to turn back"); + + /// + /// "There are currently some background operations which will be aborted if you continue: + /// + /// {0}" + /// + public static LocalisableString ConfirmExitBodyTextOngoingOperations(string ongoingOperationsText) => new TranslatableString(getKey(@"confirm_exit_body_text_ongoing_operations"), @"There are currently some background operations which will be aborted if you continue: + +{0}", ongoingOperationsText); + + /// + /// "There are currently some background operations which will be aborted if you continue: + /// + /// {0} + /// + /// and {1} other operation(s)." + /// + public static LocalisableString ConfirmExitBodyTextOtherOngoingOperations(string ongoingOperationsText, int count) => new TranslatableString(getKey(@"confirm_exit_body_text_other_ongoing_operations"), @"There are currently some background operations which will be aborted if you continue: + +{0} + +and {1} other operation(s).", ongoingOperationsText, count); + + /// + /// "Let me out!" + /// + public static LocalisableString ConfirmExitOkButton => new TranslatableString(getKey(@"confirm_exit_ok_button"), @"Let me out!"); + + /// + /// "Just a little more..." + /// + public static LocalisableString ConfirmExitCancelButton => new TranslatableString(getKey(@"confirm_exit_cancel_button"), @"Just a little more..."); + + /// + /// "Are you sure you want to go back?" + /// + public static LocalisableString ConfirmDiscardChangesHeaderText => new TranslatableString(getKey(@"confirm_discard_changes_header_text"), @"Are you sure you want to go back?"); + + /// + /// "This will discard any unsaved changes" + /// + public static LocalisableString ConfirmDiscardChangesBodyText => new TranslatableString(getKey(@"confirm_discard_changes_body_text"), @"This will discard any unsaved changes"); + + /// + /// "No I didn't mean to" + /// + public static LocalisableString ConfirmDiscardChangesCancelButton => new TranslatableString(getKey(@"confirm_discard_changes_cancel_button"), @"No I didn't mean to"); + + /// + /// "Are you sure you want to open the following link in a web browser? + /// + /// {0}" + /// + public static LocalisableString ExternalLinkBodyText(string url) => new TranslatableString(getKey(@"external_link_body_text"), @"Are you sure you want to open the following link in a web browser? + +{0}", url); + + /// + /// "Open in browser" + /// + public static LocalisableString ExternalLinkOkButton => new TranslatableString(getKey(@"external_link_ok_button"), @"Open in browser"); + + /// + /// "Do you really want to delete your comment?" + /// + public static LocalisableString DeleteCommentBodyText => new TranslatableString(getKey(@"delete_comment_body_text"), @"Do you really want to delete your comment?"); + + /// + /// "Are you sure you want to leave this multiplayer match?" + /// + public static LocalisableString ConfirmExitMultiplayerMatchBodyText => new TranslatableString(getKey(@"confirm_exit_multiplayer_match_body_text"), @"Are you sure you want to leave this multiplayer match?"); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Localisation/EditorDialogsStrings.cs b/osu.Game/Localisation/EditorDialogsStrings.cs index 3617dca81f..ea4e3d0d55 100644 --- a/osu.Game/Localisation/EditorDialogsStrings.cs +++ b/osu.Game/Localisation/EditorDialogsStrings.cs @@ -59,6 +59,26 @@ namespace osu.Game.Localisation /// public static LocalisableString DiscardUnsavedChangesDialogHeader => new TranslatableString(getKey(@"discard_unsaved_changes_dialog_header"), @"Discard all unsaved changes? This cannot be undone."); + /// + /// "The beatmap will be saved to continue with this operation." + /// + public static LocalisableString SaveRequiredDialogHeader => new TranslatableString(getKey(@"save_required_dialog_header"), @"The beatmap will be saved to continue with this operation."); + + /// + /// "Sounds good, let's go!" + /// + public static LocalisableString SoundsGood => new TranslatableString(getKey(@"sounds_good"), @"Sounds good, let's go!"); + + /// + /// "Difficulty "{0}" with {1} objects" + /// + public static LocalisableString DeleteDifficultyDetails(string difficultyName, int objectCount) => new TranslatableString(getKey(@"delete_difficulty_details"), @"Difficulty ""{0}"" with {1} objects", difficultyName, objectCount); + + /// + /// "All Bookmarks" + /// + public static LocalisableString AllBookmarks => new TranslatableString(getKey(@"all_bookmarks"), @"All Bookmarks"); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Online/Chat/ExternalLinkOpener.cs b/osu.Game/Online/Chat/ExternalLinkOpener.cs index 53faafcf36..708e9edefa 100644 --- a/osu.Game/Online/Chat/ExternalLinkOpener.cs +++ b/osu.Game/Online/Chat/ExternalLinkOpener.cs @@ -98,7 +98,7 @@ namespace osu.Game.Online.Chat public ExternalLinkDialog(string url, Action openExternalLinkAction, Action copyExternalLinkAction) { HeaderText = DialogStrings.CautionHeaderText; - BodyText = $"Are you sure you want to open the following link in a web browser?\n\n{url}"; + BodyText = DialogStrings.ExternalLinkBodyText(url); Icon = FontAwesome.Solid.ExclamationTriangle; @@ -106,7 +106,7 @@ namespace osu.Game.Online.Chat { new PopupDialogOkButton { - Text = @"Open in browser", + Text = DialogStrings.ExternalLinkOkButton, Action = openExternalLinkAction }, new PopupDialogCancelButton diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs index 33f09b7622..c439905245 100644 --- a/osu.Game/Overlays/Comments/DrawableComment.cs +++ b/osu.Game/Overlays/Comments/DrawableComment.cs @@ -21,11 +21,12 @@ using System.Diagnostics; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Comments.Buttons; using osu.Game.Overlays.Dialog; -using osu.Game.Resources.Localisation.Web; +using WebCommonStrings = osu.Game.Resources.Localisation.Web.CommonStrings; namespace osu.Game.Overlays.Comments { @@ -324,13 +325,13 @@ namespace osu.Game.Overlays.Comments if (WasDeleted) makeDeleted(); - actionsContainer.AddLink(CommonStrings.ButtonsPermalink, () => game?.CopyToClipboard($@"{api.Endpoints.APIUrl}/comments/{Comment.Id}")); + actionsContainer.AddLink(WebCommonStrings.ButtonsPermalink, () => game?.CopyToClipboard($@"{api.Endpoints.APIUrl}/comments/{Comment.Id}")); actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10)); - actionsContainer.AddLink(CommonStrings.ButtonsReply.ToLower(), toggleReply); + actionsContainer.AddLink(WebCommonStrings.ButtonsReply.ToLower(), toggleReply); actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10)); if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id) - actionsContainer.AddLink(CommonStrings.ButtonsDelete.ToLower(), deleteComment); + actionsContainer.AddLink(WebCommonStrings.ButtonsDelete.ToLower(), deleteComment); else actionsContainer.AddArbitraryDrawable(new CommentReportButton(Comment)); @@ -384,7 +385,7 @@ namespace osu.Game.Overlays.Comments if (dialogOverlay == null) deleteCommentRequest(); else - dialogOverlay.Push(new ConfirmDialog("Do you really want to delete your comment?", deleteCommentRequest)); + dialogOverlay.Push(new ConfirmDialog(DialogStrings.DeleteCommentBodyText, deleteCommentRequest)); } /// diff --git a/osu.Game/Overlays/Dialog/ConfirmDialog.cs b/osu.Game/Overlays/Dialog/ConfirmDialog.cs index f1caac8b5d..f6a5ca4f9c 100644 --- a/osu.Game/Overlays/Dialog/ConfirmDialog.cs +++ b/osu.Game/Overlays/Dialog/ConfirmDialog.cs @@ -6,7 +6,8 @@ using System; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; -using osu.Game.Resources.Localisation.Web; +using osu.Game.Localisation; +using WebCommonStrings = osu.Game.Resources.Localisation.Web.CommonStrings; namespace osu.Game.Overlays.Dialog { @@ -24,7 +25,7 @@ namespace osu.Game.Overlays.Dialog public ConfirmDialog(LocalisableString message, Action onConfirm, Action onCancel = null) { HeaderText = message; - BodyText = "Last chance to turn back"; + BodyText = DialogStrings.ConfirmDialogBodyText; Icon = FontAwesome.Solid.ExclamationTriangle; @@ -32,12 +33,12 @@ namespace osu.Game.Overlays.Dialog { new PopupDialogOkButton { - Text = @"Yes", + Text = DialogStrings.Confirm, Action = onConfirm }, new PopupDialogCancelButton { - Text = CommonStrings.ButtonsCancel, + Text = WebCommonStrings.ButtonsCancel, Action = onCancel }, }; diff --git a/osu.Game/Screens/Edit/BookmarkResetDialog.cs b/osu.Game/Screens/Edit/BookmarkResetDialog.cs index 48a0202c86..30a61c684a 100644 --- a/osu.Game/Screens/Edit/BookmarkResetDialog.cs +++ b/osu.Game/Screens/Edit/BookmarkResetDialog.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Game.Localisation; using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Edit @@ -13,7 +14,7 @@ namespace osu.Game.Screens.Edit public BookmarkResetDialog(EditorBeatmap editorBeatmap) { editor = editorBeatmap; - BodyText = "All Bookmarks"; + BodyText = EditorDialogsStrings.AllBookmarks; } [BackgroundDependencyLoader] @@ -23,4 +24,3 @@ namespace osu.Game.Screens.Edit } } } - diff --git a/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs b/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs index 1aeb1d8a40..ff69689c91 100644 --- a/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs +++ b/osu.Game/Screens/Edit/DeleteDifficultyConfirmationDialog.cs @@ -2,16 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Game.Beatmaps; +using osu.Game.Localisation; using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Edit { public partial class DeleteDifficultyConfirmationDialog : DeletionDialog { - public DeleteDifficultyConfirmationDialog(BeatmapInfo beatmapInfo, Action deleteAction) + public DeleteDifficultyConfirmationDialog(string difficultyName, int objectCount, Action deleteAction) { - BodyText = $"\"{beatmapInfo.DifficultyName}\" difficulty"; + BodyText = EditorDialogsStrings.DeleteDifficultyDetails(difficultyName, objectCount); DangerousAction = deleteAction; } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 452419ca45..4ba1b2fac2 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -1425,7 +1425,7 @@ namespace osu.Game.Screens.Edit if (dialogOverlay == null) delete(); else - dialogOverlay.Push(new DeleteDifficultyConfirmationDialog(Beatmap.Value.BeatmapInfo, delete)); + dialogOverlay.Push(new DeleteDifficultyConfirmationDialog(playableBeatmap.BeatmapInfo.DifficultyName, editorBeatmap.HitObjects.Count, delete)); void delete() { diff --git a/osu.Game/Screens/Edit/SaveRequiredPopupDialog.cs b/osu.Game/Screens/Edit/SaveRequiredPopupDialog.cs index 618efb7cda..5c69037825 100644 --- a/osu.Game/Screens/Edit/SaveRequiredPopupDialog.cs +++ b/osu.Game/Screens/Edit/SaveRequiredPopupDialog.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Graphics.Sprites; +using osu.Game.Localisation; using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Edit @@ -11,7 +12,7 @@ namespace osu.Game.Screens.Edit { public SaveRequiredPopupDialog(Action saveAndAction) { - HeaderText = "The beatmap will be saved to continue with this operation."; + HeaderText = EditorDialogsStrings.SaveRequiredDialogHeader; Icon = FontAwesome.Regular.Save; @@ -19,12 +20,12 @@ namespace osu.Game.Screens.Edit { new PopupDialogOkButton { - Text = "Sounds good, let's go!", + Text = EditorDialogsStrings.SoundsGood, Action = saveAndAction }, new PopupDialogCancelButton { - Text = "Oops, continue editing", + Text = EditorDialogsStrings.ContinueEditing, }, }; } diff --git a/osu.Game/Screens/Menu/ConfirmDiscardChangesDialog.cs b/osu.Game/Screens/Menu/ConfirmDiscardChangesDialog.cs index 0cd3e9ce71..b57d786f56 100644 --- a/osu.Game/Screens/Menu/ConfirmDiscardChangesDialog.cs +++ b/osu.Game/Screens/Menu/ConfirmDiscardChangesDialog.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Graphics.Sprites; +using osu.Game.Localisation; using osu.Game.Overlays.Dialog; namespace osu.Game.Screens.Menu @@ -16,8 +17,8 @@ namespace osu.Game.Screens.Menu /// An optional action to perform on cancel. public ConfirmDiscardChangesDialog(Action onConfirm, Action? onCancel = null) { - HeaderText = "Are you sure you want to go back?"; - BodyText = "This will discard any unsaved changes"; + HeaderText = DialogStrings.ConfirmDiscardChangesHeaderText; + BodyText = DialogStrings.ConfirmDiscardChangesBodyText; Icon = FontAwesome.Solid.ExclamationTriangle; @@ -25,12 +26,12 @@ namespace osu.Game.Screens.Menu { new PopupDialogDangerousButton { - Text = @"Yes", + Text = DialogStrings.Confirm, Action = onConfirm }, new PopupDialogCancelButton { - Text = @"No I didn't mean to", + Text = DialogStrings.ConfirmDiscardChangesCancelButton, Action = onCancel }, }; diff --git a/osu.Game/Screens/Menu/ConfirmExitDialog.cs b/osu.Game/Screens/Menu/ConfirmExitDialog.cs index e33071e78c..3e085ce063 100644 --- a/osu.Game/Screens/Menu/ConfirmExitDialog.cs +++ b/osu.Game/Screens/Menu/ConfirmExitDialog.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; using osu.Game.Localisation; using osu.Game.Overlays; using osu.Game.Overlays.Dialog; @@ -30,31 +31,29 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(INotificationOverlay notifications) { - HeaderText = "Are you sure you want to exit osu!?"; + HeaderText = DialogStrings.ConfirmExitHeaderText; Icon = FontAwesome.Solid.ExclamationTriangle; if (notifications.HasOngoingOperations) { - string text = "There are currently some background operations which will be aborted if you continue:\n\n"; - var ongoingOperations = notifications.OngoingOperations.ToArray(); + string ongoingOperationsText = ongoingOperations.Take(10).Aggregate(string.Empty, (current, n) => current + $"{n.Text} ({n.Progress:0%})\n"); - foreach (var n in ongoingOperations.Take(10)) - text += $"{n.Text} ({n.Progress:0%})\n"; + LocalisableString ongoingOperationsLocalisableString; if (ongoingOperations.Length > 10) - text += $"\nand {ongoingOperations.Length - 10} other operation(s).\n"; + ongoingOperationsLocalisableString = DialogStrings.ConfirmExitBodyTextOtherOngoingOperations(ongoingOperationsText, ongoingOperations.Length - 10); + else + ongoingOperationsLocalisableString = DialogStrings.ConfirmExitBodyTextOngoingOperations(ongoingOperationsText); - text += "\nLast chance to turn back"; - - BodyText = text; + BodyText = LocalisableString.Interpolate($"{ongoingOperationsLocalisableString}\n\n{DialogStrings.ConfirmDialogBodyText}"); Buttons = new PopupDialogButton[] { new PopupDialogDangerousButton { - Text = @"Let me out!", + Text = DialogStrings.ConfirmExitOkButton, Action = onConfirm }, new PopupDialogCancelButton @@ -66,18 +65,18 @@ namespace osu.Game.Screens.Menu } else { - BodyText = "Last chance to turn back"; + BodyText = DialogStrings.ConfirmDialogBodyText; Buttons = new PopupDialogButton[] { new PopupDialogOkButton { - Text = @"Let me out!", + Text = DialogStrings.ConfirmExitOkButton, Action = onConfirm }, new PopupDialogCancelButton { - Text = @"Just a little more...", + Text = DialogStrings.ConfirmExitCancelButton, Action = onCancel }, }; diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 0820d33622..6e7e8e7a74 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -501,7 +501,7 @@ namespace osu.Game.Screens.Menu { new PopupDialogOkButton { - Text = "Understood", + Text = ButtonSystemStrings.MobileDisclaimerOkButton, Action = confirmed, }, }; diff --git a/osu.Game/Screens/OnlinePlay/Components/ConfirmExitMultiplayerMatchDialog.cs b/osu.Game/Screens/OnlinePlay/Components/ConfirmExitMultiplayerMatchDialog.cs new file mode 100644 index 0000000000..ad1e053726 --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Components/ConfirmExitMultiplayerMatchDialog.cs @@ -0,0 +1,17 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Game.Localisation; +using osu.Game.Overlays.Dialog; + +namespace osu.Game.Screens.OnlinePlay.Components +{ + public partial class ConfirmExitMultiplayerMatchDialog : ConfirmDialog + { + public ConfirmExitMultiplayerMatchDialog(Action onConfirm) + : base(DialogStrings.ConfirmExitMultiplayerMatchBodyText, onConfirm) + { + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Match/ScreenMatchmaking.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Match/ScreenMatchmaking.cs index d692783e48..0c0c1006ad 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Match/ScreenMatchmaking.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Match/ScreenMatchmaking.cs @@ -30,6 +30,7 @@ using osu.Game.Overlays; using osu.Game.Overlays.Dialog; using osu.Game.Rulesets; using osu.Game.Screens.Footer; +using osu.Game.Screens.OnlinePlay.Components; using osu.Game.Screens.OnlinePlay.Matchmaking.Match.Gameplay; using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Users; @@ -378,7 +379,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Match confirmDialog.PerformOkAction(); else { - dialogOverlay.Push(new ConfirmDialog("Are you sure you want to leave this multiplayer match?", () => + dialogOverlay.Push(new ConfirmExitMultiplayerMatchDialog(() => { exitConfirmed = true; if (this.IsCurrentScreen()) diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlayScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlayScreen.cs index c61a8e1fc5..a6d152dfdf 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlayScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlayScreen.cs @@ -29,6 +29,7 @@ using osu.Game.Overlays; using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Volume; using osu.Game.Rulesets; +using osu.Game.Screens.OnlinePlay.Components; using osu.Game.Screens.OnlinePlay.Matchmaking.Match; using osu.Game.Screens.OnlinePlay.Matchmaking.Match.Gameplay; using osu.Game.Screens.OnlinePlay.Matchmaking.Queue; @@ -455,7 +456,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay confirmDialog.PerformOkAction(); else { - dialogOverlay.Push(new ConfirmDialog("Are you sure you want to leave this multiplayer match?", () => + dialogOverlay.Push(new ConfirmExitMultiplayerMatchDialog(() => { exitConfirmed = true; if (this.IsCurrentScreen()) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MatchStartControl.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MatchStartControl.cs index f73983217f..97f30035cf 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MatchStartControl.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MatchStartControl.cs @@ -12,6 +12,7 @@ using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Threading; +using osu.Game.Localisation; using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer.Countdown; using osu.Game.Overlays; @@ -259,7 +260,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match { public ConfirmAbortDialog(Action abortMatch, Action cancel) { - HeaderText = "Are you sure you want to abort the match?"; + HeaderText = DialogStrings.ConfirmAbortMatchHeaderText; DangerousAction = abortMatch; CancelAction = cancel; diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs index ed4f431d4e..40c1309e90 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs @@ -878,7 +878,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer confirmDialog.PerformOkAction(); else { - dialogOverlay.Push(new ConfirmDialog("Are you sure you want to leave this multiplayer match?", () => + dialogOverlay.Push(new ConfirmExitMultiplayerMatchDialog(() => { ExitConfirmed = true; this.Exit(); diff --git a/osu.Game/Screens/OnlinePlay/Playlists/ClosePlaylistDialog.cs b/osu.Game/Screens/OnlinePlay/Playlists/ClosePlaylistDialog.cs index 08fed037d3..4dbe08e93e 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/ClosePlaylistDialog.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/ClosePlaylistDialog.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Game.Localisation; using osu.Game.Online.Rooms; using osu.Game.Overlays.Dialog; @@ -11,7 +12,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists { public ClosePlaylistDialog(Room room, Action closeAction) { - HeaderText = "Are you sure you want to close the following playlist:"; + HeaderText = DialogStrings.ClosePlaylistHeaderText; BodyText = room.Name; DangerousAction = closeAction; } diff --git a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs index e3981c85f0..c681f89cd0 100644 --- a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs +++ b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs @@ -5,19 +5,20 @@ using System; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Game.Beatmaps; +using osu.Game.Localisation; using osu.Game.Overlays.Dialog; using osu.Game.Scoring; namespace osu.Game.Screens.Select { - public partial class BeatmapClearScoresDialog : DangerousActionDialog + public partial class BeatmapClearScoresDialog : DeletionDialog { [Resolved] private ScoreManager scoreManager { get; set; } = null!; public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action? onCompletion = null) { - BodyText = $"All local scores on {beatmapInfo.GetDisplayTitle()}"; + BodyText = DialogStrings.BeatmapClearScoresBodyText(beatmapInfo.GetDisplayTitle()); DangerousAction = () => { Task.Run(() => scoreManager.Delete(beatmapInfo)) From 9105fc15b244a0c3a4d59241d7529de7562500cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Mar 2026 17:57:25 +0900 Subject: [PATCH 06/21] Fix editor not updating titlebar with new difficulty name after rename (#36908) --- osu.Game/Screens/Edit/Editor.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 4ba1b2fac2..164d02d869 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -188,15 +188,14 @@ namespace osu.Game.Screens.Edit private bool isNewBeatmap; - protected override UserActivity InitialActivity - { - get - { - if (Beatmap.Value.Metadata.Author.OnlineID == api.LocalUser.Value.OnlineID) - return new UserActivity.EditingBeatmap(Beatmap.Value.BeatmapInfo); + protected override UserActivity InitialActivity => getCurrentUserActivity(); - return new UserActivity.ModdingBeatmap(Beatmap.Value.BeatmapInfo); - } + private UserActivity getCurrentUserActivity() + { + if (Beatmap.Value.Metadata.Author.OnlineID == api.LocalUser.Value.OnlineID) + return new UserActivity.EditingBeatmap(Beatmap.Value.BeatmapInfo); + + return new UserActivity.ModdingBeatmap(Beatmap.Value.BeatmapInfo); } protected override bool InitialBackButtonVisibility => false; @@ -604,6 +603,9 @@ namespace osu.Game.Screens.Edit updateLastSavedHash(); onScreenDisplay?.Display(new BeatmapEditorToast(ToastStrings.BeatmapSaved, editorBeatmap.BeatmapInfo.GetDisplayTitle())); Saved?.Invoke(); + + // This triggers an update to the window title post-save (ie if the difficulty name changed). + Activity.Value = getCurrentUserActivity(); return true; } From 14743a14eb243922ca65205cfd72f6dad1f2ef38 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Mar 2026 20:40:54 +0900 Subject: [PATCH 07/21] Fix "Deselect all" mods button becoming enabled when system mods are applied (#36913) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/ppy/osu/issues/36906. --------- Co-authored-by: Bartłomiej Dach --- .../TestSceneModSelectOverlay.cs | 29 +++++++++++++++++++ .../Overlays/Mods/DeselectAllModsButton.cs | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index d0778172d9..b4f9365c8f 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -698,6 +698,35 @@ namespace osu.Game.Tests.Visual.UserInterface AddUntilStep("all mods deselected", () => !SelectedMods.Value.Any()); } + [Test] + public void TestTouchDeviceDoesNotInterfereWithDeselectAll() + { + createScreen(); + changeRuleset(0); + + AddAssert("deselect all button disabled", () => !this.ChildrenOfType().Single().Enabled.Value); + + AddStep("select TD", () => SelectedMods.Value = new Mod[] { new OsuModTouchDevice() }); + AddAssert("deselect all button still disabled", () => !this.ChildrenOfType().Single().Enabled.Value); + + AddStep("click deselect all button", () => + { + InputManager.MoveMouseTo(this.ChildrenOfType().Single()); + InputManager.Click(MouseButton.Left); + }); + + AddUntilStep("touch mod still present", () => SelectedMods.Value, () => Is.EqualTo(new Mod[] { new OsuModTouchDevice() })); + + AddStep("select NC + TD", () => SelectedMods.Value = new Mod[] { new OsuModTouchDevice(), new OsuModNightcore() }); + AddStep("click deselect all button", () => + { + InputManager.MoveMouseTo(this.ChildrenOfType().Single()); + InputManager.Click(MouseButton.Left); + }); + + AddUntilStep("touch mod still present", () => SelectedMods.Value, () => Is.EqualTo(new Mod[] { new OsuModTouchDevice() })); + } + [Test] public void TestDeselectAllViaButton() { diff --git a/osu.Game/Overlays/Mods/DeselectAllModsButton.cs b/osu.Game/Overlays/Mods/DeselectAllModsButton.cs index 9b8ae1e3b6..0e5bb4d3da 100644 --- a/osu.Game/Overlays/Mods/DeselectAllModsButton.cs +++ b/osu.Game/Overlays/Mods/DeselectAllModsButton.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Mods private void updateEnabledState() { - Enabled.Value = selectedMods.Value.Any(); + Enabled.Value = selectedMods.Value.Any(m => m.Type != ModType.System); } } } From 87b37fd3860d75c0a90f7a67adb94e3267d1779b Mon Sep 17 00:00:00 2001 From: MayoCollector Date: Wed, 11 Mar 2026 02:27:03 +0900 Subject: [PATCH 08/21] Fix volume slider title text horizontal scaling on some languages (#36915) closes #36892. |master|This PR| |---|---| |![osu_2026-03-10_18-37-55](https://github.com/user-attachments/assets/15defef7-e1b8-485b-928b-886bb79215e2)|![osu_2026-03-10_18-43-40](https://github.com/user-attachments/assets/df4926f8-d960-45e2-ab98-1b455dc789b5)| --- osu.Game/Overlays/Volume/VolumeMeter.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index ec3d897a63..e75ee14067 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -215,6 +215,7 @@ namespace osu.Game.Overlays.Volume new Container { Size = LABEL_SIZE, + AutoSizeAxes = Axes.X, CornerRadius = 10, Masking = true, Margin = new MarginPadding { Left = CircleSize + 10 }, @@ -229,6 +230,10 @@ namespace osu.Game.Overlays.Volume }, new OsuSpriteText { + Margin = new MarginPadding + { + Horizontal = 32, + }, Anchor = Anchor.Centre, Origin = Anchor.Centre, Font = OsuFont.GetFont(weight: FontWeight.Bold), From ce571e328df9ddc12fce469fba10dbe13184c5da Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 11 Mar 2026 15:48:04 +0900 Subject: [PATCH 09/21] Ranked Play: Fix casing inconsistency in results screen (#36931) This is kind of annoying... Some hit results are given custom names (e.g. "slider tick"): https://github.com/ppy/osu/blob/87b37fd3860d75c0a90f7a67adb94e3267d1779b/osu.Game.Rulesets.Osu/OsuRuleset.cs#L301-L320 While others go through that `base` call which uses the enum descriptions (e.g. "Great"): https://github.com/ppy/osu/blob/87b37fd3860d75c0a90f7a67adb94e3267d1779b/osu.Game/Rulesets/Scoring/HitResult.cs#L53-L56 --- .../RankedPlay/ResultsScreen.ScoreStatisticsDisplay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.ScoreStatisticsDisplay.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.ScoreStatisticsDisplay.cs index 217984beff..0f15402200 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.ScoreStatisticsDisplay.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.ScoreStatisticsDisplay.cs @@ -3,6 +3,7 @@ using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Scoring; @@ -48,7 +49,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay Children = score.GetStatisticsForDisplay().Select(it => new BeatmapTitleWedge.StatisticDifficulty { Width = 80, - Value = new BeatmapTitleWedge.StatisticDifficulty.Data(it.DisplayName, it.Count, it.Count, it.MaxCount ?? it.Count), + Value = new BeatmapTitleWedge.StatisticDifficulty.Data(it.DisplayName.ToTitle(), it.Count, it.Count, it.MaxCount ?? it.Count), AccentColour = colours.PrimaryDarker, }).ToArray(), } From 4c0657f4ca88769fcc3b1cb4fa2dcc8bb862f9e3 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 11 Mar 2026 17:04:51 +0900 Subject: [PATCH 10/21] Ranked Play: Add countdown timer to all screens (#36930) There's been [some feedback](https://discord.com/channels/90072389919997952/1476979671886205060/1477868178775216148) that there's no timer during some screens. Personally I feel like some screens shouldn't require it, but I get it. The results screen is going to be the most controversial one, where I've decided to shift the content down a bit - it would otherwise overlap with the progress bar. Another option is to make the progress bar shorter, but I feel like that makes things inconsistent. image Regarding implementation, I'm not entirely sure on it being added to every subscreen via `RankedPlaySubScreen` instead of just a single component at a top level. I did it this way because the colour scheme seems annoying to change without recreating the entire component (or otherwise all of its children) anyway. --- .../Components/RankedPlayStageDisplay.cs | 77 ++++++++++++++++--- .../Matchmaking/RankedPlay/DiscardScreen.cs | 16 ++-- .../Matchmaking/RankedPlay/EndedScreen.cs | 4 + .../Matchmaking/RankedPlay/GameplayScreen.cs | 4 + .../RankedPlay/GameplayWarmupScreen.cs | 4 + .../RankedPlay/Intro/IntroScreen.cs | 5 ++ .../RankedPlay/OpponentPickScreen.cs | 12 +-- .../Matchmaking/RankedPlay/PickScreen.cs | 10 +-- .../RankedPlay/RankedPlaySubScreen.cs | 27 ++++++- .../Matchmaking/RankedPlay/ResultsScreen.cs | 20 ++--- 10 files changed, 137 insertions(+), 42 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/RankedPlayStageDisplay.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/RankedPlayStageDisplay.cs index d0fb4f9332..8bcd66292a 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/RankedPlayStageDisplay.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Components/RankedPlayStageDisplay.cs @@ -3,7 +3,6 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; @@ -21,24 +20,20 @@ using osuTK.Graphics; namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components { - public partial class RankedPlayStageDisplay : CompositeDrawable + public partial class RankedPlayStageDisplay : VisibilityContainer { - public required LocalisableString Heading { get; init; } - - public required LocalisableString Caption { get; init; } - - public Color4? CaptionColour { get; init; } - [Resolved] private MultiplayerClient client { get; set; } = null!; private readonly RankedPlayColourScheme colourScheme; private Drawable headingTextBackground = null!; - private OsuSpriteText headingText = null!; private Drawable progressBar = null!; private OsuSpriteText progressText = null!; + private OsuSpriteText? headingText; + private OsuSpriteText? captionText; + private DateTimeOffset countdownStartTime; private DateTimeOffset countdownEndTime; @@ -50,7 +45,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load() { const float phase_text_background_height = 55; Vector2 progressBarSize = new Vector2(300, 25); @@ -162,7 +157,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components } ] }, - new OsuSpriteText + captionText = new OsuSpriteText { Margin = new MarginPadding { @@ -176,6 +171,54 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components }; } + private LocalisableString heading; + + /// + /// Heading text to be displayed indicating the purpose of the current stage. + /// + public LocalisableString Heading + { + get => heading; + set + { + heading = value; + if (headingText != null) + headingText.Text = value; + } + } + + private LocalisableString caption; + + /// + /// Subtitle text to be displayed indicating the action a user should take in the current stage. + /// + public LocalisableString Caption + { + get => caption; + set + { + caption = value; + if (captionText != null) + captionText.Text = value; + } + } + + private Color4? captionColour; + + /// + /// Overrides the default caption colour from the colour scheme with a custom one. + /// + public Color4? CaptionColour + { + get => captionColour; + set + { + captionColour = value; + if (captionText != null) + captionText.Colour = value ?? colourScheme.Primary; + } + } + protected override void LoadComplete() { base.LoadComplete(); @@ -194,7 +237,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components { base.Update(); - headingTextBackground.Width = headingText.DrawWidth + 80; + headingTextBackground.Width = headingText!.DrawWidth + 80; TimeSpan duration = countdownEndTime - countdownStartTime; TimeSpan remaining = countdownEndTime - DateTimeOffset.Now; @@ -226,6 +269,16 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components countdownEndTime = DateTimeOffset.Now; }); + protected override void PopIn() + { + this.FadeIn(); + } + + protected override void PopOut() + { + this.FadeOut(); + } + protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/DiscardScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/DiscardScreen.cs index c044a0d4c6..69da87aaa0 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/DiscardScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/DiscardScreen.cs @@ -11,6 +11,7 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; +using osu.Framework.Localisation; using osu.Game.Audio; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -33,6 +34,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay public CardFlow CenterRow { get; private set; } = null!; + protected override LocalisableString StageHeading => "Discard Phase"; + protected override LocalisableString StageCaption => "Replace cards from your hand"; + private PlayerHandOfCards playerHand = null!; private ShearedButton discardButton = null!; private OsuTextFlowContainer explainer = null!; @@ -57,6 +61,11 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay private DateTimeOffset stageEndTime; private TimeSpan stageDuration; + public DiscardScreen() + { + StageDisplay.CaptionColour = Color4.White; + } + [BackgroundDependencyLoader] private void load(AudioManager audio) { @@ -72,13 +81,6 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - new RankedPlayStageDisplay(RankedPlayColourScheme.Blue) - { - Heading = "Discard Phase", - Caption = "Replace cards from your hand", - CaptionColour = Color4.White, - Margin = new MarginPadding { Top = 60 }, - }, discardButton = new ShearedButton { Name = "Discard Button", diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/EndedScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/EndedScreen.cs index ba0549e5fa..b76f8a7944 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/EndedScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/EndedScreen.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -24,6 +25,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay /// public Action? ExitRequested { get; init; } + protected override LocalisableString StageHeading => "Results"; + protected override LocalisableString StageCaption => string.Empty; + [Resolved] private RankedPlayMatchInfo matchInfo { get; set; } = null!; diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayScreen.cs index 8a558b24e3..251c304995 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayScreen.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; @@ -12,6 +13,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay { public partial class GameplayScreen : RankedPlaySubScreen { + protected override LocalisableString StageHeading => "Gameplay"; + protected override LocalisableString StageCaption => string.Empty; + [BackgroundDependencyLoader] private void load() { diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayWarmupScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayWarmupScreen.cs index 80f4bb4ad5..c01a732c74 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayWarmupScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayWarmupScreen.cs @@ -8,6 +8,7 @@ using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Localisation; using osu.Framework.Logging; using osu.Game.Database; using osu.Game.Graphics.Containers; @@ -24,6 +25,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay { public override bool ShowBeatmapBackground => true; + protected override LocalisableString StageHeading => "Gameplay"; + protected override LocalisableString StageCaption => string.Empty; + [Cached(typeof(IBindable))] private readonly Bindable lastLookupResult = new Bindable(); diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Intro/IntroScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Intro/IntroScreen.cs index 87fac18026..7cfed62015 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Intro/IntroScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Intro/IntroScreen.cs @@ -9,6 +9,7 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Localisation; using osu.Game.Database; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; @@ -20,9 +21,13 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Intro { public partial class IntroScreen : RankedPlaySubScreen { + protected override LocalisableString StageHeading => string.Empty; + protected override LocalisableString StageCaption => string.Empty; + public IntroScreen() { CornerPieceVisibility.Value = Visibility.Hidden; + CountdownVisibility.Value = Visibility.Hidden; } [Resolved] diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/OpponentPickScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/OpponentPickScreen.cs index 122b3ff8dd..aa8f392890 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/OpponentPickScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/OpponentPickScreen.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; +using osu.Framework.Localisation; using osu.Framework.Logging; using osu.Game.Audio; using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay; @@ -22,6 +23,11 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay { public CardFlow CenterRow { get; private set; } = null!; + protected override LocalisableString StageHeading => "Pick Phase"; + protected override LocalisableString StageCaption => "Waiting for your opponent..."; + + protected override RankedPlayColourScheme ColourScheme => RankedPlayColourScheme.Red; + private PlayerHandOfCards playerHand = null!; private OpponentHandOfCards opponentHand = null!; @@ -46,12 +52,6 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - new RankedPlayStageDisplay(RankedPlayColourScheme.Red) - { - Heading = "Pick Phase", - Caption = "Waiting for your opponent...", - Margin = new MarginPadding { Top = 60 }, - }, ]; CenterColumn.Children = diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs index 0a232322ca..2d94e28ff3 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; +using osu.Framework.Localisation; using osu.Framework.Logging; using osu.Game.Audio; using osu.Game.Online.Multiplayer; @@ -27,6 +28,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay public CardFlow CenterRow { get; private set; } = null!; + protected override LocalisableString StageHeading => "Pick Phase"; + protected override LocalisableString StageCaption => "It's your turn to play a card!"; + private PlayerHandOfCards playerHand = null!; private OpponentHandOfCards opponentHand = null!; @@ -65,12 +69,6 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - new RankedPlayStageDisplay(RankedPlayColourScheme.Blue) - { - Heading = "Pick Phase", - Caption = "It's your turn to play a card!", - Margin = new MarginPadding { Top = 60 }, - }, ]; CenterColumn.Children = diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlaySubScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlaySubScreen.cs index b19340107f..46aa1d20cb 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlaySubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/RankedPlaySubScreen.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Localisation; using osu.Game.Online.Multiplayer; using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components; using osuTK; @@ -18,19 +19,34 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay public const float CENTERED_CARD_SCALE = 1.2f; public readonly Bindable CornerPieceVisibility = new Bindable(Visibility.Visible); + protected readonly Bindable CountdownVisibility = new Bindable(Visibility.Visible); public virtual bool ShowBeatmapBackground => false; + /// + /// Heading text to be displayed indicating the purpose of the current stage. + /// + protected abstract LocalisableString StageHeading { get; } + + /// + /// Subtitle text to be displayed indicating the action a user should take in the current stage. + /// + protected abstract LocalisableString StageCaption { get; } + + /// + /// The colour scheme commonly used for components of this screen. + /// + protected virtual RankedPlayColourScheme ColourScheme => RankedPlayColourScheme.Blue; + [Resolved] private MultiplayerClient client { get; set; } = null!; protected MultiplayerClient Client => client; protected override Container Content { get; } - protected readonly Container CenterColumn; - protected readonly FillFlowContainer ButtonsContainer; + protected readonly RankedPlayStageDisplay StageDisplay; protected RankedPlaySubScreen() { @@ -62,6 +78,13 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay Direction = FillDirection.Vertical, Spacing = new Vector2(8) }, + StageDisplay = new RankedPlayStageDisplay(ColourScheme) + { + Heading = StageHeading, + Caption = StageCaption, + Margin = new MarginPadding { Top = 60 }, + State = { BindTarget = CountdownVisibility } + }, ]; } diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs index 872920272a..129ffc61dc 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Transforms; +using osu.Framework.Localisation; using osu.Framework.Logging; using osu.Framework.Utils; using osu.Game.Beatmaps; @@ -36,6 +37,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay { public partial class ResultsScreen : RankedPlaySubScreen { + protected override LocalisableString StageHeading => "Results"; + protected override LocalisableString StageCaption => string.Empty; + public override bool ShowBeatmapBackground => true; [Resolved] @@ -63,14 +67,11 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay { CornerPieceVisibility.Value = Visibility.Hidden; - InternalChildren = new Drawable[] + AddInternal(loadingSpinner = new LoadingSpinner { - loadingSpinner = new LoadingSpinner - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, - }; + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); } protected override void LoadComplete() @@ -160,6 +161,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay AddInternal(new ResultScreenContent { + RelativeSizeAxes = Axes.Both, + // A little bit of room for the countdown timer... + Margin = new MarginPadding { Top = 45 }, PlayerScore = playerScore, OpponentScore = opponentScore, PlayerDamageInfo = matchInfo.RoomState.Users[playerId].DamageInfo!, @@ -210,8 +214,6 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay .OfType() .MaxBy(it => it.Damage)!; - RelativeSizeAxes = Axes.Both; - AddInternal(panelScaffold = new PanelScaffold { Anchor = Anchor.Centre, From d0d5d97cfea8b4664c0110ca384d57c3ef44aec5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 11 Mar 2026 19:08:26 +0900 Subject: [PATCH 11/21] Add replay / spectator mode scrolling text back (#36911) As mentioned in https://github.com/ppy/osu/discussions/36883. This has caught me off-guard a few times. Was a quick one to make this work like it does on stable. It doesn't fit as well as stable because we have a lot of elements at the top of the screen, but I think it's better than nothing, as it lets you know you're in a replay quick obviously. I don't think we can easily localise strings with formatting in them yet. Maybe using a `MarkdownContainer` or something? --- .../TestSceneExpandedPanelMiddleContent.cs | 4 +- osu.Game/Rulesets/Mods/ModExtensions.cs | 2 + osu.Game/Screens/Play/Player.cs | 10 +++- osu.Game/Screens/Play/ReplayPlayer.cs | 25 +++++++++ osu.Game/Screens/Play/ScrollingMessage.cs | 44 +++++++++++++++ osu.Game/Screens/Play/SpectatorPlayer.cs | 20 ++++--- .../Expanded/ExpandedPanelMiddleContent.cs | 40 +------------- .../Screens/Ranking/Expanded/PlayedOnText.cs | 55 +++++++++++++++++++ 8 files changed, 150 insertions(+), 50 deletions(-) create mode 100644 osu.Game/Screens/Play/ScrollingMessage.cs create mode 100644 osu.Game/Screens/Ranking/Expanded/PlayedOnText.cs diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs index eade5aaf5d..df9dbf90ee 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs @@ -67,7 +67,7 @@ namespace osu.Game.Tests.Visual.Ranking AddAssert("mapped by text not present", () => this.ChildrenOfType().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by"))); - AddAssert("play time displayed", () => this.ChildrenOfType().Any()); + AddAssert("play time displayed", () => this.ChildrenOfType().Any()); } [Test] @@ -137,7 +137,7 @@ namespace osu.Game.Tests.Visual.Ranking showPanel(score); }); - AddAssert("play time not displayed", () => !this.ChildrenOfType().Any()); + AddAssert("play time not displayed", () => !this.ChildrenOfType().Any()); } [Test] diff --git a/osu.Game/Rulesets/Mods/ModExtensions.cs b/osu.Game/Rulesets/Mods/ModExtensions.cs index bd2d42f3eb..b9f723e88e 100644 --- a/osu.Game/Rulesets/Mods/ModExtensions.cs +++ b/osu.Game/Rulesets/Mods/ModExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; @@ -20,6 +21,7 @@ namespace osu.Game.Rulesets.Mods Replay = replayData.Replay, ScoreInfo = { + Date = DateTimeOffset.Now, User = new APIUser { Id = replayData.User.OnlineID, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ba543db996..97c0a0b769 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -311,7 +311,7 @@ namespace osu.Game.Screens.Play { // underlay and gameplay should have access to the skinning sources. createUnderlayComponents(Beatmap.Value), - createGameplayComponents(Beatmap.Value) + createGameplayComponents() } }, FailOverlay = new FailOverlay @@ -426,6 +426,11 @@ namespace osu.Game.Screens.Play IsBreakTime.BindValueChanged(onBreakTimeChanged, true); } + /// + /// Implement to add any components which should exist above gameplay but below the HUD. + /// + protected virtual Drawable CreateOverlayComponents() => Empty(); + protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart); private Drawable createUnderlayComponents(WorkingBeatmap working) @@ -451,7 +456,7 @@ namespace osu.Game.Screens.Play return container; } - private Drawable createGameplayComponents(IWorkingBeatmap working) => new ScalingContainer(ScalingMode.Gameplay) + private Drawable createGameplayComponents() => new ScalingContainer(ScalingMode.Gameplay) { Children = new Drawable[] { @@ -474,6 +479,7 @@ namespace osu.Game.Screens.Play Children = new[] { DimmableStoryboard.OverlayLayerContainer.CreateProxy(), + CreateOverlayComponents(), HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods, Configuration) { HoldToQuit = diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index cd769d7615..e3c0361052 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -12,12 +12,15 @@ using osu.Framework.Input.Events; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Screens.Play.Leaderboards; using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Ranking; +using osu.Game.Screens.Ranking.Expanded; using osu.Game.Skinning; using osu.Game.Users; @@ -97,6 +100,7 @@ namespace osu.Game.Screens.Play playbackSettings.UserPlaybackRate.BindTo(master.UserPlaybackRate); HUDOverlay.PlayerSettingsOverlay.AddAtStart(playbackSettings); + AddInternal(new RulesetSkinProvidingContainer(GameplayState.Ruleset, GameplayState.Beatmap, Beatmap.Value.Skin) { Child = failIndicator = new ReplayFailIndicator(GameplayClockContainer) @@ -113,6 +117,27 @@ namespace osu.Game.Screens.Play }); } + protected override Drawable CreateOverlayComponents() + { + OsuTextFlowContainer message = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Style.Body) { AutoSizeAxes = Axes.Both }; + message.AddText("Watching "); + message.AddText(Score.ScoreInfo.User.Username, s => s.Font = s.Font.With(weight: FontWeight.SemiBold)); + message.AddText(" play "); + message.AddText(Beatmap.Value.BeatmapInfo.GetDisplayTitleRomanisable(), s => s.Font = s.Font.With(weight: FontWeight.SemiBold)); + message.AddText(" on "); + message.AddArbitraryDrawable(new PlayedOnText(Score.ScoreInfo.Date, false) + { + Font = OsuFont.Style.Body.With(weight: FontWeight.SemiBold), + }); + + return new ScrollingMessage(message) + { + Y = 100, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }; + } + protected override void PrepareReplay() { DrawableRuleset?.SetReplayScore(Score); diff --git a/osu.Game/Screens/Play/ScrollingMessage.cs b/osu.Game/Screens/Play/ScrollingMessage.cs new file mode 100644 index 0000000000..9dcd303fe1 --- /dev/null +++ b/osu.Game/Screens/Play/ScrollingMessage.cs @@ -0,0 +1,44 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Screens.Play +{ + public partial class ScrollingMessage : CompositeDrawable + { + private readonly Drawable messageContent; + + public ScrollingMessage(Drawable messageContent) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChild = this.messageContent = messageContent; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + this.FadeInFromZero(2000, Easing.OutQuint); + resetMessagePosition(); + } + + protected override void Update() + { + base.Update(); + + if (messageContent.X + messageContent.DrawWidth > 0) + messageContent.X -= (float)Clock.ElapsedFrameTime * 0.05f; + else + resetMessagePosition(); + } + + private void resetMessagePosition() + { + messageContent.X = DrawWidth + 10; + } + } +} diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index 22c966e0af..6d008447bb 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -7,7 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.Containers; using osu.Game.Online.Spectator; using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays.Types; @@ -29,17 +29,23 @@ namespace osu.Game.Screens.Play this.score = score; } - [BackgroundDependencyLoader] - private void load() + protected override Drawable CreateOverlayComponents() { - AddInternal(new OsuSpriteText + // TODO: This should be customised for `MultiplayerSpectatorPlayer` to be static and only show the player name. + // Or maybe we should completely redesign this to show the user avatar and other things if that happens. + OsuTextFlowContainer message = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Style.Body) { AutoSizeAxes = Axes.Both }; + message.AddText("Watching "); + message.AddText(Score.ScoreInfo.User.Username, s => s.Font = s.Font.With(weight: FontWeight.SemiBold)); + message.AddText(" play "); + message.AddText(Beatmap.Value.BeatmapInfo.GetDisplayTitleRomanisable(), s => s.Font = s.Font.With(weight: FontWeight.SemiBold)); + message.AddText(" live", s => s.Font = s.Font.With(weight: FontWeight.Bold)); + + return new ScrollingMessage(message) { - Text = $"Watching {score.ScoreInfo.User.Username} playing live!", - Font = OsuFont.Default.With(size: 30), Y = 100, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - }); + }; } protected override void LoadComplete() diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs index 445d219c7f..0f11b01dde 100644 --- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs @@ -1,19 +1,15 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Framework.Extensions; -using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; -using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -237,7 +233,7 @@ namespace osu.Game.Screens.Ranking.Expanded }); if (score.Date != default) - AddInternal(new PlayedOnText(score.Date)); + AddInternal(new PlayedOnText(score.Date, true)); } protected override void LoadComplete() @@ -268,40 +264,6 @@ namespace osu.Game.Screens.Ranking.Expanded }); } - public partial class PlayedOnText : OsuSpriteText - { - private readonly DateTimeOffset time; - private readonly Bindable prefer24HourTime = new Bindable(); - - public PlayedOnText(DateTimeOffset time) - { - this.time = time; - - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; - Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold); - } - - [BackgroundDependencyLoader] - private void load(OsuConfigManager configManager) - { - configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - prefer24HourTime.BindValueChanged(_ => updateDisplay(), true); - } - - private void updateDisplay() - { - Text = LocalisableString.Format("Played on {0}", - time.ToLocalTime().ToLocalisableString(prefer24HourTime.Value ? @"d MMMM yyyy HH:mm" : @"d MMMM yyyy h:mm tt")); - } - } - internal partial class ClickableMetadata : OsuHoverContainer { [Resolved] diff --git a/osu.Game/Screens/Ranking/Expanded/PlayedOnText.cs b/osu.Game/Screens/Ranking/Expanded/PlayedOnText.cs new file mode 100644 index 0000000000..9ac453bfb7 --- /dev/null +++ b/osu.Game/Screens/Ranking/Expanded/PlayedOnText.cs @@ -0,0 +1,55 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Extensions.LocalisationExtensions; +using osu.Framework.Graphics; +using osu.Framework.Localisation; +using osu.Game.Configuration; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Ranking.Expanded +{ + public partial class PlayedOnText : OsuSpriteText + { + private readonly DateTimeOffset time; + private readonly bool withPrefix; + private readonly Bindable prefer24HourTime = new Bindable(); + + public PlayedOnText(DateTimeOffset time, bool withPrefix) + { + this.time = time; + this.withPrefix = withPrefix; + + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold); + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager configManager) + { + configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + prefer24HourTime.BindValueChanged(_ => updateDisplay(), true); + } + + private void updateDisplay() + { + var timeText = time.ToLocalTime().ToLocalisableString(prefer24HourTime.Value ? @"d MMMM yyyy HH:mm" : @"d MMMM yyyy h:mm tt"); + + if (withPrefix) + Text = LocalisableString.Format("Played on {0}", timeText); + else + Text = timeText; + } + } +} From 390fc521e9342778fa74f8f9ae899d21976e3519 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Wed, 11 Mar 2026 20:06:01 +0800 Subject: [PATCH 12/21] Fix avatar sometimes showing as guest in beatmap detail comment container (#36935) - close https://github.com/ppy/osu/issues/34969 The solution here is shown in the issue. I don't think this needs a test... if need I will write one --- osu.Game/Overlays/Comments/CommentsContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 5e277357a9..20b12806ce 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -188,7 +188,7 @@ namespace osu.Game.Overlays.Comments protected override void LoadComplete() { User.BindValueChanged(_ => refetchComments()); - User.BindValueChanged(e => avatar.User = e.NewValue); + User.BindValueChanged(e => avatar.User = e.NewValue, true); Sort.BindValueChanged(_ => refetchComments(), true); base.LoadComplete(); } From 94c9f16b27e2de13bfa24345ae579f16d03a85c8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 Mar 2026 16:03:01 +0900 Subject: [PATCH 13/21] Update editor hitsound icons with new designs from Adarin (#36940) | Before | After | | :---: | :---: | | 2026-03-12 00 56 58@2x | 2026-03-12 01 06 04@2x | --- osu.Game/Graphics/OsuIcon.cs | 4 ++++ .../Edit/Compose/Components/ComposeBlueprintContainer.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/OsuIcon.cs b/osu.Game/Graphics/OsuIcon.cs index a02c611285..5eccbabf95 100644 --- a/osu.Game/Graphics/OsuIcon.cs +++ b/osu.Game/Graphics/OsuIcon.cs @@ -100,6 +100,7 @@ namespace osu.Game.Graphics public static IconUsage EditorSelect => get(OsuIconMapping.EditorSelect); public static IconUsage EditorSound => get(OsuIconMapping.EditorSound); public static IconUsage EditorWhistle => get(OsuIconMapping.EditorWhistle); + public static IconUsage EditorClap => get(OsuIconMapping.EditorClap); public static IconUsage Tortoise => get(OsuIconMapping.Tortoise); public static IconUsage Hare => get(OsuIconMapping.Hare); @@ -426,6 +427,9 @@ namespace osu.Game.Graphics [Description(@"Editor/whistle")] EditorWhistle, + [Description(@"Editor/clap")] + EditorClap, + [Description(@"tortoise")] Tortoise, diff --git a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs index 11ae0ef56d..eff74bd556 100644 --- a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs @@ -230,7 +230,7 @@ namespace osu.Game.Screens.Edit.Compose.Components switch (sampleName) { case HitSampleInfo.HIT_CLAP: - return new SpriteIcon { Icon = FontAwesome.Solid.Hands }; + return new SpriteIcon { Icon = OsuIcon.EditorClap }; case HitSampleInfo.HIT_WHISTLE: return new SpriteIcon { Icon = OsuIcon.EditorWhistle }; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b4c66223ed..384d5412a8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ - + From 365b88b4a9b72fbcdab1fc6c78490ab594ab3160 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 Mar 2026 21:48:22 +0900 Subject: [PATCH 14/21] Ensure folder migration screen uses a blank background to avoid readability issues (#36948) https://github.com/ppy/osu/issues/36941 --- .../Settings/Sections/Maintenance/MigrationRunScreen.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationRunScreen.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationRunScreen.cs index c0363851ef..ce33039d68 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationRunScreen.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationRunScreen.cs @@ -15,12 +15,15 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; using osu.Game.Screens; +using osu.Game.Screens.Backgrounds; using osuTK; namespace osu.Game.Overlays.Settings.Sections.Maintenance { public partial class MigrationRunScreen : OsuScreen { + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); + private readonly DirectoryInfo destination; [Resolved(canBeNull: true)] From 28fbb83cc660f737e29d2421c3724b8cf440e386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 12 Mar 2026 14:05:39 +0100 Subject: [PATCH 15/21] Fix Simplified Rhythm mod breaking diffcalc when applied to some maps (#36947) - closes https://github.com/ppy/osu/issues/36942 - fixes https://osu.ppy.sh/community/forums/topics/2187041?n=1 ## [Ensure Simplified Rhythm mod does not produce beatmaps with objects out of order](https://github.com/ppy/osu/commit/f4807b3a42dbf46ea0e669b0ba658feaef9baca5) This is a last ditch safety. This mod has more apparent issues (see below) but this is a first step of restoring sanity. Aside than the other fix described below I have not attempted to figure out further why this is happening because the conversion logic is in over my head. I just want hard breakage to not be possible. Why this extra sort is necessary can be investigated by @Hiviexd if he's so inclined. ## [Fix `GetClosestBeatDivisor()` not working correctly with negative time instants](https://github.com/ppy/osu/commit/88dc0d8a73c712a040635af262d7519fe6d772a0) This was causing the 1/3 -> 1/2 conversion in Simplified Rhythm to engage on some maps that weren't even mapped in waltz time. Those maps had the common trait of having a timing point with a negative start time. Notably this could feasibly affect other places as well, like mania beat snap colouring, or the Synesthesia osu! mod.
testing Tested with Simplified Rhythm engaged, with 1/6 -> 1/4 and 1/3 -> 1/2 conversion enabled [BULANOVA - NE PLACH' [oni]](https://osu.ppy.sh/beatmapsets/1740291#taiko/3664995) (1/8 snap): - No mods: 5.18* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 3.48* - Simplified Rhythm @ 933de7ab: 5.18* [BULANOVA - NE PLACH' [inner oni]](https://osu.ppy.sh/beatmapsets/1740291#taiko/3648625) (1/8 snap): - No mods: 5.84* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 4.13* - Simplified Rhythm @ 933de7ab: 5.84* [BULANOVA - NE PLACH' [don't cry]](https://osu.ppy.sh/beatmapsets/1740291#taiko/3557681) (1/8 snap): - No mods: 6.91* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 4.84* - Simplified Rhythm @ 933de7ab: 6.91* [Mili - Peach Pit and Cyanide [nik's Normal]](https://osu.ppy.sh/beatmapsets/2468654#osu/5405909) (1/6 snap): - No mods: 1.63* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 1.10* - Simplified Rhythm @ 933de7ab: 1.10* [Mili - Peach Pit and Cyanide [Ix's Hard]](https://osu.ppy.sh/beatmapsets/2468654#osu/5405906) (1/3 snap): - No mods: 2.50* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 1.71* - Simplified Rhythm @ 933de7ab: 1.71* [Mili - Peach Pit and Cyanide [nomi's Hidden Insane]](https://osu.ppy.sh/beatmapsets/2468654#osu/5405910) (1/3 snap): - No mods: 3.93* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 2.59* - Simplified Rhythm @ 933de7ab: 2.59* [Within Temptation - The Unforgiving [Stairway To The Skies]](https://osu.ppy.sh/beatmapsets/29157#osu/172617) (1/3 snap in editor): - No mods: 1.53* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 1.48* - Simplified Rhythm @ 933de7ab: 1.48* [Within Temptation - The Unforgiving [Iron]](https://osu.ppy.sh/beatmapsets/29157#osu/172612) (1/6 snap in editor): - No mods: 2.76* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 1.75* - Simplified Rhythm @ 933de7ab: 1.75* [Within Temptation - The Unforgiving [Marathon]](https://osu.ppy.sh/beatmapsets/29157#osu/156352) (1/4 snap in editor, but has 1/3 / 1/6 sections for sure): - No mods: 2.96* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 2.75* - Simplified Rhythm @ 933de7ab: 2.75* [Halozy - Genryuu Kaiko [Higan Torrent]](https://osu.ppy.sh/beatmapsets/180138#osu/433005) (1/4 snap): - No mods: 5.37* - Simplified Rhythm @ master: 0.00* - Simplified Rhythm @ f4807b3a: 3.95* - Simplified Rhythm @ 933de7ab: 5.37*
--- .../Mods/TaikoModSimplifiedRhythm.cs | 2 ++ .../NonVisual/ClosestBeatDivisorTest.cs | 12 ++++++++++++ .../Beatmaps/ControlPoints/ControlPointInfo.cs | 16 +++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModSimplifiedRhythm.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModSimplifiedRhythm.cs index 2132121cd2..dfaae8e99e 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModSimplifiedRhythm.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModSimplifiedRhythm.cs @@ -122,6 +122,8 @@ namespace osu.Game.Rulesets.Taiko.Mods } } } + + taikoBeatmap.HitObjects.Sort((a, b) => a.StartTime.CompareTo(b.StartTime)); } private int getSnapBetweenNotes(ControlPointInfo controlPointInfo, Hit currentNote, Hit nextNote) diff --git a/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs b/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs index 8a53759323..a563bcd865 100644 --- a/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs +++ b/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs @@ -66,6 +66,18 @@ namespace osu.Game.Tests.NonVisual assertClosestDivisors(divisors, closestDivisors, cpi); } + [Test] + public void TestNegativeTimingPointOffset() + { + var cpi = new ControlPointInfo(); + cpi.Add(-300000, new TimingControlPoint { BeatLength = 1000 }); + + double[] divisors = { 3.03d, 0.97d, 14, 13, 7.94d, 6.08d, 3.93d, 2.96d, 2.02d, 64 }; + double[] closestDivisors = { 3, 1, 16, 12, 8, 6, 4, 3, 2, 1 }; + + assertClosestDivisors(divisors, closestDivisors, cpi); + } + private static void assertClosestDivisors(IReadOnlyList divisors, IReadOnlyList closestDivisors, ControlPointInfo cpi, double step = 1) { List hitobjects = new List(); diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs index 8666f01129..30a6d9516e 100644 --- a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs +++ b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs @@ -169,7 +169,7 @@ namespace osu.Game.Beatmaps.ControlPoints public double GetClosestSnappedTime(double time, int beatDivisor, double? referenceTime = null) { var timingPoint = TimingPointAt(referenceTime ?? time); - double snappedTime = getClosestSnappedTime(timingPoint, time, beatDivisor); + double snappedTime = getClosestPositiveSnappedTime(timingPoint, time, beatDivisor); if (referenceTime.HasValue) return snappedTime; @@ -197,9 +197,19 @@ namespace osu.Game.Beatmaps.ControlPoints int closestDivisor = 0; double closestTime = double.MaxValue; + // `getClosestSnappedTime()` only returns positive time values. + // due to that, if `time` is allowed to be negative, the loop lower below could return bogus results + // as the "snapped time" will not necessarily be "closest" at that point. + // compensate for this by moving `time` by enough beat lengths to go back to the positives. + if (time < 0) + { + int offsetBeats = (int)Math.Ceiling(-time / timingPoint.BeatLength); + time += offsetBeats * timingPoint.BeatLength; + } + foreach (int divisor in BindableBeatDivisor.PREDEFINED_DIVISORS) { - double distanceFromSnap = Math.Abs(time - getClosestSnappedTime(timingPoint, time, divisor)); + double distanceFromSnap = Math.Abs(time - getClosestPositiveSnappedTime(timingPoint, time, divisor)); if (Precision.DefinitelyBigger(closestTime, distanceFromSnap)) { @@ -211,7 +221,7 @@ namespace osu.Game.Beatmaps.ControlPoints return closestDivisor; } - private static double getClosestSnappedTime(TimingControlPoint timingPoint, double time, int beatDivisor) + private static double getClosestPositiveSnappedTime(TimingControlPoint timingPoint, double time, int beatDivisor) { double beatLength = timingPoint.BeatLength / beatDivisor; double beats = (Math.Max(time, 0) - timingPoint.Time) / beatLength; From 2380fcd36dc89528dad08deeb7b37d9d37973bee Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 13 Mar 2026 08:54:19 +0300 Subject: [PATCH 16/21] Reuse existing triangles in `Triangles` background (#36951) As [per comment](https://github.com/ppy/osu/pull/36943#issuecomment-4045361755). Unfortunately I'm not able to reproduce such a big impact of triangles using linked pr (or at all really). In my case usage was low in the first place and went from 0.9% to 0.6% with this pr, so outside benchmarking would be great Improvement list: * No more sorted list. Basic list is being used which is sorted once after all the triangles added. * Out-of-bounds triangles are reused rather than removed and re-added. * On `Reset` if `AimCount` stays the same, all triangles are reused instead of being cleared and re-added. --- osu.Game/Graphics/Backgrounds/Triangles.cs | 64 +++++++++++++--------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index d22aa197bb..f4646e5af6 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -14,8 +14,8 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Primitives; using osu.Framework.Allocation; using System.Collections.Generic; +using Microsoft.Toolkit.HighPerformance; using osu.Framework.Graphics.Rendering; -using osu.Framework.Lists; using osu.Framework.Bindables; namespace osu.Game.Graphics.Backgrounds @@ -94,7 +94,7 @@ namespace osu.Game.Graphics.Backgrounds /// public float Velocity = 1; - private readonly SortedList parts = new SortedList(Comparer.Default); + private readonly List parts = new List(); private Random stableRandom; private IShader shader; @@ -127,9 +127,6 @@ namespace osu.Game.Graphics.Backgrounds { base.Update(); - if (CreateNewTriangles) - addTriangles(false); - float adjustedAlpha = HideAlphaDiscrepancies // Cubically scale alpha to make it drop off more sharply. ? MathF.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3) @@ -145,19 +142,31 @@ namespace osu.Game.Graphics.Backgrounds // dividing by triangleScale. float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * TriangleScale); - for (int i = 0; i < parts.Count; i++) + for (int i = parts.Count - 1; i >= 0; i--) { - TriangleParticle newParticle = parts[i]; + TriangleParticle particle = parts[i]; // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. - newParticle.Position.Y += Math.Max(0.5f, parts[i].Scale) * movedDistance; - newParticle.Colour.A = adjustedAlpha; + float newY = particle.Position.Y + Math.Max(0.5f, particle.Scale) * movedDistance; + float bottomY = newY + triangle_size * particle.Scale * equilateral_triangle_ratio / DrawHeight; - parts[i] = newParticle; + if (bottomY < 0) + { + if (!CreateNewTriangles) + { + parts.RemoveAt(i); + continue; + } - float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * equilateral_triangle_ratio / DrawHeight; - if (bottomPos < 0) - parts.RemoveAt(i); + particle.Position = getRandomPosition(false, particle.Scale); + } + else + { + particle.Position.Y = newY; + } + + particle.Colour.A = adjustedAlpha; + parts[i] = particle; } Invalidate(Invalidation.DrawNode); @@ -172,30 +181,33 @@ namespace osu.Game.Graphics.Backgrounds if (seed != null) stableRandom = new Random(seed.Value); - parts.Clear(); - addTriangles(true); - } - - protected int AimCount { get; private set; } - - private void addTriangles(bool randomY) - { // Limited by the maximum size of QuadVertexBuffer for safety. const int max_triangles = ushort.MaxValue / (IRenderer.VERTICES_PER_QUAD + 2); AimCount = (int)Math.Min(max_triangles, DrawWidth * DrawHeight * 0.002f / (TriangleScale * TriangleScale) * SpawnRatio); - int currentCount = parts.Count; + if (parts.Count == AimCount) + { + var span = parts.AsSpan(); - if (AimCount - currentCount == 0) - return; + for (int i = 0; i < span.Length; i++) + span[i].Position = getRandomPosition(true, span[i].Scale); + } + else + { + parts.Clear(); - for (int i = 0; i < AimCount - currentCount; i++) - parts.Add(createTriangle(randomY)); + for (int i = 0; i < AimCount; i++) + parts.Add(createTriangle(true)); + + parts.Sort(Comparer.Default); + } Invalidate(Invalidation.DrawNode); } + protected int AimCount { get; private set; } + private TriangleParticle createTriangle(bool randomY) { TriangleParticle particle = CreateTriangle(); From fd66d7c4e4bb7a15dce6e5c8e2e2b485828fe6b5 Mon Sep 17 00:00:00 2001 From: Denis Titovets Date: Sat, 14 Mar 2026 16:47:58 +0300 Subject: [PATCH 17/21] Localise some strings on `SecondFactorAuthForm` (#36961) --- osu.Game/Localisation/LoginPanelStrings.cs | 10 ++++++++++ osu.Game/Overlays/Login/SecondFactorAuthForm.cs | 9 +++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/osu.Game/Localisation/LoginPanelStrings.cs b/osu.Game/Localisation/LoginPanelStrings.cs index 925c2b9146..243f065906 100644 --- a/osu.Game/Localisation/LoginPanelStrings.cs +++ b/osu.Game/Localisation/LoginPanelStrings.cs @@ -49,6 +49,16 @@ namespace osu.Game.Localisation /// public static LocalisableString Register => new TranslatableString(getKey(@"register"), @"Register"); + /// + /// "An email has been sent to you with a verification code. Enter the code." + /// + public static LocalisableString CodeSent => new TranslatableString(getKey(@"code_sent"), @"An email has been sent to you with a verification code. Enter the code."); + + /// + /// "Enter code" + /// + public static LocalisableString EnterCode => new TranslatableString(getKey(@"enter_code"), @"Enter code"); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Overlays/Login/SecondFactorAuthForm.cs b/osu.Game/Overlays/Login/SecondFactorAuthForm.cs index 2cdc4bf6a6..38025de1d9 100644 --- a/osu.Game/Overlays/Login/SecondFactorAuthForm.cs +++ b/osu.Game/Overlays/Login/SecondFactorAuthForm.cs @@ -11,6 +11,7 @@ using osu.Framework.Logging; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; @@ -104,12 +105,12 @@ namespace osu.Game.Overlays.Login { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Text = "An email has been sent to you with a verification code. Enter the code.", + Text = LoginPanelStrings.CodeSent, }, codeTextBox = new OsuTextBox { InputProperties = new TextInputProperties(TextInputType.Code), - PlaceholderText = "Enter code", + PlaceholderText = LoginPanelStrings.EnterCode, RelativeSizeAxes = Axes.X, TabbableContentContainer = this, }, @@ -169,12 +170,12 @@ namespace osu.Game.Overlays.Login { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Text = "Please enter the code from your authenticator app.", + Text = UserVerificationStrings.BoxTotpHeading, }, codeTextBox = new OsuNumberBox { InputProperties = new TextInputProperties(TextInputType.NumericalPassword), - PlaceholderText = "Enter code", + PlaceholderText = LoginPanelStrings.EnterCode, RelativeSizeAxes = Axes.X, TabbableContentContainer = this, }, From ed905b761dbba26156dbd089286b5e77cba389dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 14 Mar 2026 15:05:59 +0100 Subject: [PATCH 18/21] Add models for new tournament-related multiplayer operations (#36953) Continuation of https://github.com/ppy/osu-server-spectator/issues/406 Operations in question being: - (un)locking rooms / `!mp (un)lock` (prevents players from changing team, will also include slots when slots are implemented) - rolling / `!roll` (frequently used in coin toss type situations, will receive nice animation to go with it) --- .../Online/Multiplayer/MatchServerEvent.cs | 1 + .../TeamVersus/TeamVersusRoomState.cs | 3 ++ .../Online/Multiplayer/MatchUserRequest.cs | 2 ++ osu.Game/Online/Multiplayer/RollEvent.cs | 36 +++++++++++++++++++ osu.Game/Online/Multiplayer/RollRequest.cs | 24 +++++++++++++ .../Online/Multiplayer/SetLockStateRequest.cs | 24 +++++++++++++ osu.Game/Online/SignalRWorkaroundTypes.cs | 3 ++ 7 files changed, 93 insertions(+) create mode 100644 osu.Game/Online/Multiplayer/RollEvent.cs create mode 100644 osu.Game/Online/Multiplayer/RollRequest.cs create mode 100644 osu.Game/Online/Multiplayer/SetLockStateRequest.cs diff --git a/osu.Game/Online/Multiplayer/MatchServerEvent.cs b/osu.Game/Online/Multiplayer/MatchServerEvent.cs index 402de392a8..723452d3f6 100644 --- a/osu.Game/Online/Multiplayer/MatchServerEvent.cs +++ b/osu.Game/Online/Multiplayer/MatchServerEvent.cs @@ -19,6 +19,7 @@ namespace osu.Game.Online.Multiplayer [Union(1, typeof(CountdownStoppedEvent))] [Union(2, typeof(MatchmakingAvatarActionEvent))] [Union(3, typeof(RankedPlayCardHandReplayEvent))] + [Union(4, typeof(RollEvent))] public abstract class MatchServerEvent { } diff --git a/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs index 3758429643..d5e30bb2e0 100644 --- a/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs @@ -12,6 +12,9 @@ namespace osu.Game.Online.Multiplayer.MatchTypes.TeamVersus [Key(0)] public List Teams { get; set; } = new List(); + [Key(1)] + public bool Locked { get; set; } + public static TeamVersusRoomState CreateDefault() => new TeamVersusRoomState { diff --git a/osu.Game/Online/Multiplayer/MatchUserRequest.cs b/osu.Game/Online/Multiplayer/MatchUserRequest.cs index fdcbf75682..bacc1a7632 100644 --- a/osu.Game/Online/Multiplayer/MatchUserRequest.cs +++ b/osu.Game/Online/Multiplayer/MatchUserRequest.cs @@ -21,6 +21,8 @@ namespace osu.Game.Online.Multiplayer [Union(2, typeof(StopCountdownRequest))] [Union(3, typeof(MatchmakingAvatarActionRequest))] [Union(4, typeof(RankedPlayCardHandReplayRequest))] + [Union(5, typeof(SetLockStateRequest))] + [Union(6, typeof(RollRequest))] public abstract class MatchUserRequest { } diff --git a/osu.Game/Online/Multiplayer/RollEvent.cs b/osu.Game/Online/Multiplayer/RollEvent.cs new file mode 100644 index 0000000000..8588bc6adf --- /dev/null +++ b/osu.Game/Online/Multiplayer/RollEvent.cs @@ -0,0 +1,36 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + /// + /// Communicates the result of a . + /// + [Serializable] + [MessagePackObject] + public class RollEvent : MatchServerEvent + { + /// + /// The ID of the user who initiated the roll. + /// + [Key(0)] + public int UserID { get; set; } + + /// + /// Determines the maximum possible result of the roll. + /// Bigger than 1. + /// + [Key(1)] + public uint Max { get; set; } + + /// + /// The actual result of the roll. + /// In the range [1, ], inclusive both ends. + /// + [Key(2)] + public uint Result { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/RollRequest.cs b/osu.Game/Online/Multiplayer/RollRequest.cs new file mode 100644 index 0000000000..3f6be23e1e --- /dev/null +++ b/osu.Game/Online/Multiplayer/RollRequest.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + /// + /// Requests a random roll of a number from 1 to inclusive. + /// + [Serializable] + [MessagePackObject] + public class RollRequest : MatchUserRequest + { + /// + /// Determines the maximum possible result of the roll. + /// Must be bigger than 1. + /// Defaults to 100 if not provided. + /// + [Key(0)] + public uint? Max { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/SetLockStateRequest.cs b/osu.Game/Online/Multiplayer/SetLockStateRequest.cs new file mode 100644 index 0000000000..8f1451fdab --- /dev/null +++ b/osu.Game/Online/Multiplayer/SetLockStateRequest.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + [MessagePackObject] + public class SetLockStateRequest : MatchUserRequest + { + /// + /// + /// If , s will not be able to change teams by themselves in the room, + /// only s will be able to change teams for the s. + /// + /// + /// If , any user can change their team in the room. + /// + /// + // TODO: mention slots as well when slots are reimplemented + [Key(0)] + public bool Locked { get; set; } + } +} diff --git a/osu.Game/Online/SignalRWorkaroundTypes.cs b/osu.Game/Online/SignalRWorkaroundTypes.cs index 70c6fcf2b7..06e8451205 100644 --- a/osu.Game/Online/SignalRWorkaroundTypes.cs +++ b/osu.Game/Online/SignalRWorkaroundTypes.cs @@ -27,8 +27,11 @@ namespace osu.Game.Online (typeof(ChangeTeamRequest), typeof(MatchUserRequest)), (typeof(StartMatchCountdownRequest), typeof(MatchUserRequest)), (typeof(StopCountdownRequest), typeof(MatchUserRequest)), + (typeof(SetLockStateRequest), typeof(MatchUserRequest)), + (typeof(RollRequest), typeof(MatchUserRequest)), (typeof(CountdownStartedEvent), typeof(MatchServerEvent)), (typeof(CountdownStoppedEvent), typeof(MatchServerEvent)), + (typeof(RollEvent), typeof(MatchServerEvent)), (typeof(TeamVersusRoomState), typeof(MatchRoomState)), (typeof(TeamVersusUserState), typeof(MatchUserState)), (typeof(MatchStartCountdown), typeof(MultiplayerCountdown)), From 39912e044a05480d7587b6c8d9dfd78f3f99dd0f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 14 Mar 2026 23:55:12 +0900 Subject: [PATCH 19/21] Fix weird variable naming --- osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs | 2 +- osu.Game/Overlays/Dashboard/Friends/FriendsList.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs b/osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs index 4088233013..66e90e51eb 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs @@ -178,7 +178,7 @@ namespace osu.Game.Overlays.Dashboard.Friends FriendsList newList = new FriendsList(userListToolbar.DisplayStyle.Value, apiFriends.Select(f => f.TargetUser!).ToArray()) { - OnlineStream = { BindTarget = streamControl.Current }, + StatusFilter = { BindTarget = streamControl.Current }, SortCriteria = { BindTarget = userListToolbar.SortCriteria }, SearchText = { BindTarget = searchTextBox.Current } }; diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsList.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsList.cs index c7689dff8f..8d95222ee2 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsList.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsList.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { public partial class FriendsList : CompositeDrawable { - public readonly IBindable OnlineStream = new Bindable(); + public readonly IBindable StatusFilter = new Bindable(); public readonly IBindable SortCriteria = new Bindable(); public readonly IBindable SearchText = new Bindable(); @@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Dashboard.Friends friendPresences.BindCollectionChanged(onFriendPresencesChanged); SearchText.BindValueChanged(onSearchTextChanged, true); - OnlineStream.BindValueChanged(onFriendsStreamChanged, true); + StatusFilter.BindValueChanged(onStatusFilterChanged, true); } private void onFriendPresencesChanged(object? sender, NotifyDictionaryChangedEventArgs e) @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Dashboard.Friends searchContainer.SearchTerm = search.NewValue; } - private void onFriendsStreamChanged(ValueChangedEvent stream) + private void onStatusFilterChanged(ValueChangedEvent status) { updatePanelVisibilities(); } @@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { foreach (var panel in searchContainer) { - switch (OnlineStream.Value) + switch (StatusFilter.Value) { case OnlineStatus.All: panel.CanBeShown.Value = true; From 73644d87bc747be4cfc00fe5f2f1a44910ba3e3d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 16 Mar 2026 14:15:29 +0900 Subject: [PATCH 20/21] Attempt to fix mod output including build output --- .github/workflows/update-web-mod-definitions.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-web-mod-definitions.yml b/.github/workflows/update-web-mod-definitions.yml index b19f03ad7d..160872a9a1 100644 --- a/.github/workflows/update-web-mod-definitions.yml +++ b/.github/workflows/update-web-mod-definitions.yml @@ -38,8 +38,12 @@ jobs: run: ./UseLocalOsu.sh working-directory: ./osu-tools + - name: Build tools + run: dotnet build PerformanceCalculator --nologo --verbosity quiet + working-directory: ./osu-tools + - name: Regenerate mod definitions - run: dotnet run --project PerformanceCalculator -- mods > ../osu-web/database/mods.json + run: dotnet run --project PerformanceCalculator --no-build -- mods > ../osu-web/database/mods.json working-directory: ./osu-tools - name: Create pull request with changes From a99626130490ed60bb4bf1677bdf67d9374d5811 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 17 Mar 2026 03:58:02 +0900 Subject: [PATCH 21/21] Update lots of packages (#36996) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's been a while. Notes: - `SharpCompress` usages changed a bit. Manually adjusted these, mostly just renames or adjusted parameters. - nUnit 3 -> 4 migrated using https://gist.github.com/peppy/07994386d793a117350cb5f24b156585. there's a mode in this script to update to the newer `Assert.That` syntax but it requires fixes and couldn't really be bothered. - DeepEqual nuked as the only usage was on a disabled test. The reason it's disabled has been merged upstream, but it's failing for other (realm) reasons which I don't think is worthwhile to investigate for now. - This bumps Moq. I think the author is back in a sensible headspace and the new version has the stupid shit removed, so probably okay? Nice to be on a level playing field with packages for once in a long time. - Automapper is silly, but we've discussed this elsewhere. - `TestRealmKeyBindingStore` failures are a wildcard, but fixed by using a more standardised testing method. Dunno why, don't care. --------- Co-authored-by: Bartłomiej Dach --- ...u.Game.Rulesets.EmptyFreeform.Tests.csproj | 4 +- .../osu.Game.Rulesets.Pippidon.Tests.csproj | 4 +- ....Game.Rulesets.EmptyScrolling.Tests.csproj | 4 +- .../osu.Game.Rulesets.Pippidon.Tests.csproj | 4 +- osu.Desktop/osu.Desktop.csproj | 4 +- .../osu.Game.Benchmarks.csproj | 6 +- .../CatchSkinColourDecodingTest.cs | 7 +- .../osu.Game.Rulesets.Catch.Tests.csproj | 6 +- .../Editor/TestSceneObjectPlacement.cs | 2 +- .../ManiaFilterCriteriaTest.cs | 85 ++-- .../ManiaSpecialColumnTest.cs | 3 +- .../Mods/TestSceneManiaModHoldOff.cs | 3 +- .../TestSceneAutoGeneration.cs | 95 ++-- .../osu.Game.Rulesets.Mania.Tests.csproj | 6 +- .../Editor/TestSliderScaling.cs | 5 +- osu.Game.Rulesets.Osu.Tests/StackingTest.cs | 5 +- .../osu.Game.Rulesets.Osu.Tests.csproj | 8 +- .../Editor/TestSceneTaikoEditorSaving.cs | 2 +- .../osu.Game.Rulesets.Taiko.Tests.csproj | 6 +- .../Formats/LegacyBeatmapDecoderTest.cs | 349 +++++++-------- .../Formats/LegacyBeatmapEncoderTest.cs | 5 +- .../Formats/LegacyScoreDecoderTest.cs | 21 +- .../Formats/LegacyStoryboardDecoderTest.cs | 153 +++---- .../Beatmaps/Formats/OsuJsonDecoderTest.cs | 135 +++--- .../Beatmaps/Formats/ParsingTest.cs | 7 +- .../Beatmaps/IO/BeatmapImportHelper.cs | 16 +- .../Beatmaps/IO/LineBufferedReaderTest.cs | 67 +-- .../Beatmaps/IO/OszArchiveReaderTest.cs | 27 +- .../TestSceneBeatmapDifficultyCache.cs | 3 +- osu.Game.Tests/Beatmaps/WorkingBeatmapTest.cs | 7 +- osu.Game.Tests/Chat/MessageFormatterTests.cs | 417 +++++++++--------- .../Database/BeatmapImporterTests.cs | 225 +++++----- .../Database/BeatmapImporterUpdateTests.cs | 4 +- osu.Game.Tests/Database/FileStoreTests.cs | 27 +- osu.Game.Tests/Database/GeneralUsageTests.cs | 3 +- .../Database/LegacyBeatmapImporterTest.cs | 5 +- osu.Game.Tests/Database/RealmLiveTests.cs | 41 +- osu.Game.Tests/Database/RulesetStoreTests.cs | 19 +- .../Database/TestRealmKeyBindingStore.cs | 143 +++--- .../Editing/Checks/CheckAudioInVideoTest.cs | 5 +- .../Checks/CheckDelayedHitsoundsTest.cs | 5 +- .../Checks/CheckHitsoundsFormatTest.cs | 6 +- .../Editing/Checks/CheckSongFormatTest.cs | 2 +- .../Checks/CheckTooShortAudioFilesTest.cs | 11 +- .../Checks/CheckVideoResolutionTest.cs | 2 +- .../Editing/Checks/CheckZeroByteFilesTest.cs | 5 +- osu.Game.Tests/ImportTest.cs | 3 +- .../BeatmapMetadataRomanisationTest.cs | 7 +- osu.Game.Tests/Mods/ModUtilsTest.cs | 41 +- .../NonVisual/BarLineGeneratorTest.cs | 7 +- .../NonVisual/BeatmapSetInfoEqualityTest.cs | 37 +- .../NonVisual/ClosestBeatDivisorTest.cs | 3 +- ...DifficultyAdjustmentModCombinationsTest.cs | 3 +- .../NonVisual/Filtering/FilterMatchingTest.cs | 43 +- .../Filtering/FilterQueryParserTest.cs | 219 ++++----- .../NonVisual/FirstAvailableHitWindowsTest.cs | 9 +- osu.Game.Tests/NonVisual/FormatUtilsTest.cs | 5 +- .../NonVisual/FramedReplayInputHandlerTest.cs | 13 +- .../NonVisual/LimitedCapacityQueueTest.cs | 33 +- osu.Game.Tests/NonVisual/PeriodTrackerTest.cs | 19 +- .../NonVisual/Ranking/UnstableRateTest.cs | 19 +- osu.Game.Tests/NonVisual/ReverseQueueTest.cs | 41 +- .../NonVisual/SessionStaticsTest.cs | 21 +- .../Skinning/LegacySkinTextureFallbackTest.cs | 21 +- .../NonVisual/TimeDisplayExtensionTest.cs | 5 +- .../Online/Chat/MessageNotifierTest.cs | 27 +- .../Matchmaking/MatchmakingRoomStateTest.cs | 89 ++-- .../Online/TestAPIModJsonSerialization.cs | 5 +- ...TestMultiplayerMessagePackSerialization.cs | 7 +- osu.Game.Tests/Resources/TestResources.cs | 6 +- .../Rulesets/Scoring/ScoreProcessorTest.cs | 13 +- osu.Game.Tests/Scores/IO/ImportScoreTest.cs | 121 ++--- .../ScrollAlgorithms/ConstantScrollTest.cs | 29 +- .../ScrollAlgorithms/OverlappingScrollTest.cs | 35 +- .../ScrollAlgorithms/SequentialScrollTest.cs | 25 +- osu.Game.Tests/Skins/IO/ImportSkinTest.cs | 55 +-- osu.Game.Tests/Skins/LegacySkinDecoderTest.cs | 21 +- .../Skins/TestSceneSkinResources.cs | 2 +- osu.Game.Tests/Utils/NamingUtilsTest.cs | 45 +- .../Editing/TestSceneComposerSelection.cs | 19 +- .../Editing/TestSceneEditorBeatmapCreation.cs | 2 +- .../Visual/Gameplay/TestSceneSpectator.cs | 2 +- .../Visual/Online/TestSceneDrawableChannel.cs | 3 +- osu.Game.Tests/osu.Game.Tests.csproj | 11 +- .../NonVisual/IPCLocationTest.cs | 5 +- .../NonVisual/TournamentHostTest.cs | 3 +- .../osu.Game.Tournament.Tests.csproj | 6 +- .../LocalCachedBeatmapMetadataSource.cs | 2 +- osu.Game/Database/LegacyArchiveExporter.cs | 2 +- osu.Game/Database/RealmObjectExtensions.cs | 4 +- osu.Game/IO/Archives/ZipArchiveReader.cs | 13 +- .../Sections/General/QuickActionSettings.cs | 6 +- .../Edit/Checks/Components/IssueTemplate.cs | 3 +- osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs | 2 +- osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs | 2 +- .../Edit/LegacyEditorBeatmapPatcher.cs | 15 +- .../Tests/Beatmaps/BeatmapConversionTest.cs | 3 +- .../Tests/Beatmaps/LegacyModConversionTest.cs | 8 +- osu.Game/Utils/ZipUtils.cs | 9 +- osu.Game/osu.Game.csproj | 32 +- 100 files changed, 1606 insertions(+), 1544 deletions(-) diff --git a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj index 86f73a37d4..4fa8b94099 100644 --- a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj +++ b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj index 51c0233942..bb95c675fc 100644 --- a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj +++ b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj index ed4e8631ea..fc170b2c24 100644 --- a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj +++ b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj index 51c0233942..bb95c675fc 100644 --- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj +++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index b0c5c953d4..bd0f4448fc 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -24,8 +24,8 @@ - - + + diff --git a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj index 8a353eb2f5..104ee50fe1 100644 --- a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj +++ b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs index 74b02bab9b..3a0dea3e8c 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.IO.Stores; using osu.Game.Rulesets.Catch.Skinning; using osu.Game.Rulesets.Catch.Skinning.Legacy; @@ -21,9 +22,9 @@ namespace osu.Game.Rulesets.Catch.Tests var skinSource = new SkinProvidingContainer(rawSkin); var skin = new CatchLegacySkinTransformer(skinSource); - Assert.AreEqual(new Color4(232, 185, 35, 255), skin.GetConfig(CatchSkinColour.HyperDash)?.Value); - Assert.AreEqual(new Color4(232, 74, 35, 255), skin.GetConfig(CatchSkinColour.HyperDashAfterImage)?.Value); - Assert.AreEqual(new Color4(0, 255, 255, 255), skin.GetConfig(CatchSkinColour.HyperDashFruit)?.Value); + ClassicAssert.AreEqual(new Color4(232, 185, 35, 255), skin.GetConfig(CatchSkinColour.HyperDash)?.Value); + ClassicAssert.AreEqual(new Color4(232, 74, 35, 255), skin.GetConfig(CatchSkinColour.HyperDashAfterImage)?.Value); + ClassicAssert.AreEqual(new Color4(0, 255, 255, 255), skin.GetConfig(CatchSkinColour.HyperDashFruit)?.Value); } private class TestLegacySkin : LegacySkin diff --git a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj index fc1b13f3ad..132bc4bed1 100644 --- a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj +++ b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj @@ -1,9 +1,9 @@  - - - + + + WinExe diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneObjectPlacement.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneObjectPlacement.cs index 13a116b209..94b832e43a 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneObjectPlacement.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneObjectPlacement.cs @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor AddStep("change seek setting to true", () => config.SetValue(OsuSetting.EditorAutoSeekOnPlacement, true)); placeObject(); AddUntilStep("wait for seek to complete", () => !EditorClock.IsSeeking); - AddAssert("seeked forward to object", () => EditorClock.CurrentTime, () => Is.GreaterThan(initialTime)); + AddAssert("seeked forward to object", () => EditorClock.CurrentTime, () => Is.GreaterThan(initialTime!)); } [Test] diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaFilterCriteriaTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaFilterCriteriaTest.cs index ad3cf4e05f..49fb8ecb2c 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaFilterCriteriaTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaFilterCriteriaTest.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Mods; using osu.Game.Screens.Select; @@ -18,19 +19,19 @@ namespace osu.Game.Rulesets.Mania.Tests var criteria = new ManiaFilterCriteria(); criteria.TryParseCustomKeywordCriteria("keys", Operator.Equal, "1"); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 1 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 2 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 3 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new RulesetInfo { OnlineID = 0 }, new BeatmapDifficulty { CircleSize = 4 }), new FilterCriteria { @@ -44,19 +45,19 @@ namespace osu.Game.Rulesets.Mania.Tests var criteria = new ManiaFilterCriteria(); criteria.TryParseCustomKeywordCriteria("keys", Operator.Equal, "1,3,5,7"); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 1 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 2 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 3 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new RulesetInfo { OnlineID = 0 }, new BeatmapDifficulty { CircleSize = 4 }), new FilterCriteria { @@ -70,19 +71,19 @@ namespace osu.Game.Rulesets.Mania.Tests var criteria = new ManiaFilterCriteria(); criteria.TryParseCustomKeywordCriteria("keys", Operator.NotEqual, "1"); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 1 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 2 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 3 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new RulesetInfo { OnlineID = 0 }, new BeatmapDifficulty { CircleSize = 4 }), new FilterCriteria { @@ -96,19 +97,19 @@ namespace osu.Game.Rulesets.Mania.Tests var criteria = new ManiaFilterCriteria(); criteria.TryParseCustomKeywordCriteria("keys", Operator.NotEqual, "1,3,5,7"); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 1 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 2 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 3 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new RulesetInfo { OnlineID = 0 }, new BeatmapDifficulty { CircleSize = 4 }), new FilterCriteria { @@ -122,23 +123,23 @@ namespace osu.Game.Rulesets.Mania.Tests var criteria = new ManiaFilterCriteria(); criteria.TryParseCustomKeywordCriteria("keys", Operator.GreaterOrEqual, "4"); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 1 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 2 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 4 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 5 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new RulesetInfo { OnlineID = 0 }, new BeatmapDifficulty { CircleSize = 3 }), new FilterCriteria { @@ -153,23 +154,23 @@ namespace osu.Game.Rulesets.Mania.Tests criteria.TryParseCustomKeywordCriteria("keys", Operator.Greater, "4"); criteria.TryParseCustomKeywordCriteria("keys", Operator.NotEqual, "7"); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 3 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 4 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 5 }), new FilterCriteria())); - Assert.False(criteria.Matches( + ClassicAssert.False(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 7 }), new FilterCriteria())); - Assert.True(criteria.Matches( + ClassicAssert.True(criteria.Matches( new BeatmapInfo(new ManiaRuleset().RulesetInfo, new BeatmapDifficulty { CircleSize = 9 }), new FilterCriteria())); } @@ -179,9 +180,9 @@ namespace osu.Game.Rulesets.Mania.Tests { var criteria = new ManiaFilterCriteria(); - Assert.False(criteria.TryParseCustomKeywordCriteria("keys", Operator.Equal, "some text")); - Assert.False(criteria.TryParseCustomKeywordCriteria("keys", Operator.NotEqual, "4,some text")); - Assert.False(criteria.TryParseCustomKeywordCriteria("keys", Operator.GreaterOrEqual, "4,5,6")); + ClassicAssert.False(criteria.TryParseCustomKeywordCriteria("keys", Operator.Equal, "some text")); + ClassicAssert.False(criteria.TryParseCustomKeywordCriteria("keys", Operator.NotEqual, "4,some text")); + ClassicAssert.False(criteria.TryParseCustomKeywordCriteria("keys", Operator.GreaterOrEqual, "4,5,6")); } [TestCase] @@ -199,7 +200,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 0, EndTimeObjectCount = 0 }; - Assert.True(criteria.Matches(beatmapInfo1, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo1, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.Equal, "0"); BeatmapInfo beatmapInfo2 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -207,7 +208,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 0 }; - Assert.True(criteria.Matches(beatmapInfo2, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo2, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.Equal, "100"); BeatmapInfo beatmapInfo3 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -215,7 +216,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 100 }; - Assert.True(criteria.Matches(beatmapInfo3, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo3, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.Equal, "1"); BeatmapInfo beatmapInfo4 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -223,7 +224,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 1 }; - Assert.True(criteria.Matches(beatmapInfo4, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo4, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.Equal, "0.1"); BeatmapInfo beatmapInfo5 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -231,7 +232,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 1000, EndTimeObjectCount = 1 }; - Assert.True(criteria.Matches(beatmapInfo5, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo5, filterCriteria)); } [TestCase] @@ -249,7 +250,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 0, EndTimeObjectCount = 0 }; - Assert.True(criteria.Matches(beatmapInfo1, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo1, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.GreaterOrEqual, "0"); BeatmapInfo beatmapInfo2 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -257,7 +258,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 0 }; - Assert.True(criteria.Matches(beatmapInfo2, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo2, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.GreaterOrEqual, "100"); BeatmapInfo beatmapInfo3 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -265,7 +266,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 100 }; - Assert.True(criteria.Matches(beatmapInfo3, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo3, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.GreaterOrEqual, "1"); BeatmapInfo beatmapInfo4 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -273,7 +274,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 1 }; - Assert.True(criteria.Matches(beatmapInfo4, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo4, filterCriteria)); criteria.TryParseCustomKeywordCriteria("lns", Operator.GreaterOrEqual, "0.1"); BeatmapInfo beatmapInfo5 = new BeatmapInfo(new ManiaRuleset().RulesetInfo) @@ -281,7 +282,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 1000, EndTimeObjectCount = 1 }; - Assert.True(criteria.Matches(beatmapInfo5, filterCriteria)); + ClassicAssert.True(criteria.Matches(beatmapInfo5, filterCriteria)); } [TestCase] @@ -299,7 +300,7 @@ namespace osu.Game.Rulesets.Mania.Tests TotalObjectCount = 100, EndTimeObjectCount = 50 }; - Assert.False(criteria.Matches(beatmapInfo, filterCriteria)); + ClassicAssert.False(criteria.Matches(beatmapInfo, filterCriteria)); } [TestCase] @@ -307,8 +308,8 @@ namespace osu.Game.Rulesets.Mania.Tests { var criteria = new ManiaFilterCriteria(); - Assert.False(criteria.TryParseCustomKeywordCriteria("lns", Operator.Equal, "some text")); - Assert.False(criteria.TryParseCustomKeywordCriteria("lns", Operator.GreaterOrEqual, "1some text")); + ClassicAssert.False(criteria.TryParseCustomKeywordCriteria("lns", Operator.Equal, "some text")); + ClassicAssert.False(criteria.TryParseCustomKeywordCriteria("lns", Operator.GreaterOrEqual, "1some text")); } } } diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaSpecialColumnTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaSpecialColumnTest.cs index ff1f9e6894..726d0af945 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaSpecialColumnTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaSpecialColumnTest.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using osu.Game.Rulesets.Mania.Beatmaps; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace osu.Game.Rulesets.Mania.Tests { @@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.Tests { var definition = new StageDefinition(columns); var results = getResults(definition); - Assert.AreEqual(special, results); + ClassicAssert.AreEqual(special, results); } private IEnumerable getResults(StageDefinition definition) diff --git a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModHoldOff.cs b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModHoldOff.cs index f5117b61af..a06d389f95 100644 --- a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModHoldOff.cs +++ b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModHoldOff.cs @@ -3,6 +3,7 @@ using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Mods; using osu.Game.Tests.Visual; @@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods public void TestMapHasNoHoldNotes() { var testBeatmap = createModdedBeatmap(); - Assert.False(testBeatmap.HitObjects.OfType().Any()); + ClassicAssert.False(testBeatmap.HitObjects.OfType().Any()); } [Test] diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs index 9a3167b97f..fd4eb9855c 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs @@ -3,6 +3,7 @@ using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Testing; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; @@ -33,11 +34,11 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); - Assert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); + ClassicAssert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); } [Test] @@ -54,11 +55,11 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); - Assert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); + ClassicAssert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); } [Test] @@ -74,11 +75,11 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); - Assert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been released"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); + ClassicAssert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been released"); } [Test] @@ -96,13 +97,13 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); - Assert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time"); + ClassicAssert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been released"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been released"); } [Test] @@ -119,15 +120,15 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 4, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time"); - Assert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect first note release time"); - Assert.AreEqual(2000, generated.Frames[frame_offset + 2].Time, "Incorrect second note hit time"); - Assert.AreEqual(2000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 3].Time, "Incorrect second note release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 3], ManiaAction.Key2), "Key2 has not been released"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 4, "Incorrect number of frames"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time"); + ClassicAssert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect first note release time"); + ClassicAssert.AreEqual(2000, generated.Frames[frame_offset + 2].Time, "Incorrect second note hit time"); + ClassicAssert.AreEqual(2000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 3].Time, "Incorrect second note release time"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 3], ManiaAction.Key2), "Key2 has not been released"); } [Test] @@ -146,16 +147,16 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 4, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time"); - Assert.AreEqual(3000, generated.Frames[frame_offset + 2].Time, "Incorrect first note release time"); - Assert.AreEqual(2000, generated.Frames[frame_offset + 1].Time, "Incorrect second note hit time"); - Assert.AreEqual(4000, generated.Frames[frame_offset + 3].Time, "Incorrect second note release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key1), "Key1 has not been released"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has been released"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 3], ManiaAction.Key2), "Key2 has not been released"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 4, "Incorrect number of frames"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time"); + ClassicAssert.AreEqual(3000, generated.Frames[frame_offset + 2].Time, "Incorrect first note release time"); + ClassicAssert.AreEqual(2000, generated.Frames[frame_offset + 1].Time, "Incorrect second note hit time"); + ClassicAssert.AreEqual(4000, generated.Frames[frame_offset + 3].Time, "Incorrect second note release time"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key1), "Key1 has not been released"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has been released"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 3], ManiaAction.Key2), "Key2 has not been released"); } [Test] @@ -173,14 +174,14 @@ namespace osu.Game.Rulesets.Mania.Tests var generated = new ManiaAutoGenerator(beatmap).Generate(); - Assert.AreEqual(generated.Frames.Count, frame_offset + 3, "Incorrect number of frames"); - Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time"); - Assert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect second note press time + first note release time"); - Assert.AreEqual(3000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 2].Time, "Incorrect second note release time"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); - Assert.IsTrue(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key2), "Key2 has not been pressed"); - Assert.IsFalse(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has not been released"); + ClassicAssert.AreEqual(generated.Frames.Count, frame_offset + 3, "Incorrect number of frames"); + ClassicAssert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time"); + ClassicAssert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect second note press time + first note release time"); + ClassicAssert.AreEqual(3000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 2].Time, "Incorrect second note release time"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released"); + ClassicAssert.True(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key2), "Key2 has not been pressed"); + ClassicAssert.False(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has not been released"); } private bool checkContains(ReplayFrame frame, params ManiaAction[] actions) => actions.All(action => ((ManiaReplayFrame)frame).Actions.Contains(action)); diff --git a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj index edb01b044e..8d5c4d9da6 100644 --- a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj +++ b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj @@ -1,9 +1,9 @@  - - - + + + WinExe diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSliderScaling.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSliderScaling.cs index 52a170b84e..4a19350619 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSliderScaling.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSliderScaling.cs @@ -6,6 +6,7 @@ using System; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Graphics.Primitives; using osu.Framework.Testing; using osu.Framework.Utils; @@ -102,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor for (int i = 0; i < 100; i++) { - Assert.True(Precision.AlmostEquals(sliderPathPerfect.PositionAt(i / 100.0f), sliderPathBezier.PositionAt(i / 100.0f))); + ClassicAssert.True(Precision.AlmostEquals(sliderPathPerfect.PositionAt(i / 100.0f), sliderPathBezier.PositionAt(i / 100.0f))); } } @@ -174,7 +175,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor double theta = circularArcProperties.ThetaStart + (circularArcProperties.Direction * progress * circularArcProperties.ThetaRange); Vector2 vector = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * circularArcProperties.Radius; - Assert.True(Precision.AlmostEquals(circularArcProperties.Centre + vector, path.PositionAt(progress), 0.01f), + ClassicAssert.True(Precision.AlmostEquals(circularArcProperties.Centre + vector, path.PositionAt(progress), 0.01f), "A perfect circle with points " + string.Join(", ", path.ControlPoints.Select(x => x.Position)) + " and radius" + circularArcProperties.Radius + "from SliderPath does not almost equal a theoretical perfect circle with " + subpoints + " subpoints" + ": " + (circularArcProperties.Centre + vector) + " - " + path.PositionAt(progress) + " = " + (circularArcProperties.Centre + vector - path.PositionAt(progress)) diff --git a/osu.Game.Rulesets.Osu.Tests/StackingTest.cs b/osu.Game.Rulesets.Osu.Tests/StackingTest.cs index f9b4dcad52..6daf5c59c6 100644 --- a/osu.Game.Rulesets.Osu.Tests/StackingTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/StackingTest.cs @@ -5,6 +5,7 @@ using System; using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.IO; using osu.Game.Rulesets.Mods; @@ -57,7 +58,7 @@ SliderTickRate:0.5 // The last hitobject triggers the stacking for (int i = 0; i < objects.Count - 1; i++) - Assert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight); + ClassicAssert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight); } } @@ -104,7 +105,7 @@ SliderTickRate:1 // The last hitobject triggers the stacking for (int i = 0; i < objects.Count - 1; i++) - Assert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight); + ClassicAssert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight); } } } diff --git a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj index 6510568555..15dca424f3 100644 --- a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj +++ b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj @@ -1,10 +1,10 @@  - - - - + + + + WinExe diff --git a/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorSaving.cs b/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorSaving.cs index fb05502158..ca99ae296c 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorSaving.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorSaving.cs @@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor string export = LocalStorage.GetFiles("exports").First(); using (var stream = LocalStorage.GetStream(export)) - using (var zip = ZipArchive.Open(stream)) + using (var zip = ZipArchive.OpenArchive(stream)) { using (var osuStream = zip.Entries.First().OpenEntryStream()) using (var reader = new StreamReader(osuStream)) diff --git a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj index e498989a79..facb0d0cfb 100644 --- a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj +++ b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj @@ -1,9 +1,9 @@  - - - + + + WinExe diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs index 916e1e757a..51875a25d9 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; @@ -42,9 +43,9 @@ namespace osu.Game.Tests.Beatmaps.Formats var decoder = Decoder.GetDecoder(stream); var working = new TestWorkingBeatmap(decoder.Decode(stream)); - Assert.AreEqual(6, working.Beatmap.BeatmapVersion); + ClassicAssert.AreEqual(6, working.Beatmap.BeatmapVersion); Assert.That(working.Beatmap.BeatmapInfo.Ruleset.Name, Is.Not.EqualTo("null placeholder ruleset")); - Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty()).BeatmapVersion); + ClassicAssert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty()).BeatmapVersion); } } @@ -59,10 +60,10 @@ namespace osu.Game.Tests.Beatmaps.Formats ((LegacyBeatmapDecoder)decoder).ApplyOffsets = applyOffsets; var working = new TestWorkingBeatmap(decoder.Decode(stream)); - Assert.AreEqual(4, working.Beatmap.BeatmapVersion); - Assert.AreEqual(4, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty()).BeatmapVersion); + ClassicAssert.AreEqual(4, working.Beatmap.BeatmapVersion); + ClassicAssert.AreEqual(4, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty()).BeatmapVersion); - Assert.AreEqual(-1, working.BeatmapInfo.Metadata.PreviewTime); + ClassicAssert.AreEqual(-1, working.BeatmapInfo.Metadata.PreviewTime); } } @@ -78,17 +79,17 @@ namespace osu.Game.Tests.Beatmaps.Formats var beatmapInfo = beatmap.BeatmapInfo; var metadata = beatmap.Metadata; - Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", metadata.AudioFile); - Assert.AreEqual(0, beatmap.AudioLeadIn); - Assert.AreEqual(164471, metadata.PreviewTime); - Assert.AreEqual(0.7f, beatmap.StackLeniency); - Assert.IsTrue(beatmapInfo.Ruleset.OnlineID == 0); - Assert.IsFalse(beatmap.LetterboxInBreaks); - Assert.IsFalse(beatmap.SpecialStyle); - Assert.IsFalse(beatmap.WidescreenStoryboard); - Assert.IsFalse(beatmap.SamplesMatchPlaybackRate); - Assert.AreEqual(CountdownType.None, beatmap.Countdown); - Assert.AreEqual(0, beatmap.CountdownOffset); + ClassicAssert.AreEqual("03. Renatus - Soleily 192kbps.mp3", metadata.AudioFile); + ClassicAssert.AreEqual(0, beatmap.AudioLeadIn); + ClassicAssert.AreEqual(164471, metadata.PreviewTime); + ClassicAssert.AreEqual(0.7f, beatmap.StackLeniency); + ClassicAssert.True(beatmapInfo.Ruleset.OnlineID == 0); + ClassicAssert.False(beatmap.LetterboxInBreaks); + ClassicAssert.False(beatmap.SpecialStyle); + ClassicAssert.False(beatmap.WidescreenStoryboard); + ClassicAssert.False(beatmap.SamplesMatchPlaybackRate); + ClassicAssert.AreEqual(CountdownType.None, beatmap.Countdown); + ClassicAssert.AreEqual(0, beatmap.CountdownOffset); } } @@ -108,13 +109,13 @@ namespace osu.Game.Tests.Beatmaps.Formats 95901, 106450, 116999, 119637, 130186, 140735, 151285, 161834, 164471, 175020, 185570, 196119, 206669, 209306 }; - Assert.AreEqual(expectedBookmarks.Length, beatmap.Bookmarks.Length); + ClassicAssert.AreEqual(expectedBookmarks.Length, beatmap.Bookmarks.Length); for (int i = 0; i < expectedBookmarks.Length; i++) - Assert.AreEqual(expectedBookmarks[i], beatmap.Bookmarks[i]); - Assert.AreEqual(1.8, beatmap.DistanceSpacing); - Assert.AreEqual(4, beatmap.BeatmapInfo.BeatDivisor); - Assert.AreEqual(4, beatmap.GridSize); - Assert.AreEqual(2, beatmap.TimelineZoom); + ClassicAssert.AreEqual(expectedBookmarks[i], beatmap.Bookmarks[i]); + ClassicAssert.AreEqual(1.8, beatmap.DistanceSpacing); + ClassicAssert.AreEqual(4, beatmap.BeatmapInfo.BeatDivisor); + ClassicAssert.AreEqual(4, beatmap.GridSize); + ClassicAssert.AreEqual(2, beatmap.TimelineZoom); } } @@ -130,16 +131,16 @@ namespace osu.Game.Tests.Beatmaps.Formats var beatmapInfo = beatmap.BeatmapInfo; var metadata = beatmap.Metadata; - Assert.AreEqual("Renatus", metadata.Title); - Assert.AreEqual("Renatus", metadata.TitleUnicode); - Assert.AreEqual("Soleily", metadata.Artist); - Assert.AreEqual("Soleily", metadata.ArtistUnicode); - Assert.AreEqual("Gamu", metadata.Author.Username); - Assert.AreEqual("Insane", beatmapInfo.DifficultyName); - Assert.AreEqual(string.Empty, metadata.Source); - Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags); - Assert.AreEqual(557821, beatmapInfo.OnlineID); - Assert.AreEqual(241526, beatmapInfo.BeatmapSet?.OnlineID); + ClassicAssert.AreEqual("Renatus", metadata.Title); + ClassicAssert.AreEqual("Renatus", metadata.TitleUnicode); + ClassicAssert.AreEqual("Soleily", metadata.Artist); + ClassicAssert.AreEqual("Soleily", metadata.ArtistUnicode); + ClassicAssert.AreEqual("Gamu", metadata.Author.Username); + ClassicAssert.AreEqual("Insane", beatmapInfo.DifficultyName); + ClassicAssert.AreEqual(string.Empty, metadata.Source); + ClassicAssert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags); + ClassicAssert.AreEqual(557821, beatmapInfo.OnlineID); + ClassicAssert.AreEqual(241526, beatmapInfo.BeatmapSet?.OnlineID); } } @@ -153,12 +154,12 @@ namespace osu.Game.Tests.Beatmaps.Formats { var difficulty = decoder.Decode(stream).Difficulty; - Assert.AreEqual(6.5f, difficulty.DrainRate); - Assert.AreEqual(4, difficulty.CircleSize); - Assert.AreEqual(8, difficulty.OverallDifficulty); - Assert.AreEqual(9, difficulty.ApproachRate); - Assert.AreEqual(1.8, difficulty.SliderMultiplier); - Assert.AreEqual(2, difficulty.SliderTickRate); + ClassicAssert.AreEqual(6.5f, difficulty.DrainRate); + ClassicAssert.AreEqual(4, difficulty.CircleSize); + ClassicAssert.AreEqual(8, difficulty.OverallDifficulty); + ClassicAssert.AreEqual(9, difficulty.ApproachRate); + ClassicAssert.AreEqual(1.8, difficulty.SliderMultiplier); + ClassicAssert.AreEqual(2, difficulty.SliderTickRate); } } @@ -174,10 +175,10 @@ namespace osu.Game.Tests.Beatmaps.Formats var metadata = beatmap.Metadata; var breakPoint = beatmap.Breaks[0]; - Assert.AreEqual("machinetop_background.jpg", metadata.BackgroundFile); - Assert.AreEqual(122474, breakPoint.StartTime); - Assert.AreEqual(140135, breakPoint.EndTime); - Assert.IsTrue(breakPoint.HasEffect); + ClassicAssert.AreEqual("machinetop_background.jpg", metadata.BackgroundFile); + ClassicAssert.AreEqual(122474, breakPoint.StartTime); + ClassicAssert.AreEqual(140135, breakPoint.EndTime); + ClassicAssert.True(breakPoint.HasEffect); } } @@ -192,7 +193,7 @@ namespace osu.Game.Tests.Beatmaps.Formats var beatmap = decoder.Decode(stream); var metadata = beatmap.Metadata; - Assert.AreEqual("BG.jpg", metadata.BackgroundFile); + ClassicAssert.AreEqual("BG.jpg", metadata.BackgroundFile); } } @@ -207,7 +208,7 @@ namespace osu.Game.Tests.Beatmaps.Formats var beatmap = decoder.Decode(stream); var metadata = beatmap.Metadata; - Assert.AreEqual("BG.jpg", metadata.BackgroundFile); + ClassicAssert.AreEqual("BG.jpg", metadata.BackgroundFile); } } @@ -222,7 +223,7 @@ namespace osu.Game.Tests.Beatmaps.Formats var beatmap = decoder.Decode(stream); var metadata = beatmap.Metadata; - Assert.AreEqual("BG.jpg", metadata.BackgroundFile); + ClassicAssert.AreEqual("BG.jpg", metadata.BackgroundFile); } } @@ -237,67 +238,67 @@ namespace osu.Game.Tests.Beatmaps.Formats var beatmap = decoder.Decode(stream); var controlPoints = (LegacyControlPointInfo)beatmap.ControlPointInfo; - Assert.AreEqual(4, controlPoints.TimingPoints.Count); - Assert.AreEqual(5, controlPoints.DifficultyPoints.Count); - Assert.AreEqual(34, controlPoints.SamplePoints.Count); - Assert.AreEqual(8, controlPoints.EffectPoints.Count); + ClassicAssert.AreEqual(4, controlPoints.TimingPoints.Count); + ClassicAssert.AreEqual(5, controlPoints.DifficultyPoints.Count); + ClassicAssert.AreEqual(34, controlPoints.SamplePoints.Count); + ClassicAssert.AreEqual(8, controlPoints.EffectPoints.Count); var timingPoint = controlPoints.TimingPointAt(0); - Assert.AreEqual(956, timingPoint.Time); - Assert.AreEqual(329.67032967033, timingPoint.BeatLength); - Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); - Assert.IsFalse(timingPoint.OmitFirstBarLine); + ClassicAssert.AreEqual(956, timingPoint.Time); + ClassicAssert.AreEqual(329.67032967033, timingPoint.BeatLength); + ClassicAssert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); + ClassicAssert.False(timingPoint.OmitFirstBarLine); timingPoint = controlPoints.TimingPointAt(48428); - Assert.AreEqual(956, timingPoint.Time); - Assert.AreEqual(329.67032967033d, timingPoint.BeatLength); - Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); - Assert.IsFalse(timingPoint.OmitFirstBarLine); + ClassicAssert.AreEqual(956, timingPoint.Time); + ClassicAssert.AreEqual(329.67032967033d, timingPoint.BeatLength); + ClassicAssert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); + ClassicAssert.False(timingPoint.OmitFirstBarLine); timingPoint = controlPoints.TimingPointAt(119637); - Assert.AreEqual(119637, timingPoint.Time); - Assert.AreEqual(659.340659340659, timingPoint.BeatLength); - Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); - Assert.IsFalse(timingPoint.OmitFirstBarLine); + ClassicAssert.AreEqual(119637, timingPoint.Time); + ClassicAssert.AreEqual(659.340659340659, timingPoint.BeatLength); + ClassicAssert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature); + ClassicAssert.False(timingPoint.OmitFirstBarLine); var difficultyPoint = controlPoints.DifficultyPointAt(0); - Assert.AreEqual(0, difficultyPoint.Time); - Assert.AreEqual(1.0, difficultyPoint.SliderVelocity); + ClassicAssert.AreEqual(0, difficultyPoint.Time); + ClassicAssert.AreEqual(1.0, difficultyPoint.SliderVelocity); difficultyPoint = controlPoints.DifficultyPointAt(48428); - Assert.AreEqual(0, difficultyPoint.Time); - Assert.AreEqual(1.0, difficultyPoint.SliderVelocity); + ClassicAssert.AreEqual(0, difficultyPoint.Time); + ClassicAssert.AreEqual(1.0, difficultyPoint.SliderVelocity); difficultyPoint = controlPoints.DifficultyPointAt(116999); - Assert.AreEqual(116999, difficultyPoint.Time); - Assert.AreEqual(0.75, difficultyPoint.SliderVelocity, 0.1); + ClassicAssert.AreEqual(116999, difficultyPoint.Time); + ClassicAssert.AreEqual(0.75, difficultyPoint.SliderVelocity, 0.1); var soundPoint = controlPoints.SamplePointAt(0); - Assert.AreEqual(956, soundPoint.Time); - Assert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank); - Assert.AreEqual(60, soundPoint.SampleVolume); + ClassicAssert.AreEqual(956, soundPoint.Time); + ClassicAssert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank); + ClassicAssert.AreEqual(60, soundPoint.SampleVolume); soundPoint = controlPoints.SamplePointAt(53373); - Assert.AreEqual(53373, soundPoint.Time); - Assert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank); - Assert.AreEqual(60, soundPoint.SampleVolume); + ClassicAssert.AreEqual(53373, soundPoint.Time); + ClassicAssert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank); + ClassicAssert.AreEqual(60, soundPoint.SampleVolume); soundPoint = controlPoints.SamplePointAt(119637); - Assert.AreEqual(119637, soundPoint.Time); - Assert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank); - Assert.AreEqual(80, soundPoint.SampleVolume); + ClassicAssert.AreEqual(119637, soundPoint.Time); + ClassicAssert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank); + ClassicAssert.AreEqual(80, soundPoint.SampleVolume); var effectPoint = controlPoints.EffectPointAt(0); - Assert.AreEqual(0, effectPoint.Time); - Assert.IsFalse(effectPoint.KiaiMode); + ClassicAssert.AreEqual(0, effectPoint.Time); + ClassicAssert.False(effectPoint.KiaiMode); effectPoint = controlPoints.EffectPointAt(53703); - Assert.AreEqual(53703, effectPoint.Time); - Assert.IsTrue(effectPoint.KiaiMode); + ClassicAssert.AreEqual(53703, effectPoint.Time); + ClassicAssert.True(effectPoint.KiaiMode); effectPoint = controlPoints.EffectPointAt(116637); - Assert.AreEqual(95901, effectPoint.Time); - Assert.IsFalse(effectPoint.KiaiMode); + ClassicAssert.AreEqual(95901, effectPoint.Time); + ClassicAssert.False(effectPoint.KiaiMode); } } @@ -397,9 +398,9 @@ namespace osu.Game.Tests.Beatmaps.Formats new Color4(255, 177, 140, 255), new Color4(100, 100, 100, 255), // alpha is specified as 100, but should be ignored. }; - Assert.AreEqual(expectedColors.Length, comboColors.Count); + ClassicAssert.AreEqual(expectedColors.Length, comboColors.Count); for (int i = 0; i < expectedColors.Length; i++) - Assert.AreEqual(expectedColors[i], comboColors[i]); + ClassicAssert.AreEqual(expectedColors[i], comboColors[i]); } } @@ -426,9 +427,9 @@ namespace osu.Game.Tests.Beatmaps.Formats new Color4(100, 100, 100, 255), new Color4(142, 199, 255, 255), }; - Assert.AreEqual(expectedColors.Length, comboColors.Count); + ClassicAssert.AreEqual(expectedColors.Length, comboColors.Count); for (int i = 0; i < expectedColors.Length; i++) - Assert.AreEqual(expectedColors[i], comboColors[i]); + ClassicAssert.AreEqual(expectedColors[i], comboColors[i]); } } @@ -464,12 +465,12 @@ namespace osu.Game.Tests.Beatmaps.Formats new OsuBeatmapProcessor(converted).PreProcess(); new OsuBeatmapProcessor(converted).PostProcess(); - Assert.AreEqual(1, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets); - Assert.AreEqual(2, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets); - Assert.AreEqual(3, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets); - Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets); - Assert.AreEqual(8, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets); - Assert.AreEqual(9, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(1, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(2, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(3, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(8, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(9, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets); } } @@ -487,12 +488,12 @@ namespace osu.Game.Tests.Beatmaps.Formats new CatchBeatmapProcessor(converted).PreProcess(); new CatchBeatmapProcessor(converted).PostProcess(); - Assert.AreEqual(1, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets); - Assert.AreEqual(2, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets); - Assert.AreEqual(3, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets); - Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets); - Assert.AreEqual(8, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets); - Assert.AreEqual(9, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(1, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(2, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(3, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(8, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets); + ClassicAssert.AreEqual(9, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets); } } @@ -508,8 +509,8 @@ namespace osu.Game.Tests.Beatmaps.Formats var positionData = hitObjects[0] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.AreEqual(new Vector2(256, 256), positionData!.Position); + ClassicAssert.NotNull(positionData); + ClassicAssert.AreEqual(new Vector2(256, 256), positionData!.Position); } } @@ -525,8 +526,8 @@ namespace osu.Game.Tests.Beatmaps.Formats var positionData = hitObjects[0] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.AreEqual(new Vector2(256.99853f, 256.001f), positionData!.Position); + ClassicAssert.NotNull(positionData); + ClassicAssert.AreEqual(new Vector2(256.99853f, 256.001f), positionData!.Position); } } @@ -543,18 +544,18 @@ namespace osu.Game.Tests.Beatmaps.Formats var curveData = hitObjects[0] as IHasPathWithRepeats; var positionData = hitObjects[0] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.IsNotNull(curveData); - Assert.AreEqual(new Vector2(192, 168), positionData!.Position); - Assert.AreEqual(956, hitObjects[0].StartTime); - Assert.IsTrue(hitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL)); + ClassicAssert.NotNull(positionData); + ClassicAssert.NotNull(curveData); + ClassicAssert.AreEqual(new Vector2(192, 168), positionData!.Position); + ClassicAssert.AreEqual(956, hitObjects[0].StartTime); + ClassicAssert.True(hitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL)); positionData = hitObjects[1] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.AreEqual(new Vector2(304, 56), positionData!.Position); - Assert.AreEqual(1285, hitObjects[1].StartTime); - Assert.IsTrue(hitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)); + ClassicAssert.NotNull(positionData); + ClassicAssert.AreEqual(new Vector2(304, 56), positionData!.Position); + ClassicAssert.AreEqual(1285, hitObjects[1].StartTime); + ClassicAssert.True(hitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)); } } @@ -585,22 +586,22 @@ namespace osu.Game.Tests.Beatmaps.Formats { var hitObjects = decoder.Decode(stream).HitObjects; - Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); - Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); - Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); - Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); // The fourth object is a slider. // `Samples` of a slider are presumed to control the volume of sounds that last the entire duration of the slider // (such as ticks, slider slide sounds, etc.) // Thus, the point of query of control points used for `Samples` is just beyond the start time of the slider. - Assert.AreEqual("Gameplay/soft-hitnormal11", getTestableSampleInfo(hitObjects[4]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/soft-hitnormal11", getTestableSampleInfo(hitObjects[4]).LookupNames.First()); // That said, the `NodeSamples` of the slider are responsible for the sounds of the slider's head / tail / repeats / large ticks etc. // Therefore, they should be read at the time instant correspondent to the given node. // This means that the tail should use bank 8 rather than 11. - Assert.AreEqual("Gameplay/soft-hitnormal11", ((ConvertSlider)hitObjects[4]).NodeSamples[0][0].LookupNames.First()); - Assert.AreEqual("Gameplay/soft-hitnormal8", ((ConvertSlider)hitObjects[4]).NodeSamples[1][0].LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/soft-hitnormal11", ((ConvertSlider)hitObjects[4]).NodeSamples[0][0].LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/soft-hitnormal8", ((ConvertSlider)hitObjects[4]).NodeSamples[1][0].LookupNames.First()); } static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0]; @@ -616,9 +617,9 @@ namespace osu.Game.Tests.Beatmaps.Formats { var hitObjects = decoder.Decode(stream).HitObjects; - Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); - Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); - Assert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); } static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0]; @@ -634,11 +635,11 @@ namespace osu.Game.Tests.Beatmaps.Formats { var hitObjects = decoder.Decode(stream).HitObjects; - Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); - Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); - Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); - Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); - Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume); + ClassicAssert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); + ClassicAssert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); + ClassicAssert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); + ClassicAssert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); + ClassicAssert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume); } static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0]; @@ -656,35 +657,35 @@ namespace osu.Game.Tests.Beatmaps.Formats var slider1 = (ConvertSlider)hitObjects[0]; - Assert.AreEqual(1, slider1.NodeSamples[0].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[0][0].Name); - Assert.AreEqual(1, slider1.NodeSamples[1].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[1][0].Name); - Assert.AreEqual(1, slider1.NodeSamples[2].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[2][0].Name); + ClassicAssert.AreEqual(1, slider1.NodeSamples[0].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[0][0].Name); + ClassicAssert.AreEqual(1, slider1.NodeSamples[1].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[1][0].Name); + ClassicAssert.AreEqual(1, slider1.NodeSamples[2].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[2][0].Name); var slider2 = (ConvertSlider)hitObjects[1]; - Assert.AreEqual(2, slider2.NodeSamples[0].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[0][0].Name); - Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[0][1].Name); - Assert.AreEqual(2, slider2.NodeSamples[1].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[1][0].Name); - Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[1][1].Name); - Assert.AreEqual(2, slider2.NodeSamples[2].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[2][0].Name); - Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[2][1].Name); + ClassicAssert.AreEqual(2, slider2.NodeSamples[0].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[0][0].Name); + ClassicAssert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[0][1].Name); + ClassicAssert.AreEqual(2, slider2.NodeSamples[1].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[1][0].Name); + ClassicAssert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[1][1].Name); + ClassicAssert.AreEqual(2, slider2.NodeSamples[2].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[2][0].Name); + ClassicAssert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[2][1].Name); var slider3 = (ConvertSlider)hitObjects[2]; - Assert.AreEqual(2, slider3.NodeSamples[0].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[0][0].Name); - Assert.AreEqual(HitSampleInfo.HIT_WHISTLE, slider3.NodeSamples[0][1].Name); - Assert.AreEqual(1, slider3.NodeSamples[1].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[1][0].Name); - Assert.AreEqual(2, slider3.NodeSamples[2].Count); - Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[2][0].Name); - Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider3.NodeSamples[2][1].Name); + ClassicAssert.AreEqual(2, slider3.NodeSamples[0].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[0][0].Name); + ClassicAssert.AreEqual(HitSampleInfo.HIT_WHISTLE, slider3.NodeSamples[0][1].Name); + ClassicAssert.AreEqual(1, slider3.NodeSamples[1].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[1][0].Name); + ClassicAssert.AreEqual(2, slider3.NodeSamples[2].Count); + ClassicAssert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[2][0].Name); + ClassicAssert.AreEqual(HitSampleInfo.HIT_CLAP, slider3.NodeSamples[2][1].Name); } } @@ -698,7 +699,7 @@ namespace osu.Game.Tests.Beatmaps.Formats { var hitObjects = decoder.Decode(stream).HitObjects; - Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank); + ClassicAssert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank); } } @@ -739,10 +740,10 @@ namespace osu.Game.Tests.Beatmaps.Formats static void assertObjectHasBanks(HitObject hitObject, string normalBank, string? additionsBank = null) { - Assert.AreEqual(normalBank, hitObject.Samples[0].Bank); + ClassicAssert.AreEqual(normalBank, hitObject.Samples[0].Bank); if (additionsBank != null) - Assert.AreEqual(additionsBank, hitObject.Samples[1].Bank); + ClassicAssert.AreEqual(additionsBank, hitObject.Samples[1].Bank); } } @@ -756,11 +757,11 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); - Assert.IsNotNull(beatmap); - Assert.AreEqual("Beatmap with corrupted header", beatmap.Metadata.Title); - Assert.AreEqual("Evil Hacker", beatmap.Metadata.Author.Username); + ClassicAssert.NotNull(beatmap); + ClassicAssert.AreEqual("Beatmap with corrupted header", beatmap.Metadata.Title); + ClassicAssert.AreEqual("Evil Hacker", beatmap.Metadata.Author.Username); } } @@ -774,11 +775,11 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); - Assert.IsNotNull(beatmap); - Assert.AreEqual("Beatmap with no header", beatmap.Metadata.Title); - Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.Author.Username); + ClassicAssert.NotNull(beatmap); + ClassicAssert.AreEqual("Beatmap with no header", beatmap.Metadata.Title); + ClassicAssert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.Author.Username); } } @@ -792,11 +793,11 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); - Assert.IsNotNull(beatmap); - Assert.AreEqual("Empty lines at start", beatmap.Metadata.Title); - Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username); + ClassicAssert.NotNull(beatmap); + ClassicAssert.AreEqual("Empty lines at start", beatmap.Metadata.Title); + ClassicAssert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username); } } @@ -810,11 +811,11 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); - Assert.IsNotNull(beatmap); - Assert.AreEqual("The dog ate the file header", beatmap.Metadata.Title); - Assert.AreEqual("Why does this keep happening", beatmap.Metadata.Author.Username); + ClassicAssert.NotNull(beatmap); + ClassicAssert.AreEqual("The dog ate the file header", beatmap.Metadata.Title); + ClassicAssert.AreEqual("Why does this keep happening", beatmap.Metadata.Author.Username); } } @@ -828,11 +829,11 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); - Assert.IsNotNull(beatmap); - Assert.AreEqual("No empty line delimiting header from contents", beatmap.Metadata.Title); - Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username); + ClassicAssert.NotNull(beatmap); + ClassicAssert.AreEqual("No empty line delimiting header from contents", beatmap.Metadata.Title); + ClassicAssert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username); } } @@ -855,7 +856,7 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); } Assert.DoesNotThrow(LegacyDifficultyCalculatorBeatmapDecoder.Register); @@ -864,7 +865,7 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = new LineBufferedReader(resStream)) { Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder(stream)); - Assert.IsInstanceOf(decoder); + ClassicAssert.IsInstanceOf(decoder); } } diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs index 35ce733895..c18bb9e902 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using System.Text; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; @@ -100,7 +101,7 @@ namespace osu.Game.Tests.Beatmaps.Formats { // emulate non-legacy control points by cloning the non-legacy portion. // the assertion is that the encoder can recreate this losslessly from hitobject data. - Assert.IsInstanceOf(controlPointInfo); + ClassicAssert.IsInstanceOf(controlPointInfo); var newControlPoints = new ControlPointInfo(); @@ -129,7 +130,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.That(actual.beatmap.HitObjects.Serialize(), Is.EqualTo(expected.beatmap.HitObjects.Serialize())); // Check skin. - Assert.IsTrue(areComboColoursEqual(expected.skin.Configuration, actual.skin.Configuration)); + ClassicAssert.True(areComboColoursEqual(expected.skin.Configuration, actual.skin.Configuration)); } [Test] diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs index 2815c9cd8f..1292d25d6a 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs @@ -9,6 +9,7 @@ using System.Globalization; using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Extensions; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; @@ -58,18 +59,18 @@ namespace osu.Game.Tests.Beatmaps.Formats { var score = decoder.Parse(resourceStream); - Assert.AreEqual(3, score.ScoreInfo.Ruleset.OnlineID); + ClassicAssert.AreEqual(3, score.ScoreInfo.Ruleset.OnlineID); - Assert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.Great]); - Assert.AreEqual(1, score.ScoreInfo.Statistics[HitResult.Good]); + ClassicAssert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.Great]); + ClassicAssert.AreEqual(1, score.ScoreInfo.Statistics[HitResult.Good]); - Assert.AreEqual(829_931, score.ScoreInfo.LegacyTotalScore); - Assert.AreEqual(3, score.ScoreInfo.MaxCombo); + ClassicAssert.AreEqual(829_931, score.ScoreInfo.LegacyTotalScore); + ClassicAssert.AreEqual(3, score.ScoreInfo.MaxCombo); Assert.That(score.ScoreInfo.APIMods.Select(m => m.Acronym), Is.EquivalentTo(new[] { "CL", "9K", "DS" })); Assert.That((2 * 300d + 1 * 200) / (3 * 305d), Is.EqualTo(score.ScoreInfo.Accuracy).Within(0.0001)); - Assert.AreEqual(ScoreRank.B, score.ScoreInfo.Rank); + ClassicAssert.AreEqual(ScoreRank.B, score.ScoreInfo.Rank); Assert.That(score.Replay.Frames, Has.One.Matches(frame => frame.Time == 414 && frame.Actions.SequenceEqual(new[] { ManiaAction.Key1, ManiaAction.Key18 }))); @@ -85,10 +86,10 @@ namespace osu.Game.Tests.Beatmaps.Formats { var score = decoder.Parse(resourceStream); - Assert.AreEqual(1, score.ScoreInfo.Ruleset.OnlineID); - Assert.AreEqual(4, score.ScoreInfo.Statistics[HitResult.Great]); - Assert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.LargeBonus]); - Assert.AreEqual(4, score.ScoreInfo.MaxCombo); + ClassicAssert.AreEqual(1, score.ScoreInfo.Ruleset.OnlineID); + ClassicAssert.AreEqual(4, score.ScoreInfo.Statistics[HitResult.Great]); + ClassicAssert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.LargeBonus]); + ClassicAssert.AreEqual(4, score.ScoreInfo.MaxCombo); Assert.That(score.Replay.Frames, Is.Not.Empty); } diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs index b10cce6a52..9b76bd53ec 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs @@ -3,6 +3,7 @@ using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osuTK; using osu.Framework.Graphics; using osu.Game.Beatmaps.Formats; @@ -25,73 +26,73 @@ namespace osu.Game.Tests.Beatmaps.Formats { var storyboard = decoder.Decode(stream); - Assert.IsTrue(storyboard.HasDrawable); - Assert.AreEqual(6, storyboard.Layers.Count()); + ClassicAssert.True(storyboard.HasDrawable); + ClassicAssert.AreEqual(6, storyboard.Layers.Count()); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.IsNotNull(background); - Assert.AreEqual(16, background.Elements.Count); - Assert.IsTrue(background.VisibleWhenFailing); - Assert.IsTrue(background.VisibleWhenPassing); - Assert.AreEqual("Background", background.Name); + ClassicAssert.NotNull(background); + ClassicAssert.AreEqual(16, background.Elements.Count); + ClassicAssert.True(background.VisibleWhenFailing); + ClassicAssert.True(background.VisibleWhenPassing); + ClassicAssert.AreEqual("Background", background.Name); StoryboardLayer fail = storyboard.Layers.Single(l => l.Depth == 2); - Assert.IsNotNull(fail); - Assert.AreEqual(0, fail.Elements.Count); - Assert.IsTrue(fail.VisibleWhenFailing); - Assert.IsFalse(fail.VisibleWhenPassing); - Assert.AreEqual("Fail", fail.Name); + ClassicAssert.NotNull(fail); + ClassicAssert.AreEqual(0, fail.Elements.Count); + ClassicAssert.True(fail.VisibleWhenFailing); + ClassicAssert.False(fail.VisibleWhenPassing); + ClassicAssert.AreEqual("Fail", fail.Name); StoryboardLayer pass = storyboard.Layers.Single(l => l.Depth == 1); - Assert.IsNotNull(pass); - Assert.AreEqual(0, pass.Elements.Count); - Assert.IsFalse(pass.VisibleWhenFailing); - Assert.IsTrue(pass.VisibleWhenPassing); - Assert.AreEqual("Pass", pass.Name); + ClassicAssert.NotNull(pass); + ClassicAssert.AreEqual(0, pass.Elements.Count); + ClassicAssert.False(pass.VisibleWhenFailing); + ClassicAssert.True(pass.VisibleWhenPassing); + ClassicAssert.AreEqual("Pass", pass.Name); StoryboardLayer foreground = storyboard.Layers.Single(l => l.Depth == 0); - Assert.IsNotNull(foreground); - Assert.AreEqual(151, foreground.Elements.Count); - Assert.IsTrue(foreground.VisibleWhenFailing); - Assert.IsTrue(foreground.VisibleWhenPassing); - Assert.AreEqual("Foreground", foreground.Name); + ClassicAssert.NotNull(foreground); + ClassicAssert.AreEqual(151, foreground.Elements.Count); + ClassicAssert.True(foreground.VisibleWhenFailing); + ClassicAssert.True(foreground.VisibleWhenPassing); + ClassicAssert.AreEqual("Foreground", foreground.Name); StoryboardLayer overlay = storyboard.Layers.Single(l => l.Depth == int.MinValue); - Assert.IsNotNull(overlay); - Assert.IsEmpty(overlay.Elements); - Assert.IsTrue(overlay.VisibleWhenFailing); - Assert.IsTrue(overlay.VisibleWhenPassing); - Assert.AreEqual("Overlay", overlay.Name); + ClassicAssert.NotNull(overlay); + ClassicAssert.IsEmpty(overlay.Elements); + ClassicAssert.True(overlay.VisibleWhenFailing); + ClassicAssert.True(overlay.VisibleWhenPassing); + ClassicAssert.AreEqual("Overlay", overlay.Name); int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite)); int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation)); int sampleCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSampleInfo)); - Assert.AreEqual(15, spriteCount); - Assert.AreEqual(1, animationCount); - Assert.AreEqual(0, sampleCount); - Assert.AreEqual(background.Elements.Count, spriteCount + animationCount + sampleCount); + ClassicAssert.AreEqual(15, spriteCount); + ClassicAssert.AreEqual(1, animationCount); + ClassicAssert.AreEqual(0, sampleCount); + ClassicAssert.AreEqual(background.Elements.Count, spriteCount + animationCount + sampleCount); var sprite = background.Elements.ElementAt(0) as StoryboardSprite; - Assert.NotNull(sprite); - Assert.IsTrue(sprite!.HasCommands); - Assert.AreEqual(new Vector2(320, 240), sprite.InitialPosition); - Assert.IsTrue(sprite.IsDrawable); - Assert.AreEqual(Anchor.Centre, sprite.Origin); - Assert.AreEqual("SB/lyric/ja-21.png", sprite.Path); + ClassicAssert.NotNull(sprite); + ClassicAssert.True(sprite!.HasCommands); + ClassicAssert.AreEqual(new Vector2(320, 240), sprite.InitialPosition); + ClassicAssert.True(sprite.IsDrawable); + ClassicAssert.AreEqual(Anchor.Centre, sprite.Origin); + ClassicAssert.AreEqual("SB/lyric/ja-21.png", sprite.Path); var animation = background.Elements.OfType().First(); - Assert.NotNull(animation); - Assert.AreEqual(141175, animation.EndTime); - Assert.AreEqual(10, animation.FrameCount); - Assert.AreEqual(30, animation.FrameDelay); - Assert.IsTrue(animation.HasCommands); - Assert.AreEqual(new Vector2(320, 240), animation.InitialPosition); - Assert.IsTrue(animation.IsDrawable); - Assert.AreEqual(AnimationLoopType.LoopForever, animation.LoopType); - Assert.AreEqual(Anchor.Centre, animation.Origin); - Assert.AreEqual("SB/red jitter/red_0000.jpg", animation.Path); - Assert.AreEqual(78993, animation.StartTime); + ClassicAssert.NotNull(animation); + ClassicAssert.AreEqual(141175, animation.EndTime); + ClassicAssert.AreEqual(10, animation.FrameCount); + ClassicAssert.AreEqual(30, animation.FrameDelay); + ClassicAssert.True(animation.HasCommands); + ClassicAssert.AreEqual(new Vector2(320, 240), animation.InitialPosition); + ClassicAssert.True(animation.IsDrawable); + ClassicAssert.AreEqual(AnimationLoopType.LoopForever, animation.LoopType); + ClassicAssert.AreEqual(Anchor.Centre, animation.Origin); + ClassicAssert.AreEqual("SB/red jitter/red_0000.jpg", animation.Path); + ClassicAssert.AreEqual(78993, animation.StartTime); } } @@ -106,13 +107,13 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.AreEqual(1, background.Elements.Count); + ClassicAssert.AreEqual(1, background.Elements.Count); - Assert.AreEqual(2000, background.Elements[0].StartTime); - Assert.AreEqual(2000, (background.Elements[0] as StoryboardAnimation)?.EarliestTransformTime); + ClassicAssert.AreEqual(2000, background.Elements[0].StartTime); + ClassicAssert.AreEqual(2000, (background.Elements[0] as StoryboardAnimation)?.EarliestTransformTime); - Assert.AreEqual(3000, (background.Elements[0] as StoryboardAnimation)?.GetEndTime()); - Assert.AreEqual(12000, (background.Elements[0] as StoryboardAnimation)?.EndTimeForDisplay); + ClassicAssert.AreEqual(3000, (background.Elements[0] as StoryboardAnimation)?.GetEndTime()); + ClassicAssert.AreEqual(12000, (background.Elements[0] as StoryboardAnimation)?.EndTimeForDisplay); } } @@ -127,11 +128,11 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.AreEqual(1, background.Elements.Count); + ClassicAssert.AreEqual(1, background.Elements.Count); - Assert.AreEqual(2000, background.Elements[0].StartTime); + ClassicAssert.AreEqual(2000, background.Elements[0].StartTime); // This property should be used in DrawableStoryboardAnimation as a starting point for animation playback. - Assert.AreEqual(1000, (background.Elements[0] as StoryboardAnimation)?.EarliestTransformTime); + ClassicAssert.AreEqual(1000, (background.Elements[0] as StoryboardAnimation)?.EarliestTransformTime); } } @@ -146,10 +147,10 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.AreEqual(2, background.Elements.Count); + ClassicAssert.AreEqual(2, background.Elements.Count); - Assert.AreEqual(1500, background.Elements[0].StartTime); - Assert.AreEqual(1500, background.Elements[1].StartTime); + ClassicAssert.AreEqual(1500, background.Elements[0].StartTime); + ClassicAssert.AreEqual(1500, background.Elements[1].StartTime); } } @@ -164,12 +165,12 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.AreEqual(2, background.Elements.Count); + ClassicAssert.AreEqual(2, background.Elements.Count); - Assert.AreEqual(1500, background.Elements[0].StartTime); - Assert.AreEqual(1000, background.Elements[1].StartTime); + ClassicAssert.AreEqual(1500, background.Elements[0].StartTime); + ClassicAssert.AreEqual(1000, background.Elements[1].StartTime); - Assert.AreEqual(1000, storyboard.EarliestEventTime); + ClassicAssert.AreEqual(1000, storyboard.EarliestEventTime); } } @@ -184,12 +185,12 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.AreEqual(2, background.Elements.Count); + ClassicAssert.AreEqual(2, background.Elements.Count); - Assert.AreEqual(1000, background.Elements[0].StartTime); - Assert.AreEqual(1000, background.Elements[1].StartTime); + ClassicAssert.AreEqual(1000, background.Elements[0].StartTime); + ClassicAssert.AreEqual(1000, background.Elements[1].StartTime); - Assert.AreEqual(1000, storyboard.EarliestEventTime); + ClassicAssert.AreEqual(1000, storyboard.EarliestEventTime); } } @@ -204,7 +205,7 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3); - Assert.AreEqual(3456, ((StoryboardSprite)background.Elements.Single()).InitialPosition.X); + ClassicAssert.AreEqual(3456, ((StoryboardSprite)background.Elements.Single()).InitialPosition.X); } } @@ -221,7 +222,7 @@ namespace osu.Game.Tests.Beatmaps.Formats StoryboardLayer video = storyboard.Layers.Single(l => l.Name == "Video"); Assert.That(video.Elements.Count, Is.EqualTo(1)); - Assert.AreEqual("Video.avi", ((StoryboardVideo)video.Elements[0]).Path); + ClassicAssert.AreEqual("Video.avi", ((StoryboardVideo)video.Elements[0]).Path); } } @@ -238,7 +239,7 @@ namespace osu.Game.Tests.Beatmaps.Formats StoryboardLayer video = storyboard.Layers.Single(l => l.Name == "Video"); Assert.That(video.Elements.Count, Is.EqualTo(1)); - Assert.AreEqual("Video.AVI", ((StoryboardVideo)video.Elements[0]).Path); + ClassicAssert.AreEqual("Video.AVI", ((StoryboardVideo)video.Elements[0]).Path); } } @@ -268,12 +269,12 @@ namespace osu.Game.Tests.Beatmaps.Formats var storyboard = decoder.Decode(stream); StoryboardLayer foreground = storyboard.Layers.Single(l => l.Depth == 0); - Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[0]).LoopType); - Assert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[1]).LoopType); - Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[2]).LoopType); - Assert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[3]).LoopType); - Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[4]).LoopType); - Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[5]).LoopType); + ClassicAssert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[0]).LoopType); + ClassicAssert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[1]).LoopType); + ClassicAssert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[2]).LoopType); + ClassicAssert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[3]).LoopType); + ClassicAssert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[4]).LoopType); + ClassicAssert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[5]).LoopType); } } diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs index c20cf7befd..c0c330dba5 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs @@ -5,8 +5,8 @@ using System.IO; using System.Linq; -using DeepEqual.Syntax; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; @@ -15,7 +15,6 @@ using osu.Game.IO.Serialization; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Beatmaps; -using osu.Game.Rulesets.Scoring; using osu.Game.Tests.Resources; using osuTK; @@ -33,17 +32,17 @@ namespace osu.Game.Tests.Beatmaps.Formats { var beatmap = decodeAsJson(normal); var meta = beatmap.BeatmapInfo.Metadata; - Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID); - Assert.AreEqual("Soleily", meta.Artist); - Assert.AreEqual("Soleily", meta.ArtistUnicode); - Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); - Assert.AreEqual("Gamu", meta.Author.Username); - Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); - Assert.AreEqual(164471, meta.PreviewTime); - Assert.AreEqual(string.Empty, meta.Source); - Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags); - Assert.AreEqual("Renatus", meta.Title); - Assert.AreEqual("Renatus", meta.TitleUnicode); + ClassicAssert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID); + ClassicAssert.AreEqual("Soleily", meta.Artist); + ClassicAssert.AreEqual("Soleily", meta.ArtistUnicode); + ClassicAssert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); + ClassicAssert.AreEqual("Gamu", meta.Author.Username); + ClassicAssert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); + ClassicAssert.AreEqual(164471, meta.PreviewTime); + ClassicAssert.AreEqual(string.Empty, meta.Source); + ClassicAssert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags); + ClassicAssert.AreEqual("Renatus", meta.Title); + ClassicAssert.AreEqual("Renatus", meta.TitleUnicode); } [Test] @@ -51,14 +50,14 @@ namespace osu.Game.Tests.Beatmaps.Formats { var beatmap = decodeAsJson(normal); var beatmapInfo = beatmap.BeatmapInfo; - Assert.AreEqual(0, beatmap.AudioLeadIn); - Assert.AreEqual(0.7f, beatmap.StackLeniency); - Assert.AreEqual(false, beatmap.SpecialStyle); - Assert.IsTrue(beatmapInfo.Ruleset.OnlineID == 0); - Assert.AreEqual(false, beatmap.LetterboxInBreaks); - Assert.AreEqual(false, beatmap.WidescreenStoryboard); - Assert.AreEqual(CountdownType.None, beatmap.Countdown); - Assert.AreEqual(0, beatmap.CountdownOffset); + ClassicAssert.AreEqual(0, beatmap.AudioLeadIn); + ClassicAssert.AreEqual(0.7f, beatmap.StackLeniency); + ClassicAssert.AreEqual(false, beatmap.SpecialStyle); + ClassicAssert.True(beatmapInfo.Ruleset.OnlineID == 0); + ClassicAssert.AreEqual(false, beatmap.LetterboxInBreaks); + ClassicAssert.AreEqual(false, beatmap.WidescreenStoryboard); + ClassicAssert.AreEqual(CountdownType.None, beatmap.Countdown); + ClassicAssert.AreEqual(0, beatmap.CountdownOffset); } [Test] @@ -73,13 +72,13 @@ namespace osu.Game.Tests.Beatmaps.Formats 95901, 106450, 116999, 119637, 130186, 140735, 151285, 161834, 164471, 175020, 185570, 196119, 206669, 209306 }; - Assert.AreEqual(expectedBookmarks.Length, beatmap.Bookmarks.Length); + ClassicAssert.AreEqual(expectedBookmarks.Length, beatmap.Bookmarks.Length); for (int i = 0; i < expectedBookmarks.Length; i++) - Assert.AreEqual(expectedBookmarks[i], beatmap.Bookmarks[i]); - Assert.AreEqual(1.8, beatmap.DistanceSpacing); - Assert.AreEqual(4, beatmapInfo.BeatDivisor); - Assert.AreEqual(4, beatmap.GridSize); - Assert.AreEqual(2, beatmap.TimelineZoom); + ClassicAssert.AreEqual(expectedBookmarks[i], beatmap.Bookmarks[i]); + ClassicAssert.AreEqual(1.8, beatmap.DistanceSpacing); + ClassicAssert.AreEqual(4, beatmapInfo.BeatDivisor); + ClassicAssert.AreEqual(4, beatmap.GridSize); + ClassicAssert.AreEqual(2, beatmap.TimelineZoom); } [Test] @@ -87,12 +86,12 @@ namespace osu.Game.Tests.Beatmaps.Formats { var beatmap = decodeAsJson(normal); var difficulty = beatmap.Difficulty; - Assert.AreEqual(6.5f, difficulty.DrainRate); - Assert.AreEqual(4, difficulty.CircleSize); - Assert.AreEqual(8, difficulty.OverallDifficulty); - Assert.AreEqual(9, difficulty.ApproachRate); - Assert.AreEqual(1.8, difficulty.SliderMultiplier); - Assert.AreEqual(2, difficulty.SliderTickRate); + ClassicAssert.AreEqual(6.5f, difficulty.DrainRate); + ClassicAssert.AreEqual(4, difficulty.CircleSize); + ClassicAssert.AreEqual(8, difficulty.OverallDifficulty); + ClassicAssert.AreEqual(9, difficulty.ApproachRate); + ClassicAssert.AreEqual(1.8, difficulty.SliderMultiplier); + ClassicAssert.AreEqual(2, difficulty.SliderTickRate); } [Test] @@ -112,19 +111,19 @@ namespace osu.Game.Tests.Beatmaps.Formats var curveData = beatmap.HitObjects[0] as IHasPathWithRepeats; var positionData = beatmap.HitObjects[0] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.IsNotNull(curveData); - Assert.AreEqual(90, curveData.Path.Distance); - Assert.AreEqual(new Vector2(192, 168), positionData.Position); - Assert.AreEqual(956, beatmap.HitObjects[0].StartTime); - Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL)); + Assert.That(positionData, Is.Not.Null); + Assert.That(curveData, Is.Not.Null); + ClassicAssert.AreEqual(90, curveData.Path.Distance); + ClassicAssert.AreEqual(new Vector2(192, 168), positionData.Position); + ClassicAssert.AreEqual(956, beatmap.HitObjects[0].StartTime); + ClassicAssert.True(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL)); positionData = beatmap.HitObjects[1] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.AreEqual(new Vector2(304, 56), positionData.Position); - Assert.AreEqual(1285, beatmap.HitObjects[1].StartTime); - Assert.IsTrue(beatmap.HitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)); + Assert.That(positionData, Is.Not.Null); + ClassicAssert.AreEqual(new Vector2(304, 56), positionData.Position); + ClassicAssert.AreEqual(1285, beatmap.HitObjects[1].StartTime); + ClassicAssert.True(beatmap.HitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)); } [Test] @@ -135,35 +134,35 @@ namespace osu.Game.Tests.Beatmaps.Formats var curveData = beatmap.HitObjects[0] as IHasPathWithRepeats; var positionData = beatmap.HitObjects[0] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.IsNotNull(curveData); - Assert.AreEqual(90, curveData.Path.Distance); - Assert.AreEqual(new Vector2(192, 168), positionData.Position); - Assert.AreEqual(956, beatmap.HitObjects[0].StartTime); - Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL)); + Assert.That(positionData, Is.Not.Null); + Assert.That(curveData, Is.Not.Null); + ClassicAssert.AreEqual(90, curveData.Path.Distance); + ClassicAssert.AreEqual(new Vector2(192, 168), positionData.Position); + ClassicAssert.AreEqual(956, beatmap.HitObjects[0].StartTime); + ClassicAssert.True(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL)); positionData = beatmap.HitObjects[1] as IHasPosition; - Assert.IsNotNull(positionData); - Assert.AreEqual(new Vector2(304, 56), positionData.Position); - Assert.AreEqual(1285, beatmap.HitObjects[1].StartTime); - Assert.IsTrue(beatmap.HitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)); + Assert.That(positionData, Is.Not.Null); + ClassicAssert.AreEqual(new Vector2(304, 56), positionData.Position); + ClassicAssert.AreEqual(1285, beatmap.HitObjects[1].StartTime); + ClassicAssert.True(beatmap.HitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)); } - [TestCase(normal)] - [TestCase(marathon)] - [Ignore("temporarily disabled pending DeepEqual fix (https://github.com/jamesfoster/DeepEqual/pull/35)")] - // Currently fails: - // [TestCase(with_sb)] - public void TestParity(string beatmap) - { - var legacy = decode(beatmap, out Beatmap json); - json.WithDeepEqual(legacy) - .IgnoreProperty(r => r.DeclaringType == typeof(HitWindows) - // Todo: CustomSampleBank shouldn't exist going forward, we need a conversion mechanism - || r.Name == nameof(LegacyDecoder.LegacySampleControlPoint.CustomSampleBank)) - .Assert(); - } + // [TestCase(normal)] + // [TestCase(marathon)] + // [Ignore("temporarily disabled pending DeepEqual fix (https://github.com/jamesfoster/DeepEqual/pull/35)")] + // // Currently fails: + // // [TestCase(with_sb)] + // public void TestParity(string beatmap) + // { + // var legacy = decode(beatmap, out Beatmap json); + // json.WithDeepEqual(legacy) + // .IgnoreProperty(r => r.DeclaringType == typeof(HitWindows) + // // Todo: CustomSampleBank shouldn't exist going forward, we need a conversion mechanism + // || r.Name == nameof(LegacyDecoder.LegacySampleControlPoint.CustomSampleBank)) + // .Assert(); + // } [Test] public void TestGetJsonDecoder() @@ -187,7 +186,7 @@ namespace osu.Game.Tests.Beatmaps.Formats } } - Assert.IsInstanceOf(typeof(JsonBeatmapDecoder), decoder); + ClassicAssert.IsInstanceOf(typeof(JsonBeatmapDecoder), decoder); } /// diff --git a/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs b/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs index 339063633a..8aaa5dd3f3 100644 --- a/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs @@ -6,6 +6,7 @@ using System; using System.Globalization; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps.Formats; namespace osu.Game.Tests.Beatmaps.Formats @@ -33,9 +34,9 @@ namespace osu.Game.Tests.Beatmaps.Formats [TestCase(-10, 10)] public void TestValidRanges(double input, double limit = Parsing.MAX_PARSE_VALUE) { - Assert.AreEqual(Parsing.ParseInt((input).ToString(CultureInfo.InvariantCulture), (int)limit), (int)input); - Assert.AreEqual(Parsing.ParseFloat((input).ToString(CultureInfo.InvariantCulture), (float)limit), (float)input); - Assert.AreEqual(Parsing.ParseDouble((input).ToString(CultureInfo.InvariantCulture), limit), input); + ClassicAssert.AreEqual(Parsing.ParseInt((input).ToString(CultureInfo.InvariantCulture), (int)limit), (int)input); + ClassicAssert.AreEqual(Parsing.ParseFloat((input).ToString(CultureInfo.InvariantCulture), (float)limit), (float)input); + ClassicAssert.AreEqual(Parsing.ParseDouble((input).ToString(CultureInfo.InvariantCulture), limit), input); } [TestCase(double.PositiveInfinity)] diff --git a/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs b/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs index 055832d753..6e3025e99f 100644 --- a/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs +++ b/osu.Game.Tests/Beatmaps/IO/BeatmapImportHelper.cs @@ -8,7 +8,7 @@ using System.Diagnostics; using System.IO; using System.Threading; using System.Threading.Tasks; -using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Database; @@ -62,16 +62,16 @@ namespace osu.Game.Tests.Beatmaps.IO // TODO: add back some extra checks outside of the realm ones? // var set = queryBeatmapSets().First(); // foreach (BeatmapInfo b in set.Beatmaps) - // Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID)); - // Assert.IsTrue(set.Beatmaps.Count > 0); + // ClassicAssert.True(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID)); + // ClassicAssert.True(set.Beatmaps.Count > 0); // var beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap; - // Assert.IsTrue(beatmap?.HitObjects.Any() == true); + // ClassicAssert.True(beatmap?.HitObjects.Any() == true); // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 1))?.Beatmap; - // Assert.IsTrue(beatmap?.HitObjects.Any() == true); + // ClassicAssert.True(beatmap?.HitObjects.Any() == true); // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 2))?.Beatmap; - // Assert.IsTrue(beatmap?.HitObjects.Any() == true); + // ClassicAssert.True(beatmap?.HitObjects.Any() == true); // beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap; - // Assert.IsTrue(beatmap?.HitObjects.Any() == true); + // ClassicAssert.True(beatmap?.HitObjects.Any() == true); } private static void waitForOrAssert(Func result, string failureMessage, int timeout = 60000) @@ -81,7 +81,7 @@ namespace osu.Game.Tests.Beatmaps.IO while (!result()) Thread.Sleep(200); }); - Assert.IsTrue(task.Wait(timeout), failureMessage); + ClassicAssert.True(task.Wait(timeout), failureMessage); } } } diff --git a/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs index 5e37f01c81..50c12a3a24 100644 --- a/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs @@ -5,6 +5,7 @@ using System; using System.IO; using System.Text; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.IO; namespace osu.Game.Tests.Beatmaps.IO @@ -20,10 +21,10 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.AreEqual("line 1", bufferedReader.ReadLine()); - Assert.AreEqual("line 2", bufferedReader.ReadLine()); - Assert.AreEqual("line 3", bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.ReadLine()); + ClassicAssert.AreEqual("line 1", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("line 2", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("line 3", bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.ReadLine()); } } @@ -35,11 +36,11 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.AreEqual("line 1", bufferedReader.ReadLine()); - Assert.AreEqual("peek this", bufferedReader.PeekLine()); - Assert.AreEqual("peek this", bufferedReader.ReadLine()); - Assert.AreEqual("line 3", bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.ReadLine()); + ClassicAssert.AreEqual("line 1", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("peek this", bufferedReader.PeekLine()); + ClassicAssert.AreEqual("peek this", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("line 3", bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.ReadLine()); } } @@ -51,14 +52,14 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.AreEqual("peek this once", bufferedReader.PeekLine()); - Assert.AreEqual("peek this once", bufferedReader.ReadLine()); - Assert.AreEqual("line 2", bufferedReader.ReadLine()); - Assert.AreEqual("peek this a lot", bufferedReader.PeekLine()); - Assert.AreEqual("peek this a lot", bufferedReader.PeekLine()); - Assert.AreEqual("peek this a lot", bufferedReader.PeekLine()); - Assert.AreEqual("peek this a lot", bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.ReadLine()); + ClassicAssert.AreEqual("peek this once", bufferedReader.PeekLine()); + ClassicAssert.AreEqual("peek this once", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("line 2", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("peek this a lot", bufferedReader.PeekLine()); + ClassicAssert.AreEqual("peek this a lot", bufferedReader.PeekLine()); + ClassicAssert.AreEqual("peek this a lot", bufferedReader.PeekLine()); + ClassicAssert.AreEqual("peek this a lot", bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.ReadLine()); } } @@ -70,11 +71,11 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.AreEqual("first line", bufferedReader.ReadLine()); - Assert.AreEqual("second line", bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.PeekLine()); - Assert.IsNull(bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.PeekLine()); + ClassicAssert.AreEqual("first line", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("second line", bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.PeekLine()); + ClassicAssert.Null(bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.PeekLine()); } } @@ -84,10 +85,10 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream()) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.IsNull(bufferedReader.PeekLine()); - Assert.IsNull(bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.ReadLine()); - Assert.IsNull(bufferedReader.PeekLine()); + ClassicAssert.Null(bufferedReader.PeekLine()); + ClassicAssert.Null(bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.ReadLine()); + ClassicAssert.Null(bufferedReader.PeekLine()); } } @@ -99,7 +100,7 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.AreEqual(contents, bufferedReader.ReadToEnd()); + ClassicAssert.AreEqual(contents, bufferedReader.ReadToEnd()); } } @@ -111,14 +112,14 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { - Assert.AreEqual("this line is gone", bufferedReader.ReadLine()); - Assert.AreEqual("this one shouldn't be", bufferedReader.PeekLine()); + ClassicAssert.AreEqual("this line is gone", bufferedReader.ReadLine()); + ClassicAssert.AreEqual("this one shouldn't be", bufferedReader.PeekLine()); string[] endingLines = bufferedReader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); - Assert.AreEqual(3, endingLines.Length); - Assert.AreEqual("this one shouldn't be", endingLines[0]); - Assert.AreEqual("these ones", endingLines[1]); - Assert.AreEqual("definitely not", endingLines[2]); + ClassicAssert.AreEqual(3, endingLines.Length); + ClassicAssert.AreEqual("this one shouldn't be", endingLines[0]); + ClassicAssert.AreEqual("these ones", endingLines[1]); + ClassicAssert.AreEqual("definitely not", endingLines[2]); } } } diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index 810ea5dbd0..fbc0975cfb 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Tests.Resources; using osu.Game.Beatmaps.Formats; @@ -38,7 +39,7 @@ namespace osu.Game.Tests.Beatmaps.IO }; string[] maps = reader.Filenames.ToArray(); foreach (string map in expected) - Assert.Contains(map, maps); + ClassicAssert.Contains(map, maps); } } @@ -56,17 +57,17 @@ namespace osu.Game.Tests.Beatmaps.IO var meta = beatmap.Metadata; - Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID); - Assert.AreEqual("Soleily", meta.Artist); - Assert.AreEqual("Soleily", meta.ArtistUnicode); - Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); - Assert.AreEqual("Deif", meta.Author.Username); - Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); - Assert.AreEqual(164471, meta.PreviewTime); - Assert.AreEqual(string.Empty, meta.Source); - Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags); - Assert.AreEqual("Renatus", meta.Title); - Assert.AreEqual("Renatus", meta.TitleUnicode); + ClassicAssert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID); + ClassicAssert.AreEqual("Soleily", meta.Artist); + ClassicAssert.AreEqual("Soleily", meta.ArtistUnicode); + ClassicAssert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); + ClassicAssert.AreEqual("Deif", meta.Author.Username); + ClassicAssert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); + ClassicAssert.AreEqual(164471, meta.PreviewTime); + ClassicAssert.AreEqual(string.Empty, meta.Source); + ClassicAssert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags); + ClassicAssert.AreEqual("Renatus", meta.Title); + ClassicAssert.AreEqual("Renatus", meta.TitleUnicode); } } @@ -79,7 +80,7 @@ namespace osu.Game.Tests.Beatmaps.IO using (var stream = new StreamReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu"))) { - Assert.AreEqual("osu file format v13", stream.ReadLine()?.Trim()); + ClassicAssert.AreEqual("osu file format v13", stream.ReadLine()?.Trim()); } } } diff --git a/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs b/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs index ca84d00bb3..fc986d0a60 100644 --- a/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs +++ b/osu.Game.Tests/Beatmaps/TestSceneBeatmapDifficultyCache.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions; @@ -225,7 +226,7 @@ namespace osu.Game.Tests.Beatmaps { var actualBracket = StarDifficulty.GetDifficultyRating(starRating); - Assert.AreEqual(expectedBracket, actualBracket); + ClassicAssert.AreEqual(expectedBracket, actualBracket); } private partial class TestBeatmapDifficultyCache : BeatmapDifficultyCache diff --git a/osu.Game.Tests/Beatmaps/WorkingBeatmapTest.cs b/osu.Game.Tests/Beatmaps/WorkingBeatmapTest.cs index 3c26f8e39a..1f50574619 100644 --- a/osu.Game.Tests/Beatmaps/WorkingBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/WorkingBeatmapTest.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using JetBrains.Annotations; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; @@ -29,7 +30,7 @@ namespace osu.Game.Tests.Beatmaps working.ResetEvent.Set(); - Assert.NotNull(working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo)); + ClassicAssert.NotNull(working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo)); } [Test] @@ -48,11 +49,11 @@ namespace osu.Game.Tests.Beatmaps loadCompleted.Set(); }, TaskCreationOptions.LongRunning); - Assert.IsTrue(loadStarted.Wait(10000)); + ClassicAssert.True(loadStarted.Wait(10000)); cts.Cancel(); - Assert.IsTrue(loadCompleted.Wait(10000)); + ClassicAssert.True(loadCompleted.Wait(10000)); working.ResetEvent.Set(); } diff --git a/osu.Game.Tests/Chat/MessageFormatterTests.cs b/osu.Game.Tests/Chat/MessageFormatterTests.cs index 1baa737a9c..bf04ec6466 100644 --- a/osu.Game.Tests/Chat/MessageFormatterTests.cs +++ b/osu.Game.Tests/Chat/MessageFormatterTests.cs @@ -4,6 +4,7 @@ #nullable disable using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Online.Chat; namespace osu.Game.Tests.Chat @@ -31,8 +32,8 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a gopher://really-old-protocol we don't support." }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(0, result.Links.Count); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(0, result.Links.Count); } [Test] @@ -40,8 +41,8 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a osunotarealprotocol://completely-made-up-protocol we don't support." }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(0, result.Links.Count); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(0, result.Links.Count); } [Test] @@ -49,9 +50,9 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "forgotspacehttps://dev.ppy.sh joinmyosump://12345 jointheosu://chan/#english" }); - Assert.AreEqual("https://dev.ppy.sh", result.Links[0].Url); - Assert.AreEqual("osump://12345", result.Links[1].Url); - Assert.AreEqual("osu://chan/#english", result.Links[2].Url); + ClassicAssert.AreEqual("https://dev.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual("osump://12345", result.Links[1].Url); + ClassicAssert.AreEqual("osu://chan/#english", result.Links[2].Url); } [Test] @@ -59,11 +60,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a http://www.basic-link.com/?test=test." }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("http://www.basic-link.com/?test=test", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(36, result.Links[0].Length); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("http://www.basic-link.com/?test=test", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(36, result.Links[0].Length); } [TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456")] @@ -79,12 +80,12 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = link }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual(expectedAction, result.Links[0].Action); - Assert.AreEqual(expectedArg, result.Links[0].Argument); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual(expectedAction, result.Links[0].Action); + ClassicAssert.AreEqual(expectedArg, result.Links[0].Argument); if (expectedAction == LinkAction.External) - Assert.AreEqual(link, result.Links[0].Url); + ClassicAssert.AreEqual(link, result.Links[0].Url); } [Test] @@ -95,20 +96,20 @@ namespace osu.Game.Tests.Chat Content = "This is a http://test.io/link#fragment. (see https://twitter.com). Also, This string should not be altered. http://example.com/" }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(3, result.Links.Count); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(3, result.Links.Count); - Assert.AreEqual("http://test.io/link#fragment", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(28, result.Links[0].Length); + ClassicAssert.AreEqual("http://test.io/link#fragment", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(28, result.Links[0].Length); - Assert.AreEqual("https://twitter.com", result.Links[1].Url); - Assert.AreEqual(45, result.Links[1].Index); - Assert.AreEqual(19, result.Links[1].Length); + ClassicAssert.AreEqual("https://twitter.com", result.Links[1].Url); + ClassicAssert.AreEqual(45, result.Links[1].Index); + ClassicAssert.AreEqual(19, result.Links[1].Length); - Assert.AreEqual("http://example.com/", result.Links[2].Url); - Assert.AreEqual(108, result.Links[2].Index); - Assert.AreEqual(19, result.Links[2].Length); + ClassicAssert.AreEqual("http://example.com/", result.Links[2].Url); + ClassicAssert.AreEqual(108, result.Links[2].Index); + ClassicAssert.AreEqual(19, result.Links[2].Length); } [Test] @@ -116,10 +117,10 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "https://twitter.com/#!/hashbanglinks" }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(result.Content, result.Links[0].Url); - Assert.AreEqual(0, result.Links[0].Index); - Assert.AreEqual(36, result.Links[0].Length); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(result.Content, result.Links[0].Url); + ClassicAssert.AreEqual(0, result.Links[0].Index); + ClassicAssert.AreEqual(36, result.Links[0].Length); } [Test] @@ -127,10 +128,10 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "http://www.chiark.greenend.org.uk/~sgtatham/putty/" }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(result.Content, result.Links[0].Url); - Assert.AreEqual(0, result.Links[0].Index); - Assert.AreEqual(50, result.Links[0].Length); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(result.Content, result.Links[0].Url); + ClassicAssert.AreEqual(0, result.Links[0].Index); + ClassicAssert.AreEqual(50, result.Links[0].Length); } [Test] @@ -138,9 +139,9 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "look: http://puu.sh/7Ggh8xcC6/asf0asd9876.NEF" }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(6, result.Links[0].Index); - Assert.AreEqual(39, result.Links[0].Length); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(6, result.Links[0].Index); + ClassicAssert.AreEqual(39, result.Links[0].Length); } [Test] @@ -148,11 +149,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [[Wiki Link]]." }); - Assert.AreEqual("This is a Wiki Link.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://dev.ppy.sh/wiki/Wiki Link", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(9, result.Links[0].Length); + ClassicAssert.AreEqual("This is a Wiki Link.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://dev.ppy.sh/wiki/Wiki Link", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(9, result.Links[0].Length); } [Test] @@ -160,20 +161,20 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [[Wiki Link]] [[Wiki:Link]][[Wiki.Link]]." }); - Assert.AreEqual("This is a Wiki Link Wiki:LinkWiki.Link.", result.DisplayContent); - Assert.AreEqual(3, result.Links.Count); + ClassicAssert.AreEqual("This is a Wiki Link Wiki:LinkWiki.Link.", result.DisplayContent); + ClassicAssert.AreEqual(3, result.Links.Count); - Assert.AreEqual("https://dev.ppy.sh/wiki/Wiki Link", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(9, result.Links[0].Length); + ClassicAssert.AreEqual("https://dev.ppy.sh/wiki/Wiki Link", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(9, result.Links[0].Length); - Assert.AreEqual("https://dev.ppy.sh/wiki/Wiki:Link", result.Links[1].Url); - Assert.AreEqual(20, result.Links[1].Index); - Assert.AreEqual(9, result.Links[1].Length); + ClassicAssert.AreEqual("https://dev.ppy.sh/wiki/Wiki:Link", result.Links[1].Url); + ClassicAssert.AreEqual(20, result.Links[1].Index); + ClassicAssert.AreEqual(9, result.Links[1].Length); - Assert.AreEqual("https://dev.ppy.sh/wiki/Wiki.Link", result.Links[2].Url); - Assert.AreEqual(29, result.Links[2].Index); - Assert.AreEqual(9, result.Links[2].Length); + ClassicAssert.AreEqual("https://dev.ppy.sh/wiki/Wiki.Link", result.Links[2].Url); + ClassicAssert.AreEqual(29, result.Links[2].Index); + ClassicAssert.AreEqual(9, result.Links[2].Length); } [Test] @@ -181,11 +182,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a (simple test)[https://osu.ppy.sh] of links." }); - Assert.AreEqual("This is a simple test of links.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(11, result.Links[0].Length); + ClassicAssert.AreEqual("This is a simple test of links.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(11, result.Links[0].Length); } [Test] @@ -193,11 +194,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a (tricky (one))[https://osu.ppy.sh]!" }); - Assert.AreEqual("This is a tricky (one)!", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(12, result.Links[0].Length); + ClassicAssert.AreEqual("This is a tricky (one)!", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(12, result.Links[0].Length); } [Test] @@ -205,22 +206,22 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is (another loose bracket \\))[https://osu.ppy.sh]." }); - Assert.AreEqual("This is another loose bracket ).", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(8, result.Links[0].Index); - Assert.AreEqual(23, result.Links[0].Length); + ClassicAssert.AreEqual("This is another loose bracket ).", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(8, result.Links[0].Index); + ClassicAssert.AreEqual(23, result.Links[0].Length); } [Test] public void TestOldFormatWithBackslashes() { Message result = MessageFormatter.FormatMessage(new Message { Content = "This link (should end with a backslash \\)[https://osu.ppy.sh]." }); - Assert.AreEqual("This link should end with a backslash \\.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(29, result.Links[0].Length); + ClassicAssert.AreEqual("This link should end with a backslash \\.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(29, result.Links[0].Length); } [Test] @@ -228,11 +229,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a (\\)super\\(\\( tricky (one))[https://osu.ppy.sh]!" }); - Assert.AreEqual("This is a )super(( tricky (one)!", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(21, result.Links[0].Length); + ClassicAssert.AreEqual("This is a )super(( tricky (one)!", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(21, result.Links[0].Length); } [Test] @@ -240,11 +241,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [https://osu.ppy.sh simple test]." }); - Assert.AreEqual("This is a simple test.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(11, result.Links[0].Length); + ClassicAssert.AreEqual("This is a simple test.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(11, result.Links[0].Length); } [Test] @@ -252,11 +253,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [https://osu.ppy.sh nasty link with escaped brackets: \\] and \\[]" }); - Assert.AreEqual("This is a nasty link with escaped brackets: ] and [", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(41, result.Links[0].Length); + ClassicAssert.AreEqual("This is a nasty link with escaped brackets: ] and [", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(41, result.Links[0].Length); } [Test] @@ -264,11 +265,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [https://osu.ppy.sh link \\ with \\ backslashes \\]" }); - Assert.AreEqual("This is a link \\ with \\ backslashes \\", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(27, result.Links[0].Length); + ClassicAssert.AreEqual("This is a link \\ with \\ backslashes \\", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(27, result.Links[0].Length); } [Test] @@ -276,11 +277,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [https://osu.ppy.sh [link [with \\] too many brackets \\[ ]]]" }); - Assert.AreEqual("This is a [link [with ] too many brackets [ ]]", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(36, result.Links[0].Length); + ClassicAssert.AreEqual("This is a [link [with ] too many brackets [ ]]", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(36, result.Links[0].Length); } [Test] @@ -288,11 +289,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [simple test](https://osu.ppy.sh)." }); - Assert.AreEqual("This is a simple test.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(11, result.Links[0].Length); + ClassicAssert.AreEqual("This is a simple test.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(11, result.Links[0].Length); } [Test] @@ -300,11 +301,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [tricky [one]](https://osu.ppy.sh)!" }); - Assert.AreEqual("This is a tricky [one]!", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(12, result.Links[0].Length); + ClassicAssert.AreEqual("This is a tricky [one]!", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(12, result.Links[0].Length); } [Test] @@ -312,22 +313,22 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is [another loose bracket \\]](https://osu.ppy.sh)." }); - Assert.AreEqual("This is another loose bracket ].", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(8, result.Links[0].Index); - Assert.AreEqual(23, result.Links[0].Length); + ClassicAssert.AreEqual("This is another loose bracket ].", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(8, result.Links[0].Index); + ClassicAssert.AreEqual(23, result.Links[0].Length); } [Test] public void TestMarkdownFormatWithBackslashes() { Message result = MessageFormatter.FormatMessage(new Message { Content = "This link [should end with a backslash \\](https://osu.ppy.sh)." }); - Assert.AreEqual("This link should end with a backslash \\.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(29, result.Links[0].Length); + ClassicAssert.AreEqual("This link should end with a backslash \\.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(29, result.Links[0].Length); } [Test] @@ -335,11 +336,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [\\]super\\[\\[ tricky [one]](https://osu.ppy.sh)!" }); - Assert.AreEqual("This is a ]super[[ tricky [one]!", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(21, result.Links[0].Length); + ClassicAssert.AreEqual("This is a ]super[[ tricky [one]!", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(21, result.Links[0].Length); } [Test] @@ -347,11 +348,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"osu!\") before..." }); - Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(15, result.Links[0].Index); - Assert.AreEqual(16, result.Links[0].Length); + ClassicAssert.AreEqual("I haven't seen this link format before...", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(15, result.Links[0].Index); + ClassicAssert.AreEqual(16, result.Links[0].Length); } [Test] @@ -359,11 +360,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"inner quote \\\" just to confuse \") before..." }); - Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(15, result.Links[0].Index); - Assert.AreEqual(16, result.Links[0].Length); + ClassicAssert.AreEqual("I haven't seen this link format before...", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(15, result.Links[0].Index); + ClassicAssert.AreEqual(16, result.Links[0].Length); } [Test] @@ -371,11 +372,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://osu.ppy.sh](https://osu.ppy.sh \"https://osu.ppy.sh\") before..." }); - Assert.AreEqual("I haven't seen https://osu.ppy.sh before...", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(15, result.Links[0].Index); - Assert.AreEqual(18, result.Links[0].Length); + ClassicAssert.AreEqual("I haven't seen https://osu.ppy.sh before...", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(15, result.Links[0].Index); + ClassicAssert.AreEqual(18, result.Links[0].Length); } [Test] @@ -383,11 +384,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [oh no, text here! https://osu.ppy.sh](https://osu.ppy.sh) before..." }); - Assert.AreEqual("I haven't seen oh no, text here! https://osu.ppy.sh before...", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(15, result.Links[0].Index); - Assert.AreEqual(36, result.Links[0].Length); + ClassicAssert.AreEqual("I haven't seen oh no, text here! https://osu.ppy.sh before...", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(15, result.Links[0].Index); + ClassicAssert.AreEqual(36, result.Links[0].Length); } [Test] @@ -395,11 +396,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://google.com](https://osu.ppy.sh) before..." }); - Assert.AreEqual("I haven't seen https://google.com before...", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(15, result.Links[0].Index); - Assert.AreEqual(18, result.Links[0].Length); + ClassicAssert.AreEqual("I haven't seen https://google.com before...", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(15, result.Links[0].Index); + ClassicAssert.AreEqual(18, result.Links[0].Length); } [Test] @@ -407,11 +408,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "super broken https://[osu.ppy](https://reddit.com).sh/" }); - Assert.AreEqual("super broken https://osu.ppy.sh/", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://reddit.com", result.Links[0].Url); - Assert.AreEqual(21, result.Links[0].Index); - Assert.AreEqual(7, result.Links[0].Length); + ClassicAssert.AreEqual("super broken https://osu.ppy.sh/", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://reddit.com", result.Links[0].Url); + ClassicAssert.AreEqual(21, result.Links[0].Index); + ClassicAssert.AreEqual(7, result.Links[0].Length); } [Test] @@ -420,16 +421,16 @@ namespace osu.Game.Tests.Chat // the raw link has a port at the end of it, so that the raw link regex terminates at the port and doesn't consume display text from the formatted one Message result = MessageFormatter.FormatMessage(new Message { Content = "https://localhost:8080[https://osu.ppy.sh](https://osu.ppy.sh) should be two links" }); - Assert.AreEqual("https://localhost:8080https://osu.ppy.sh should be two links", result.DisplayContent); - Assert.AreEqual(2, result.Links.Count); + ClassicAssert.AreEqual("https://localhost:8080https://osu.ppy.sh should be two links", result.DisplayContent); + ClassicAssert.AreEqual(2, result.Links.Count); - Assert.AreEqual("https://localhost:8080", result.Links[0].Url); - Assert.AreEqual(0, result.Links[0].Index); - Assert.AreEqual(22, result.Links[0].Length); + ClassicAssert.AreEqual("https://localhost:8080", result.Links[0].Url); + ClassicAssert.AreEqual(0, result.Links[0].Index); + ClassicAssert.AreEqual(22, result.Links[0].Length); - Assert.AreEqual("https://osu.ppy.sh", result.Links[1].Url); - Assert.AreEqual(22, result.Links[1].Index); - Assert.AreEqual(18, result.Links[1].Length); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[1].Url); + ClassicAssert.AreEqual(22, result.Links[1].Index); + ClassicAssert.AreEqual(18, result.Links[1].Length); } [Test] @@ -437,10 +438,10 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is an #english and #japanese." }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(2, result.Links.Count); - Assert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#english", result.Links[0].Url); - Assert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#japanese", result.Links[1].Url); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(2, result.Links.Count); + ClassicAssert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#english", result.Links[0].Url); + ClassicAssert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#japanese", result.Links[1].Url); } [Test] @@ -448,20 +449,20 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = $"This is a custom protocol {OsuGameBase.OSU_PROTOCOL}chan/#english." }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#english", result.Links[0].Url); - Assert.AreEqual(26, result.Links[0].Index); - Assert.AreEqual(19, result.Links[0].Length); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#english", result.Links[0].Url); + ClassicAssert.AreEqual(26, result.Links[0].Index); + ClassicAssert.AreEqual(19, result.Links[0].Length); result = MessageFormatter.FormatMessage(new Message { Content = $"This is a [custom protocol]({OsuGameBase.OSU_PROTOCOL}chan/#english)." }); - Assert.AreEqual("This is a custom protocol.", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#english", result.Links[0].Url); - Assert.AreEqual("#english", result.Links[0].Argument); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(15, result.Links[0].Length); + ClassicAssert.AreEqual("This is a custom protocol.", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual($"{OsuGameBase.OSU_PROTOCOL}chan/#english", result.Links[0].Url); + ClassicAssert.AreEqual("#english", result.Links[0].Argument); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(15, result.Links[0].Length); } [Test] @@ -469,11 +470,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "Join my multiplayer game osump://12346." }); - Assert.AreEqual(result.Content, result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("osump://12346", result.Links[0].Url); - Assert.AreEqual(25, result.Links[0].Index); - Assert.AreEqual(13, result.Links[0].Length); + ClassicAssert.AreEqual(result.Content, result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("osump://12346", result.Links[0].Url); + ClassicAssert.AreEqual(25, result.Links[0].Index); + ClassicAssert.AreEqual(13, result.Links[0].Length); } [Test] @@ -481,11 +482,11 @@ namespace osu.Game.Tests.Chat { Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [https://osu.ppy.sh [[simple test]]]." }); - Assert.AreEqual("This is a [[simple test]].", result.DisplayContent); - Assert.AreEqual(1, result.Links.Count); - Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); - Assert.AreEqual(10, result.Links[0].Index); - Assert.AreEqual(15, result.Links[0].Length); + ClassicAssert.AreEqual("This is a [[simple test]].", result.DisplayContent); + ClassicAssert.AreEqual(1, result.Links.Count); + ClassicAssert.AreEqual("https://osu.ppy.sh", result.Links[0].Url); + ClassicAssert.AreEqual(10, result.Links[0].Index); + ClassicAssert.AreEqual(15, result.Links[0].Length); } [Test] @@ -496,44 +497,44 @@ namespace osu.Game.Tests.Chat Content = "This is a [http://www.simple-test.com simple test] with some [traps] and [[wiki links]]. Don't forget to visit https://osu.ppy.sh (now!)[http://google.com]\uD83D\uDE12" }); - Assert.AreEqual("This is a simple test with some [traps] and wiki links. Don't forget to visit https://osu.ppy.sh now![emoji]", result.DisplayContent); - Assert.AreEqual(4, result.Links.Count); + ClassicAssert.AreEqual("This is a simple test with some [traps] and wiki links. Don't forget to visit https://osu.ppy.sh now![emoji]", result.DisplayContent); + ClassicAssert.AreEqual(4, result.Links.Count); Link f = result.Links.Find(l => l.Url == "https://dev.ppy.sh/wiki/wiki links"); Assert.That(f, Is.Not.Null); - Assert.AreEqual(44, f.Index); - Assert.AreEqual(10, f.Length); + ClassicAssert.AreEqual(44, f.Index); + ClassicAssert.AreEqual(10, f.Length); f = result.Links.Find(l => l.Url == "http://www.simple-test.com"); Assert.That(f, Is.Not.Null); - Assert.AreEqual(10, f.Index); - Assert.AreEqual(11, f.Length); + ClassicAssert.AreEqual(10, f.Index); + ClassicAssert.AreEqual(11, f.Length); f = result.Links.Find(l => l.Url == "http://google.com"); Assert.That(f, Is.Not.Null); - Assert.AreEqual(97, f.Index); - Assert.AreEqual(4, f.Length); + ClassicAssert.AreEqual(97, f.Index); + ClassicAssert.AreEqual(4, f.Length); f = result.Links.Find(l => l.Url == "https://osu.ppy.sh"); Assert.That(f, Is.Not.Null); - Assert.AreEqual(78, f.Index); - Assert.AreEqual(18, f.Length); + ClassicAssert.AreEqual(78, f.Index); + ClassicAssert.AreEqual(18, f.Length); } [Test] public void TestEmoji() { Message result = MessageFormatter.FormatMessage(new Message { Content = "Hello world\uD83D\uDE12<--This is an emoji,There are more emojis among us:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20" }); - Assert.AreEqual("Hello world[emoji]<--This is an emoji,There are more emojis among us:[emoji][emoji],[emoji]", result.DisplayContent); - Assert.AreEqual(result.Links.Count, 0); + ClassicAssert.AreEqual("Hello world[emoji]<--This is an emoji,There are more emojis among us:[emoji][emoji],[emoji]", result.DisplayContent); + ClassicAssert.AreEqual(result.Links.Count, 0); } [Test] public void TestEmojiWithSuccessiveParens() { Message result = MessageFormatter.FormatMessage(new Message { Content = "\uD83D\uDE10(let's hope this doesn't accidentally turn into a link)" }); - Assert.AreEqual("[emoji](let's hope this doesn't accidentally turn into a link)", result.DisplayContent); - Assert.AreEqual(result.Links.Count, 0); + ClassicAssert.AreEqual("[emoji](let's hope this doesn't accidentally turn into a link)", result.DisplayContent); + ClassicAssert.AreEqual(result.Links.Count, 0); } [Test] @@ -541,8 +542,8 @@ namespace osu.Game.Tests.Chat { LinkDetails result = MessageFormatter.GetLinkDetails("https://google.com"); - Assert.AreEqual(LinkAction.External, result.Action); - Assert.AreEqual("https://google.com", result.Argument); + ClassicAssert.AreEqual(LinkAction.External, result.Action); + ClassicAssert.AreEqual("https://google.com", result.Argument); } [Test] @@ -550,8 +551,8 @@ namespace osu.Game.Tests.Chat { LinkDetails result = MessageFormatter.GetLinkDetails("/relative"); - Assert.AreEqual(LinkAction.External, result.Action); - Assert.AreEqual("/relative", result.Argument); + ClassicAssert.AreEqual(LinkAction.External, result.Action); + ClassicAssert.AreEqual("/relative", result.Argument); } [TestCase("https://dev.ppy.sh/home/changelog", "")] @@ -560,8 +561,8 @@ namespace osu.Game.Tests.Chat { LinkDetails result = MessageFormatter.GetLinkDetails(link); - Assert.AreEqual(LinkAction.OpenChangelog, result.Action); - Assert.AreEqual(expectedArg, result.Argument); + ClassicAssert.AreEqual(LinkAction.OpenChangelog, result.Action); + ClassicAssert.AreEqual(expectedArg, result.Argument); } } } diff --git a/osu.Game.Tests/Database/BeatmapImporterTests.cs b/osu.Game.Tests/Database/BeatmapImporterTests.cs index ffe465e713..c1b5e4ec5a 100644 --- a/osu.Game.Tests/Database/BeatmapImporterTests.cs +++ b/osu.Game.Tests/Database/BeatmapImporterTests.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Extensions; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Logging; @@ -42,7 +43,7 @@ namespace osu.Game.Tests.Database { var beatmapSet = await importer.Import(new ImportTask(TestResources.GetTestBeatmapStream(), "renatus.osz")); - Assert.NotNull(beatmapSet); + ClassicAssert.NotNull(beatmapSet); Debug.Assert(beatmapSet != null); BeatmapSetInfo? detachedBeatmapSet = null; @@ -52,23 +53,23 @@ namespace osu.Game.Tests.Database detachedBeatmapSet = live.Detach(); // files are omitted - Assert.AreEqual(0, detachedBeatmapSet.Files.Count); + ClassicAssert.AreEqual(0, detachedBeatmapSet.Files.Count); - Assert.AreEqual(live.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count); - Assert.AreEqual(live.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); - Assert.AreEqual(live.Metadata, detachedBeatmapSet.Metadata); + ClassicAssert.AreEqual(live.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count); + ClassicAssert.AreEqual(live.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); + ClassicAssert.AreEqual(live.Metadata, detachedBeatmapSet.Metadata); }); Debug.Assert(detachedBeatmapSet != null); // Check detached instances can all be accessed without throwing. - Assert.AreEqual(0, detachedBeatmapSet.Files.Count); - Assert.NotNull(detachedBeatmapSet.Beatmaps.Count); - Assert.NotZero(detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); - Assert.NotNull(detachedBeatmapSet.Metadata); + ClassicAssert.AreEqual(0, detachedBeatmapSet.Files.Count); + ClassicAssert.NotNull(detachedBeatmapSet.Beatmaps.Count); + ClassicAssert.NotZero(detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); + ClassicAssert.NotNull(detachedBeatmapSet.Metadata); // Check cyclic reference to beatmap set - Assert.AreEqual(detachedBeatmapSet, detachedBeatmapSet.Beatmaps.First().BeatmapSet); + ClassicAssert.AreEqual(detachedBeatmapSet, detachedBeatmapSet.Beatmaps.First().BeatmapSet); } }); } @@ -84,7 +85,7 @@ namespace osu.Game.Tests.Database { var beatmapSet = await importer.Import(new ImportTask(TestResources.GetTestBeatmapStream(), "renatus.osz")); - Assert.NotNull(beatmapSet); + ClassicAssert.NotNull(beatmapSet); Debug.Assert(beatmapSet != null); // Detach at the BeatmapInfo point, similar to what GetWorkingBeatmap does. @@ -101,7 +102,7 @@ namespace osu.Game.Tests.Database detachedBeatmapSet.Beatmaps.First().Metadata.Artist = "New Artist"; detachedBeatmapSet.Beatmaps.First().Metadata.Author = newUser; - Assert.AreNotEqual(detachedBeatmapSet.Status, BeatmapOnlineStatus.Ranked); + ClassicAssert.AreNotEqual(detachedBeatmapSet.Status, BeatmapOnlineStatus.Ranked); detachedBeatmapSet.Status = BeatmapOnlineStatus.Ranked; beatmapSet.PerformWrite(detachedBeatmapSet.CopyChangesToRealm); @@ -109,17 +110,17 @@ namespace osu.Game.Tests.Database beatmapSet.PerformRead(s => { // Check above changes explicitly. - Assert.AreEqual(BeatmapOnlineStatus.Ranked, s.Status); - Assert.AreEqual("New Artist", s.Beatmaps.First().Metadata.Artist); - Assert.AreEqual(newUser, s.Beatmaps.First().Metadata.Author); - Assert.NotZero(s.Files.Count); + ClassicAssert.AreEqual(BeatmapOnlineStatus.Ranked, s.Status); + ClassicAssert.AreEqual("New Artist", s.Beatmaps.First().Metadata.Artist); + ClassicAssert.AreEqual(newUser, s.Beatmaps.First().Metadata.Author); + ClassicAssert.NotZero(s.Files.Count); // Check nothing was lost in the copy operation. - Assert.AreEqual(s.Files.Count, detachedBeatmapSet.Files.Count); - Assert.AreEqual(s.Files.Select(f => f.File).Count(), detachedBeatmapSet.Files.Select(f => f.File).Count()); - Assert.AreEqual(s.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count); - Assert.AreEqual(s.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); - Assert.AreEqual(s.Metadata, detachedBeatmapSet.Metadata); + ClassicAssert.AreEqual(s.Files.Count, detachedBeatmapSet.Files.Count); + ClassicAssert.AreEqual(s.Files.Select(f => f.File).Count(), detachedBeatmapSet.Files.Select(f => f.File).Count()); + ClassicAssert.AreEqual(s.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count); + ClassicAssert.AreEqual(s.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); + ClassicAssert.AreEqual(s.Metadata, detachedBeatmapSet.Metadata); }); } }); @@ -142,7 +143,7 @@ namespace osu.Game.Tests.Database { var beatmapSet = await importer.Import(new ImportTask(TestResources.GetTestBeatmapStream(), "renatus.osz")); - Assert.NotNull(beatmapSet); + ClassicAssert.NotNull(beatmapSet); Debug.Assert(beatmapSet != null); // Intentionally detach on async thread as to not trigger a refresh on the main thread. @@ -167,20 +168,20 @@ namespace osu.Game.Tests.Database var imported = await importer.Import(new ImportTask(TestResources.GetTestBeatmapStream(), "renatus.osz")); EnsureLoaded(realm.Realm); - Assert.AreEqual(1, realm.Realm.All().Count()); + ClassicAssert.AreEqual(1, realm.Realm.All().Count()); - Assert.NotNull(imported); + ClassicAssert.NotNull(imported); Debug.Assert(imported != null); imported.PerformWrite(s => s.DeletePending = true); - Assert.AreEqual(1, realm.Realm.All().Count(s => s.DeletePending)); + ClassicAssert.AreEqual(1, realm.Realm.All().Count(s => s.DeletePending)); } }); Logger.Log("Running with no work to purge pending deletions"); - RunTestWithRealm((realm, _) => { Assert.AreEqual(0, realm.Realm.All().Count()); }); + RunTestWithRealm((realm, _) => { ClassicAssert.AreEqual(0, realm.Realm.All().Count()); }); } [Test] @@ -208,8 +209,8 @@ namespace osu.Game.Tests.Database var beatmap = imported.Beatmaps.First(); var file = beatmap.File; - Assert.NotNull(file); - Assert.AreEqual(beatmap.Hash, file!.File.Hash); + ClassicAssert.NotNull(file); + ClassicAssert.AreEqual(beatmap.Hash, file!.File.Hash); }); } @@ -245,10 +246,10 @@ namespace osu.Game.Tests.Database EnsureLoaded(realm.Realm); } - Assert.NotNull(importedSet); + ClassicAssert.NotNull(importedSet); Debug.Assert(importedSet != null); - Assert.IsTrue(File.Exists(tempPath), "Stream source file somehow went missing"); + ClassicAssert.True(File.Exists(tempPath), "Stream source file somehow went missing"); File.Delete(tempPath); var imported = realm.Realm.All().First(beatmapSet => beatmapSet.ID == importedSet.ID); @@ -269,8 +270,8 @@ namespace osu.Game.Tests.Database var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. - Assert.IsTrue(imported.ID == importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); + ClassicAssert.True(imported.ID == importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); checkBeatmapSetCount(realm.Realm, 1); checkSingleReferencedFileCount(realm.Realm, 18); @@ -292,7 +293,7 @@ namespace osu.Game.Tests.Database try { - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); foreach (var file in new DirectoryInfo(extractedFolder).GetFiles("*.osu")) @@ -304,7 +305,7 @@ namespace osu.Game.Tests.Database } var imported = await importer.Import(new ImportTask(extractedFolder)); - Assert.IsNull(imported); + ClassicAssert.Null(imported); } finally { @@ -333,28 +334,28 @@ namespace osu.Game.Tests.Database string hashBefore = hashFile(temp); - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); } // zip files differ because different compression or encoder. - Assert.AreNotEqual(hashBefore, hashFile(temp)); + ClassicAssert.AreNotEqual(hashBefore, hashFile(temp)); var importedSecondTime = await importer.Import(new ImportTask(temp)); EnsureLoaded(realm.Realm); - Assert.NotNull(importedSecondTime); + ClassicAssert.NotNull(importedSecondTime); Debug.Assert(importedSecondTime != null); // but contents doesn't, so existing should still be used. - Assert.IsTrue(imported.ID == importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); + ClassicAssert.True(imported.ID == importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID == importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); } finally { @@ -382,7 +383,7 @@ namespace osu.Game.Tests.Database await createScoreForBeatmap(realm.Realm, imported.Beatmaps.First()); - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); // arbitrary write to hashed file @@ -390,7 +391,7 @@ namespace osu.Game.Tests.Database using (var sw = new FileInfo(Directory.GetFiles(extractedFolder, "*.osu").First()).AppendText()) await sw.WriteLineAsync("// changed"); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); @@ -401,11 +402,11 @@ namespace osu.Game.Tests.Database EnsureLoaded(realm.Realm); // check the newly "imported" beatmap is not the original. - Assert.NotNull(importedSecondTime); + ClassicAssert.NotNull(importedSecondTime); Debug.Assert(importedSecondTime != null); - Assert.IsTrue(imported.ID != importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); + ClassicAssert.True(imported.ID != importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID != importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); } finally { @@ -501,7 +502,7 @@ namespace osu.Game.Tests.Database EnsureLoaded(realm.Realm); // check the newly "imported" beatmap is not the original. - Assert.NotNull(importedSecondTime); + ClassicAssert.NotNull(importedSecondTime); Debug.Assert(importedSecondTime != null); Assert.That(imported.ID != importedSecondTime.ID); @@ -533,14 +534,14 @@ namespace osu.Game.Tests.Database { var imported = await LoadOszIntoStore(importer, realm.Realm); - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); // arbitrary write to non-hashed file using (var sw = new FileInfo(Directory.GetFiles(extractedFolder, "*.mp3").First()).AppendText()) await sw.WriteLineAsync("text"); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); @@ -550,12 +551,12 @@ namespace osu.Game.Tests.Database EnsureLoaded(realm.Realm); - Assert.NotNull(importedSecondTime); + ClassicAssert.NotNull(importedSecondTime); Debug.Assert(importedSecondTime != null); // check the newly "imported" beatmap is not the original. - Assert.IsTrue(imported.ID != importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); + ClassicAssert.True(imported.ID != importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID != importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); } finally { @@ -581,14 +582,14 @@ namespace osu.Game.Tests.Database { var imported = await LoadOszIntoStore(importer, realm.Realm); - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); // change filename var firstFile = new FileInfo(Directory.GetFiles(extractedFolder).First()); firstFile.MoveTo(Path.Combine(firstFile.DirectoryName.AsNonNull(), $"{firstFile.Name}-changed{firstFile.Extension}")); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); @@ -598,12 +599,12 @@ namespace osu.Game.Tests.Database EnsureLoaded(realm.Realm); - Assert.NotNull(importedSecondTime); + ClassicAssert.NotNull(importedSecondTime); Debug.Assert(importedSecondTime != null); // check the newly "imported" beatmap is not the original. - Assert.IsTrue(imported.ID != importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); + ClassicAssert.True(imported.ID != importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID != importedSecondTime.PerformRead(s => s.Beatmaps.First().ID)); } finally { @@ -636,11 +637,11 @@ namespace osu.Game.Tests.Database var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm); using (var stream = fileStorage.GetStream(firstFile.File.GetStoragePath())) - Assert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import"); + ClassicAssert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import"); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. - Assert.IsTrue(imported.ID == importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); + ClassicAssert.True(imported.ID == importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); checkBeatmapSetCount(realm.Realm, 1); checkSingleReferencedFileCount(realm.Realm, 18); @@ -659,7 +660,7 @@ namespace osu.Game.Tests.Database var zipStream = new MemoryStream(); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate)); var imported = await importer.Import( @@ -672,8 +673,8 @@ namespace osu.Game.Tests.Database checkBeatmapSetCount(realm.Realm, 0); checkBeatmapCount(realm.Realm, 0); - Assert.IsEmpty(imported); - Assert.AreEqual(ProgressNotificationState.Cancelled, progressNotification.State); + ClassicAssert.IsEmpty(imported); + ClassicAssert.AreEqual(ProgressNotificationState.Cancelled, progressNotification.State); }); } @@ -709,7 +710,7 @@ namespace osu.Game.Tests.Database File.Delete(brokenTempFilename); using (var outStream = File.Open(brokenTempFilename, FileMode.CreateNew)) - using (var zip = ZipArchive.Open(brokenOsz)) + using (var zip = ZipArchive.OpenArchive(brokenOsz)) { foreach (var entry in zip.Entries.ToArray()) { @@ -737,7 +738,7 @@ namespace osu.Game.Tests.Database checkSingleReferencedFileCount(realm.Realm, 18); - Assert.AreEqual(0, loggedExceptionCount); + ClassicAssert.AreEqual(0, loggedExceptionCount); File.Delete(brokenTempFilename); }); @@ -755,17 +756,17 @@ namespace osu.Game.Tests.Database deleteBeatmapSet(imported, realm.Realm); - Assert.IsTrue(imported.DeletePending); + ClassicAssert.True(imported.DeletePending); var originalAddedDate = imported.DateAdded; var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. - Assert.IsTrue(imported.ID == importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); - Assert.IsFalse(imported.DeletePending); - Assert.IsFalse(importedSecondTime.DeletePending); + ClassicAssert.True(imported.ID == importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); + ClassicAssert.False(imported.DeletePending); + ClassicAssert.False(importedSecondTime.DeletePending); Assert.That(importedSecondTime.DateAdded, Is.GreaterThan(originalAddedDate)); }); } @@ -787,13 +788,13 @@ namespace osu.Game.Tests.Database try { - using (var zip = ZipArchive.Open(pathOriginal)) + using (var zip = ZipArchive.OpenArchive(pathOriginal)) zip.WriteToDirectory(extractedFolder); // remove one difficulty before first import new FileInfo(Directory.GetFiles(extractedFolder, "*.osu").First()).Delete(); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(pathMissingOneBeatmap, new ZipWriterOptions(CompressionType.Deflate)); @@ -841,7 +842,7 @@ namespace osu.Game.Tests.Database deleteBeatmapSet(imported, realmFactory.Realm); - Assert.IsTrue(imported.DeletePending); + ClassicAssert.True(imported.DeletePending); // intentionally nuke all files storage.DeleteDirectory("files"); @@ -851,10 +852,10 @@ namespace osu.Game.Tests.Database var importedSecondTime = await LoadOszIntoStore(importer, realmFactory.Realm); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. - Assert.IsTrue(imported.ID == importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); - Assert.IsFalse(imported.DeletePending); - Assert.IsFalse(importedSecondTime.DeletePending); + ClassicAssert.True(imported.ID == importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); + ClassicAssert.False(imported.DeletePending); + ClassicAssert.False(importedSecondTime.DeletePending); // check that the files now exist, even though they were deleted above. Assert.That(importedSecondTime.Files.All(f => storage.GetStorageForDirectory("files").Exists(f.File.GetStoragePath()))); @@ -873,17 +874,17 @@ namespace osu.Game.Tests.Database deleteBeatmapSet(imported, realm.Realm); - Assert.IsTrue(imported.DeletePending); + ClassicAssert.True(imported.DeletePending); var originalAddedDate = imported.DateAdded; var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. - Assert.IsTrue(imported.ID == importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); - Assert.IsFalse(imported.DeletePending); - Assert.IsFalse(importedSecondTime.DeletePending); + ClassicAssert.True(imported.ID == importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); + ClassicAssert.False(imported.DeletePending); + ClassicAssert.False(importedSecondTime.DeletePending); Assert.That(importedSecondTime.DateAdded, Is.GreaterThan(originalAddedDate)); }); } @@ -909,8 +910,8 @@ namespace osu.Game.Tests.Database var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm); // check the newly "imported" beatmap has been reimported due to mismatch (even though hashes matched) - Assert.IsTrue(imported.ID != importedSecondTime.ID); - Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID); + ClassicAssert.True(imported.ID != importedSecondTime.ID); + ClassicAssert.True(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID); }); } @@ -954,11 +955,11 @@ namespace osu.Game.Tests.Database realm.Run(r => r.Refresh()); - Assert.NotNull(imported); + ClassicAssert.NotNull(imported); Debug.Assert(imported != null); - Assert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[0].OnlineID)); - Assert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[1].OnlineID)); + ClassicAssert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[0].OnlineID)); + ClassicAssert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[1].OnlineID)); }); } @@ -975,7 +976,7 @@ namespace osu.Game.Tests.Database await importer.Import(temp); EnsureLoaded(realm.Realm); File.Delete(temp); - Assert.IsFalse(File.Exists(temp), "We likely held a read lock on the file when we shouldn't"); + ClassicAssert.False(File.Exists(temp), "We likely held a read lock on the file when we shouldn't"); }); } @@ -994,10 +995,10 @@ namespace osu.Game.Tests.Database try { - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.AddEntry("duplicate.osu", Directory.GetFiles(extractedFolder, "*.osu").First()); @@ -1030,7 +1031,7 @@ namespace osu.Game.Tests.Database try { - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); var subdirectory = Directory.CreateDirectory(Path.Combine(extractedFolder, "subdir")); @@ -1041,7 +1042,7 @@ namespace osu.Game.Tests.Database using (var textWriter = new StreamWriter(stream)) await textWriter.WriteLineAsync("# adding a comment so that the hashes are different"); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); @@ -1075,10 +1076,10 @@ namespace osu.Game.Tests.Database try { - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(subfolder); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); @@ -1086,12 +1087,12 @@ namespace osu.Game.Tests.Database var imported = await importer.Import(new ImportTask(temp)); - Assert.NotNull(imported); + ClassicAssert.NotNull(imported); Debug.Assert(imported != null); EnsureLoaded(realm.Realm); - Assert.IsFalse(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("subfolder"))), "Files contain common subfolder"); + ClassicAssert.False(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("subfolder"))), "Files contain common subfolder"); } finally { @@ -1125,10 +1126,10 @@ namespace osu.Game.Tests.Database try { - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(dataFolder); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate)); @@ -1136,13 +1137,13 @@ namespace osu.Game.Tests.Database var imported = await importer.Import(new ImportTask(temp)); - Assert.NotNull(imported); + ClassicAssert.NotNull(imported); Debug.Assert(imported != null); EnsureLoaded(realm.Realm); - Assert.IsFalse(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("__MACOSX"))), "Files contain resource fork folder, which should be ignored"); - Assert.IsFalse(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("actual_data"))), "Files contain common subfolder"); + ClassicAssert.False(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("__MACOSX"))), "Files contain resource fork folder, which should be ignored"); + ClassicAssert.False(imported.PerformRead(s => s.Files.Any(f => f.Filename.Contains("actual_data"))), "Files contain common subfolder"); } finally { @@ -1182,7 +1183,7 @@ namespace osu.Game.Tests.Database var importedSet = await importer.Import(new ImportTask(temp)); - Assert.NotNull(importedSet); + ClassicAssert.NotNull(importedSet); EnsureLoaded(realm); @@ -1197,7 +1198,7 @@ namespace osu.Game.Tests.Database var importedSet = await importer.Import(new ImportTask(temp), new ImportParameters { Batch = batchImport }); - Assert.NotNull(importedSet); + ClassicAssert.NotNull(importedSet); Debug.Assert(importedSet != null); EnsureLoaded(realm); @@ -1214,7 +1215,7 @@ namespace osu.Game.Tests.Database checkBeatmapSetCount(realm, 0); checkBeatmapSetCount(realm, 1, true); - Assert.IsTrue(realm.All().First(_ => true).DeletePending); + ClassicAssert.True(realm.All().First(_ => true).DeletePending); } private static Task createScoreForBeatmap(Realm realm, BeatmapInfo beatmap) => @@ -1230,7 +1231,7 @@ namespace osu.Game.Tests.Database private static void checkBeatmapSetCount(Realm realm, int expected, bool includeDeletePending = false) { - Assert.AreEqual(expected, includeDeletePending + ClassicAssert.AreEqual(expected, includeDeletePending ? realm.All().Count() : realm.All().Count(s => !s.DeletePending)); } @@ -1243,7 +1244,7 @@ namespace osu.Game.Tests.Database private static void checkBeatmapCount(Realm realm, int expected) { - Assert.AreEqual(expected, realm.All().Where(_ => true).ToList().Count); + ClassicAssert.AreEqual(expected, realm.All().Where(_ => true).ToList().Count); } private static void checkSingleReferencedFileCount(Realm realm, int expected) @@ -1256,7 +1257,7 @@ namespace osu.Game.Tests.Database singleReferencedCount++; } - Assert.AreEqual(expected, singleReferencedCount); + ClassicAssert.AreEqual(expected, singleReferencedCount); } internal static void EnsureLoaded(Realm realm, int timeout = 60000) @@ -1270,7 +1271,7 @@ namespace osu.Game.Tests.Database }, @"BeatmapSet did not import to the database in allocated time.", timeout); // ensure we were stored to beatmap database backing... - Assert.IsTrue(resultSets?.Count() == 1, $@"Incorrect result count found ({resultSets?.Count()} but should be 1)."); + ClassicAssert.True(resultSets?.Count() == 1, $@"Incorrect result count found ({resultSets?.Count()} but should be 1)."); IEnumerable queryBeatmapSets() => realm.All().Where(s => !s.DeletePending && s.OnlineID == 241526); @@ -1279,20 +1280,20 @@ namespace osu.Game.Tests.Database // ReSharper disable once PossibleUnintendedReferenceComparison IEnumerable queryBeatmaps() => realm.All().Where(s => s.BeatmapSet != null && s.BeatmapSet == set); - Assert.AreEqual(12, queryBeatmaps().Count(), @"Beatmap count was not correct"); - Assert.AreEqual(1, queryBeatmapSets().Count(), @"Beatmapset count was not correct"); + ClassicAssert.AreEqual(12, queryBeatmaps().Count(), @"Beatmap count was not correct"); + ClassicAssert.AreEqual(1, queryBeatmapSets().Count(), @"Beatmapset count was not correct"); int countBeatmapSetBeatmaps; int countBeatmaps; - Assert.AreEqual( + ClassicAssert.AreEqual( countBeatmapSetBeatmaps = queryBeatmapSets().First().Beatmaps.Count, countBeatmaps = queryBeatmaps().Count(), $@"Incorrect database beatmap count post-import ({countBeatmaps} but should be {countBeatmapSetBeatmaps})."); foreach (BeatmapInfo b in set.Beatmaps) - Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID)); - Assert.IsTrue(set.Beatmaps.Count > 0); + ClassicAssert.True(set.Beatmaps.Any(c => c.OnlineID == b.OnlineID)); + ClassicAssert.True(set.Beatmaps.Count > 0); } private static void waitForOrAssert(Func result, string failureMessage, int timeout = 60000) diff --git a/osu.Game.Tests/Database/BeatmapImporterUpdateTests.cs b/osu.Game.Tests/Database/BeatmapImporterUpdateTests.cs index 3f1bc58147..016658f68b 100644 --- a/osu.Game.Tests/Database/BeatmapImporterUpdateTests.cs +++ b/osu.Game.Tests/Database/BeatmapImporterUpdateTests.cs @@ -680,14 +680,14 @@ namespace osu.Game.Tests.Database string extractedFolder = $"{path}_extracted"; Directory.CreateDirectory(extractedFolder); - using (var zip = ZipArchive.Open(path)) + using (var zip = ZipArchive.OpenArchive(path)) zip.WriteToDirectory(extractedFolder); applyModifications(new DirectoryInfo(extractedFolder)); File.Delete(path); - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { zip.AddAllFromDirectory(extractedFolder); zip.SaveTo(path, new ZipWriterOptions(CompressionType.Deflate)); diff --git a/osu.Game.Tests/Database/FileStoreTests.cs b/osu.Game.Tests/Database/FileStoreTests.cs index ab9b761b8f..243d4eebcd 100644 --- a/osu.Game.Tests/Database/FileStoreTests.cs +++ b/osu.Game.Tests/Database/FileStoreTests.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Logging; using osu.Game.Database; using osu.Game.Extensions; @@ -26,8 +27,8 @@ namespace osu.Game.Tests.Database realm.Write(() => files.Add(testData, realm)); - Assert.True(files.Storage.Exists("0/05/054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8")); - Assert.True(files.Storage.Exists(realm.All().First().GetStoragePath())); + ClassicAssert.True(files.Storage.Exists("0/05/054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8")); + ClassicAssert.True(files.Storage.Exists(realm.All().First().GetStoragePath())); }); } @@ -44,7 +45,7 @@ namespace osu.Game.Tests.Database realm.Write(() => files.Add(testData, realm)); realm.Write(() => files.Add(testData, realm)); - Assert.AreEqual(1, realm.All().Count()); + ClassicAssert.AreEqual(1, realm.All().Count()); }); } @@ -75,15 +76,15 @@ namespace osu.Game.Tests.Database string path = file.GetStoragePath(); - Assert.True(realm.All().Any()); - Assert.True(files.Storage.Exists(path)); + ClassicAssert.True(realm.All().Any()); + ClassicAssert.True(files.Storage.Exists(path)); files.Cleanup(); Logger.Log($"Cleanup complete at {timer.ElapsedMilliseconds}"); - Assert.True(realm.All().Any()); - Assert.True(file.IsValid); - Assert.True(files.Storage.Exists(path)); + ClassicAssert.True(realm.All().Any()); + ClassicAssert.True(file.IsValid); + ClassicAssert.True(files.Storage.Exists(path)); }); } @@ -99,14 +100,14 @@ namespace osu.Game.Tests.Database string path = file.GetStoragePath(); - Assert.True(realm.All().Any()); - Assert.True(files.Storage.Exists(path)); + ClassicAssert.True(realm.All().Any()); + ClassicAssert.True(files.Storage.Exists(path)); files.Cleanup(); - Assert.False(realm.All().Any()); - Assert.False(file.IsValid); - Assert.False(files.Storage.Exists(path)); + ClassicAssert.False(realm.All().Any()); + ClassicAssert.False(file.IsValid); + ClassicAssert.False(files.Storage.Exists(path)); }); } } diff --git a/osu.Game.Tests/Database/GeneralUsageTests.cs b/osu.Game.Tests/Database/GeneralUsageTests.cs index b8073a65bc..3550d39ab8 100644 --- a/osu.Game.Tests/Database/GeneralUsageTests.cs +++ b/osu.Game.Tests/Database/GeneralUsageTests.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Extensions; using osu.Game.Beatmaps; using osu.Game.Database; @@ -143,7 +144,7 @@ namespace osu.Game.Tests.Database return null; }); - Assert.IsTrue(callbackRan); + ClassicAssert.True(callbackRan); }); } diff --git a/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs b/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs index 016928c6d6..80be6fcfef 100644 --- a/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs +++ b/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs @@ -7,6 +7,7 @@ using System.IO; using System.IO.Compression; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -93,8 +94,8 @@ namespace osu.Game.Tests.Database var importedSet = realm.Realm.All().Single(); - Assert.NotNull(importedSet); - Assert.AreEqual(new DateTimeOffset(new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)), importedSet.DateAdded); + ClassicAssert.NotNull(importedSet); + ClassicAssert.AreEqual(new DateTimeOffset(new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)), importedSet.DateAdded); } }); } diff --git a/osu.Game.Tests/Database/RealmLiveTests.cs b/osu.Game.Tests/Database/RealmLiveTests.cs index cea30acf3f..5035ff68c9 100644 --- a/osu.Game.Tests/Database/RealmLiveTests.cs +++ b/osu.Game.Tests/Database/RealmLiveTests.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Extensions; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -25,7 +26,7 @@ namespace osu.Game.Tests.Database Live beatmap2 = realm.Run(r => r.All().First().ToLive(realm)); - Assert.AreEqual(beatmap, beatmap2); + ClassicAssert.AreEqual(beatmap, beatmap2); }); } @@ -52,7 +53,7 @@ namespace osu.Game.Tests.Database using (realm.BlockAllOperations("testing")) storage.Migrate(migratedStorage); - Assert.IsFalse(liveBeatmap?.PerformRead(l => l.Hidden)); + ClassicAssert.False(liveBeatmap?.PerformRead(l => l.Hidden)); }); } } @@ -111,7 +112,7 @@ namespace osu.Game.Tests.Database r.Add(beatmap))) ); - Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden)); + ClassicAssert.False(liveBeatmap.PerformRead(l => l.Hidden)); }); } @@ -126,7 +127,7 @@ namespace osu.Game.Tests.Database realm.Run(r => r.Write(_ => r.Add(beatmap))); - Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden)); + ClassicAssert.False(liveBeatmap.PerformRead(l => l.Hidden)); }); } @@ -136,15 +137,15 @@ namespace osu.Game.Tests.Database var beatmap = new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata()); var liveBeatmap = beatmap.ToLiveUnmanaged(); - Assert.IsFalse(beatmap.Hidden); - Assert.IsFalse(liveBeatmap.Value.Hidden); - Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden)); + ClassicAssert.False(beatmap.Hidden); + ClassicAssert.False(liveBeatmap.Value.Hidden); + ClassicAssert.False(liveBeatmap.PerformRead(l => l.Hidden)); Assert.Throws(() => liveBeatmap.PerformWrite(l => l.Hidden = true)); - Assert.IsFalse(beatmap.Hidden); - Assert.IsFalse(liveBeatmap.Value.Hidden); - Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden)); + ClassicAssert.False(beatmap.Hidden); + ClassicAssert.False(liveBeatmap.Value.Hidden); + ClassicAssert.False(liveBeatmap.PerformRead(l => l.Hidden)); } [Test] @@ -159,10 +160,10 @@ namespace osu.Game.Tests.Database var liveBeatmap = beatmap.ToLive(realm); Assert.Throws(() => liveBeatmap.PerformWrite(l => throw new InvalidOperationException())); - Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden)); + ClassicAssert.False(liveBeatmap.PerformRead(l => l.Hidden)); liveBeatmap.PerformWrite(l => l.Hidden = true); - Assert.IsTrue(liveBeatmap.PerformRead(l => l.Hidden)); + ClassicAssert.True(liveBeatmap.PerformRead(l => l.Hidden)); }); } @@ -188,8 +189,8 @@ namespace osu.Game.Tests.Database { liveBeatmap.PerformRead(beatmap => { - Assert.IsTrue(beatmap.IsValid); - Assert.IsFalse(beatmap.Hidden); + ClassicAssert.True(beatmap.IsValid); + ClassicAssert.False(beatmap.Hidden); }); }, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).WaitSafely(); }); @@ -216,7 +217,7 @@ namespace osu.Game.Tests.Database Task.Factory.StartNew(() => { liveBeatmap.PerformWrite(beatmap => { beatmap.Hidden = true; }); - liveBeatmap.PerformRead(beatmap => { Assert.IsTrue(beatmap.Hidden); }); + liveBeatmap.PerformRead(beatmap => { ClassicAssert.True(beatmap.Hidden); }); }, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).WaitSafely(); }); } @@ -333,17 +334,17 @@ namespace osu.Game.Tests.Database Debug.Assert(liveBeatmap != null); // not yet seen by main context - Assert.AreEqual(0, outerRealm.All().Count()); - Assert.AreEqual(0, changesTriggered); + ClassicAssert.AreEqual(0, outerRealm.All().Count()); + ClassicAssert.AreEqual(0, changesTriggered); liveBeatmap.PerformRead(resolved => { // retrieval causes an implicit refresh. even changes that aren't related to the retrieval are fired at this point. - Assert.AreEqual(2, outerRealm.All().Count()); - Assert.AreEqual(1, changesTriggered); + ClassicAssert.AreEqual(2, outerRealm.All().Count()); + ClassicAssert.AreEqual(1, changesTriggered); // can access properties without a crash. - Assert.IsFalse(resolved.Hidden); + ClassicAssert.False(resolved.Hidden); outerRealm.Write(r => { diff --git a/osu.Game.Tests/Database/RulesetStoreTests.cs b/osu.Game.Tests/Database/RulesetStoreTests.cs index 7ef2429491..c8e2a42d81 100644 --- a/osu.Game.Tests/Database/RulesetStoreTests.cs +++ b/osu.Game.Tests/Database/RulesetStoreTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Catch; @@ -27,8 +28,8 @@ namespace osu.Game.Tests.Database { using var rulesets = new RealmRulesetStore(realm, storage); - Assert.AreEqual(4, rulesets.AvailableRulesets.Count()); - Assert.AreEqual(4, realm.Realm.All().Count()); + ClassicAssert.AreEqual(4, rulesets.AvailableRulesets.Count()); + ClassicAssert.AreEqual(4, realm.Realm.All().Count()); }); } @@ -40,11 +41,11 @@ namespace osu.Game.Tests.Database using var rulesets = new RealmRulesetStore(realm, storage); using var rulesets2 = new RealmRulesetStore(realm, storage); - Assert.AreEqual(4, rulesets.AvailableRulesets.Count()); - Assert.AreEqual(4, rulesets2.AvailableRulesets.Count()); + ClassicAssert.AreEqual(4, rulesets.AvailableRulesets.Count()); + ClassicAssert.AreEqual(4, rulesets2.AvailableRulesets.Count()); - Assert.AreEqual(rulesets.AvailableRulesets.First(), rulesets2.AvailableRulesets.First()); - Assert.AreEqual(4, realm.Realm.All().Count()); + ClassicAssert.AreEqual(rulesets.AvailableRulesets.First(), rulesets2.AvailableRulesets.First()); + ClassicAssert.AreEqual(4, realm.Realm.All().Count()); }); } @@ -55,9 +56,9 @@ namespace osu.Game.Tests.Database { using var rulesets = new RealmRulesetStore(realm, storage); - Assert.IsFalse(rulesets.AvailableRulesets.First().IsManaged); - Assert.IsFalse(rulesets.GetRuleset(0)?.IsManaged); - Assert.IsFalse(rulesets.GetRuleset("mania")?.IsManaged); + ClassicAssert.False(rulesets.AvailableRulesets.First().IsManaged); + ClassicAssert.False(rulesets.GetRuleset(0)?.IsManaged); + ClassicAssert.False(rulesets.GetRuleset("mania")?.IsManaged); }); } diff --git a/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs b/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs index e2774cef00..004a89ddec 100644 --- a/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs +++ b/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs @@ -3,14 +3,11 @@ #nullable disable -using System; using System.Collections.Generic; -using System.IO; using System.Linq; using NUnit.Framework; using osu.Framework.Input; using osu.Framework.Input.Bindings; -using osu.Framework.Platform; using osu.Game.Database; using osu.Game.Input; using osu.Game.Input.Bindings; @@ -20,63 +17,87 @@ using Realms; namespace osu.Game.Tests.Database { [TestFixture] - public partial class TestRealmKeyBindingStore + public partial class TestRealmKeyBindingStore : RealmTest { - private NativeStorage storage; - - private RealmKeyBindingStore keyBindingStore; - - private RealmAccess realm; - - [SetUp] - public void SetUp() - { - var directory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); - - storage = new NativeStorage(directory.FullName); - - realm = new RealmAccess(storage, "test"); - keyBindingStore = new RealmKeyBindingStore(realm, new ReadableKeyCombinationProvider()); - } - [Test] public void TestDefaultsPopulationAndQuery() { - Assert.That(queryCount(), Is.EqualTo(0)); + RunTestWithRealm((realm, _) => + { + Assert.That(queryCount(realm), Is.EqualTo(0)); - KeyBindingContainer testContainer = new TestKeyBindingContainer(); + KeyBindingContainer testContainer = new TestKeyBindingContainer(); - keyBindingStore.Register(testContainer, Enumerable.Empty()); + var keyBindingStore = new RealmKeyBindingStore(realm, new ReadableKeyCombinationProvider()); + keyBindingStore.Register(testContainer, Enumerable.Empty()); - Assert.That(queryCount(), Is.EqualTo(3)); + Assert.That(queryCount(realm), Is.EqualTo(3)); - Assert.That(queryCount(GlobalAction.Back), Is.EqualTo(1)); - Assert.That(queryCount(GlobalAction.Select), Is.EqualTo(2)); + Assert.That(queryCount(realm, GlobalAction.Back), Is.EqualTo(1)); + Assert.That(queryCount(realm, GlobalAction.Select), Is.EqualTo(2)); + }); } [Test] public void TestDefaultsPopulationRemovesExcess() { - Assert.That(queryCount(), Is.EqualTo(0)); - - KeyBindingContainer testContainer = new TestKeyBindingContainer(); - - // Add some excess bindings for an action which only supports 1. - realm.Write(r => + RunTestWithRealm((realm, _) => { - r.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.A))); - r.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.S))); - r.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.D))); + Assert.That(queryCount(realm), Is.EqualTo(0)); + + KeyBindingContainer testContainer = new TestKeyBindingContainer(); + + // Add some excess bindings for an action which only supports 1. + realm.Write(r => + { + r.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.A))); + r.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.S))); + r.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.D))); + }); + + Assert.That(queryCount(realm, GlobalAction.Back), Is.EqualTo(3)); + + var keyBindingStore = new RealmKeyBindingStore(realm, new ReadableKeyCombinationProvider()); + keyBindingStore.Register(testContainer, Enumerable.Empty()); + + Assert.That(queryCount(realm, GlobalAction.Back), Is.EqualTo(1)); }); - - Assert.That(queryCount(GlobalAction.Back), Is.EqualTo(3)); - - keyBindingStore.Register(testContainer, Enumerable.Empty()); - - Assert.That(queryCount(GlobalAction.Back), Is.EqualTo(1)); } - private int queryCount(GlobalAction? match = null) + [Test] + public void TestUpdateViaQueriedReference() + { + RunTestWithRealm((realm, _) => + { + KeyBindingContainer testContainer = new TestKeyBindingContainer(); + + var keyBindingStore = new RealmKeyBindingStore(realm, new ReadableKeyCombinationProvider()); + keyBindingStore.Register(testContainer, Enumerable.Empty()); + + realm.Run(outerRealm => + { + var backBinding = outerRealm.All().Single(k => k.ActionInt == (int)GlobalAction.Back); + + Assert.That(backBinding.KeyCombination.Keys, Is.EquivalentTo(new[] { InputKey.Escape })); + + var tsr = ThreadSafeReference.Create(backBinding); + + realm.Run(innerRealm => + { + var binding = innerRealm.ResolveReference(tsr)!; + innerRealm.Write(() => binding.KeyCombination = new KeyCombination(InputKey.BackSpace)); + }); + + Assert.That(backBinding.KeyCombination.Keys, Is.EquivalentTo(new[] { InputKey.BackSpace })); + + // check still correct after re-query. + backBinding = outerRealm.All().Single(k => k.ActionInt == (int)GlobalAction.Back); + Assert.That(backBinding.KeyCombination.Keys, Is.EquivalentTo(new[] { InputKey.BackSpace })); + }); + }); + } + + private static int queryCount(RealmAccess realm, GlobalAction? match = null) { return realm.Run(r => { @@ -87,42 +108,6 @@ namespace osu.Game.Tests.Database }); } - [Test] - public void TestUpdateViaQueriedReference() - { - KeyBindingContainer testContainer = new TestKeyBindingContainer(); - - keyBindingStore.Register(testContainer, Enumerable.Empty()); - - realm.Run(outerRealm => - { - var backBinding = outerRealm.All().Single(k => k.ActionInt == (int)GlobalAction.Back); - - Assert.That(backBinding.KeyCombination.Keys, Is.EquivalentTo(new[] { InputKey.Escape })); - - var tsr = ThreadSafeReference.Create(backBinding); - - realm.Run(innerRealm => - { - var binding = innerRealm.ResolveReference(tsr)!; - innerRealm.Write(() => binding.KeyCombination = new KeyCombination(InputKey.BackSpace)); - }); - - Assert.That(backBinding.KeyCombination.Keys, Is.EquivalentTo(new[] { InputKey.BackSpace })); - - // check still correct after re-query. - backBinding = outerRealm.All().Single(k => k.ActionInt == (int)GlobalAction.Back); - Assert.That(backBinding.KeyCombination.Keys, Is.EquivalentTo(new[] { InputKey.BackSpace })); - }); - } - - [TearDown] - public void TearDown() - { - realm.Dispose(); - storage.DeleteDirectory(string.Empty); - } - public partial class TestKeyBindingContainer : KeyBindingContainer { public override IEnumerable DefaultKeyBindings => diff --git a/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs b/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs index 9774a8ebb6..ac04f6c4ff 100644 --- a/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckAudioInVideoTest.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Checks; @@ -44,7 +45,7 @@ namespace osu.Game.Tests.Editing.Checks public void TestRegularVideoFile() { using (var resourceStream = TestResources.OpenResource("Videos/test-video.mp4")) - Assert.IsEmpty(check.Run(getContext(resourceStream))); + ClassicAssert.IsEmpty(check.Run(getContext(resourceStream))); } [Test] @@ -88,7 +89,7 @@ namespace osu.Game.Tests.Editing.Checks var layer = storyboard.GetLayer("Video"); layer.Add(new StoryboardVideo("abc123.mp4", 0)); - var mockWorkingBeatmap = new Mock(beatmap, null, null); + var mockWorkingBeatmap = new Mock(beatmap, null!, null!); mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); mockWorkingBeatmap.As().SetupGet(w => w.Storyboard).Returns(storyboard); diff --git a/osu.Game.Tests/Editing/Checks/CheckDelayedHitsoundsTest.cs b/osu.Game.Tests/Editing/Checks/CheckDelayedHitsoundsTest.cs index 20b9643ab4..1cc89587a2 100644 --- a/osu.Game.Tests/Editing/Checks/CheckDelayedHitsoundsTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckDelayedHitsoundsTest.cs @@ -6,6 +6,7 @@ using System.Linq; using ManagedBass; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Models; using osu.Game.Rulesets.Edit; @@ -49,7 +50,7 @@ namespace osu.Game.Tests.Editing.Checks public void TestNoDelayedHitsounds() { using var resourceStream = TestResources.OpenResource("Samples/hitsound-no-delay.wav"); - Assert.IsEmpty(check.Run(getContext(resourceStream))); + ClassicAssert.IsEmpty(check.Run(getContext(resourceStream))); } [Test] @@ -96,7 +97,7 @@ namespace osu.Game.Tests.Editing.Checks private BeatmapVerifierContext getContext(Stream? resourceStream) { - var mockWorkingBeatmap = new Mock(beatmap, null, null); + var mockWorkingBeatmap = new Mock(beatmap, null!, null!); mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); return new BeatmapVerifierContext(beatmap, mockWorkingBeatmap.Object); diff --git a/osu.Game.Tests/Editing/Checks/CheckHitsoundsFormatTest.cs b/osu.Game.Tests/Editing/Checks/CheckHitsoundsFormatTest.cs index 6da391aa8d..0a6e045592 100644 --- a/osu.Game.Tests/Editing/Checks/CheckHitsoundsFormatTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckHitsoundsFormatTest.cs @@ -139,7 +139,7 @@ namespace osu.Game.Tests.Editing.Checks Metadata = new BeatmapMetadata { AudioFile = beatmapSet.Files[0].Filename } } }; - var firstWorking = new Mock(firstPlayable, null, null); + var firstWorking = new Mock(firstPlayable, null!, null!); firstWorking.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); var secondPlayable = new Beatmap @@ -150,7 +150,7 @@ namespace osu.Game.Tests.Editing.Checks Metadata = new BeatmapMetadata { AudioFile = beatmapSet.Files[1].Filename } } }; - var secondWorking = new Mock(secondPlayable, null, null); + var secondWorking = new Mock(secondPlayable, null!, null!); secondWorking.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); var context = new BeatmapVerifierContext( @@ -165,7 +165,7 @@ namespace osu.Game.Tests.Editing.Checks private BeatmapVerifierContext getContext(Stream? resourceStream) { - var mockWorkingBeatmap = new Mock(beatmap, null, null); + var mockWorkingBeatmap = new Mock(beatmap, null!, null!); mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); return new BeatmapVerifierContext(beatmap, mockWorkingBeatmap.Object); diff --git a/osu.Game.Tests/Editing/Checks/CheckSongFormatTest.cs b/osu.Game.Tests/Editing/Checks/CheckSongFormatTest.cs index 98a4e1f9e9..aab634a47f 100644 --- a/osu.Game.Tests/Editing/Checks/CheckSongFormatTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckSongFormatTest.cs @@ -103,7 +103,7 @@ namespace osu.Game.Tests.Editing.Checks private BeatmapVerifierContext getContext(Stream? resourceStream) { - var mockWorkingBeatmap = new Mock(beatmap, null, null); + var mockWorkingBeatmap = new Mock(beatmap, null!, null!); mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); return new BeatmapVerifierContext(beatmap, mockWorkingBeatmap.Object); diff --git a/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs b/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs index b646e63955..5ff786825b 100644 --- a/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckTooShortAudioFilesTest.cs @@ -7,6 +7,7 @@ using System.Linq; using ManagedBass; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Checks; @@ -52,7 +53,7 @@ namespace osu.Game.Tests.Editing.Checks beatmap.BeatmapInfo.BeatmapSet.Files.Add(CheckTestHelpers.CreateMockFile("jpg")); // Should fail to load, but not produce an error due to the extension not being expected to load. - Assert.IsEmpty(check.Run(getContext(null))); + ClassicAssert.IsEmpty(check.Run(getContext(null))); } [Test] @@ -60,7 +61,7 @@ namespace osu.Game.Tests.Editing.Checks { using (var resourceStream = TestResources.OpenResource("Samples/test-sample.mp3")) { - Assert.IsEmpty(check.Run(getContext(resourceStream))); + ClassicAssert.IsEmpty(check.Run(getContext(resourceStream))); } } @@ -70,7 +71,7 @@ namespace osu.Game.Tests.Editing.Checks using (var resourceStream = TestResources.OpenResource("Samples/blank.wav")) { // This is a 0 ms duration audio file, commonly used to silence sliderslides/ticks, and so should be fine. - Assert.IsEmpty(check.Run(getContext(resourceStream))); + ClassicAssert.IsEmpty(check.Run(getContext(resourceStream))); } } @@ -91,13 +92,13 @@ namespace osu.Game.Tests.Editing.Checks { using (var resourceStream = TestResources.OpenResource("Samples/missing.mp3")) { - Assert.IsEmpty(check.Run(getContext(resourceStream))); + ClassicAssert.IsEmpty(check.Run(getContext(resourceStream))); } } private BeatmapVerifierContext getContext(Stream? resourceStream) { - var mockWorkingBeatmap = new Mock(beatmap, null, null); + var mockWorkingBeatmap = new Mock(beatmap, null!, null!); mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); return new BeatmapVerifierContext(beatmap, mockWorkingBeatmap.Object); diff --git a/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs b/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs index 1e16c67aab..3241e489f8 100644 --- a/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs @@ -79,7 +79,7 @@ namespace osu.Game.Tests.Editing.Checks var layer = storyboard.GetLayer("Video"); layer.Add(new StoryboardVideo("abc123.mp4", 0)); - var mockWorkingBeatmap = new Mock(beatmap, null, null); + var mockWorkingBeatmap = new Mock(beatmap, null!, null!); mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); mockWorkingBeatmap.As().SetupGet(w => w.Storyboard).Returns(storyboard); diff --git a/osu.Game.Tests/Editing/Checks/CheckZeroByteFilesTest.cs b/osu.Game.Tests/Editing/Checks/CheckZeroByteFilesTest.cs index a39ef22b72..1235292511 100644 --- a/osu.Game.Tests/Editing/Checks/CheckZeroByteFilesTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckZeroByteFilesTest.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Checks; @@ -40,7 +41,7 @@ namespace osu.Game.Tests.Editing.Checks [Test] public void TestNonZeroBytes() { - Assert.IsEmpty(check.Run(getContext(byteLength: 44))); + ClassicAssert.IsEmpty(check.Run(getContext(byteLength: 44))); } [Test] @@ -55,7 +56,7 @@ namespace osu.Game.Tests.Editing.Checks [Test] public void TestMissing() { - Assert.IsEmpty(check.Run(getContextMissing())); + ClassicAssert.IsEmpty(check.Run(getContextMissing())); } private BeatmapVerifierContext getContext(long byteLength) diff --git a/osu.Game.Tests/ImportTest.cs b/osu.Game.Tests/ImportTest.cs index b1e2730703..4272e34d07 100644 --- a/osu.Game.Tests/ImportTest.cs +++ b/osu.Game.Tests/ImportTest.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Platform; @@ -42,7 +43,7 @@ namespace osu.Game.Tests while (!result()) Thread.Sleep(200); }); - Assert.IsTrue(task.Wait(timeout), failureMessage); + ClassicAssert.True(task.Wait(timeout), failureMessage); } public partial class TestOsuGameBase : OsuGameBase diff --git a/osu.Game.Tests/Localisation/BeatmapMetadataRomanisationTest.cs b/osu.Game.Tests/Localisation/BeatmapMetadataRomanisationTest.cs index 9926acf772..0a4a4e50a7 100644 --- a/osu.Game.Tests/Localisation/BeatmapMetadataRomanisationTest.cs +++ b/osu.Game.Tests/Localisation/BeatmapMetadataRomanisationTest.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; namespace osu.Game.Tests.Localisation @@ -21,8 +22,8 @@ namespace osu.Game.Tests.Localisation }; var romanisableString = metadata.GetDisplayTitleRomanisable(); - Assert.AreEqual(metadata.ToString(), romanisableString.Romanised); - Assert.AreEqual($"{metadata.ArtistUnicode} - {metadata.TitleUnicode}", romanisableString.Original); + ClassicAssert.AreEqual(metadata.ToString(), romanisableString.Romanised); + ClassicAssert.AreEqual($"{metadata.ArtistUnicode} - {metadata.TitleUnicode}", romanisableString.Original); } [Test] @@ -35,7 +36,7 @@ namespace osu.Game.Tests.Localisation }; var romanisableString = metadata.GetDisplayTitleRomanisable(); - Assert.AreEqual(romanisableString.Romanised, romanisableString.Original); + ClassicAssert.AreEqual(romanisableString.Romanised, romanisableString.Original); } } } diff --git a/osu.Game.Tests/Mods/ModUtilsTest.cs b/osu.Game.Tests/Mods/ModUtilsTest.cs index 6ec4e799e6..b05b4c00b9 100644 --- a/osu.Game.Tests/Mods/ModUtilsTest.cs +++ b/osu.Game.Tests/Mods/ModUtilsTest.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Localisation; using osu.Game.Online.Rooms; @@ -196,7 +197,7 @@ namespace osu.Game.Tests.Mods Assert.That(isValid, Is.EqualTo(expectedInvalid.Length == 0)); if (isValid) - Assert.IsNull(invalid); + ClassicAssert.Null(invalid); else Assert.That(invalid?.Select(t => t.GetType()), Is.EquivalentTo(expectedInvalid)); } @@ -214,21 +215,21 @@ namespace osu.Game.Tests.Mods [Test] public void TestFormatScoreMultiplier() { - Assert.AreEqual(ModUtils.FormatScoreMultiplier(0.9999).ToString(), "0.99x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.0).ToString(), "1.00x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.0001).ToString(), "1.01x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(0.9999).ToString(), "0.99x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.0).ToString(), "1.00x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.0001).ToString(), "1.01x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(0.899999999999999).ToString(), "0.90x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(0.9).ToString(), "0.90x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(0.900000000000001).ToString(), "0.90x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(0.899999999999999).ToString(), "0.90x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(0.9).ToString(), "0.90x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(0.900000000000001).ToString(), "0.90x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.099999999999999).ToString(), "1.10x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.1).ToString(), "1.10x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.100000000000001).ToString(), "1.10x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.099999999999999).ToString(), "1.10x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.1).ToString(), "1.10x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.100000000000001).ToString(), "1.10x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.045).ToString(), "1.05x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.05).ToString(), "1.05x"); - Assert.AreEqual(ModUtils.FormatScoreMultiplier(1.055).ToString(), "1.06x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.045).ToString(), "1.05x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.05).ToString(), "1.05x"); + ClassicAssert.AreEqual(ModUtils.FormatScoreMultiplier(1.055).ToString(), "1.06x"); } private static readonly object[] multiplayer_mod_test_scenarios = @@ -309,7 +310,7 @@ namespace osu.Game.Tests.Mods Assert.That(isValid, Is.EqualTo(scenario.InvalidTypes.Length == 0)); if (isValid) - Assert.IsNull(invalidMods); + ClassicAssert.Null(invalidMods); else Assert.That(invalidMods?.Select(t => t.GetType()), Is.EquivalentTo(scenario.InvalidTypes)); } @@ -318,12 +319,12 @@ namespace osu.Game.Tests.Mods public void TestPlaylistsModScenarios() { // The rest are tested by TestMultiplayerModScenarios. - Assert.IsTrue(ModUtils.IsValidModForMatch(new OsuModHardRock(), false, MatchType.Playlists, false)); - Assert.IsTrue(ModUtils.IsValidModForMatch(new OsuModHardRock(), true, MatchType.Playlists, false)); - Assert.IsTrue(ModUtils.IsValidModForMatch(new OsuModDoubleTime(), false, MatchType.Playlists, false)); - Assert.IsTrue(ModUtils.IsValidModForMatch(new OsuModDoubleTime(), true, MatchType.Playlists, false)); - Assert.IsTrue(ModUtils.IsValidModForMatch(new ModAdaptiveSpeed(), false, MatchType.Playlists, false)); - Assert.IsTrue(ModUtils.IsValidModForMatch(new ModAdaptiveSpeed(), true, MatchType.Playlists, false)); + ClassicAssert.True(ModUtils.IsValidModForMatch(new OsuModHardRock(), false, MatchType.Playlists, false)); + ClassicAssert.True(ModUtils.IsValidModForMatch(new OsuModHardRock(), true, MatchType.Playlists, false)); + ClassicAssert.True(ModUtils.IsValidModForMatch(new OsuModDoubleTime(), false, MatchType.Playlists, false)); + ClassicAssert.True(ModUtils.IsValidModForMatch(new OsuModDoubleTime(), true, MatchType.Playlists, false)); + ClassicAssert.True(ModUtils.IsValidModForMatch(new ModAdaptiveSpeed(), false, MatchType.Playlists, false)); + ClassicAssert.True(ModUtils.IsValidModForMatch(new ModAdaptiveSpeed(), true, MatchType.Playlists, false)); } [Test] diff --git a/osu.Game.Tests/NonVisual/BarLineGeneratorTest.cs b/osu.Game.Tests/NonVisual/BarLineGeneratorTest.cs index 0f5c13ca0e..e3be681a91 100644 --- a/osu.Game.Tests/NonVisual/BarLineGeneratorTest.cs +++ b/osu.Game.Tests/NonVisual/BarLineGeneratorTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; @@ -54,13 +55,13 @@ namespace osu.Game.Tests.NonVisual // every seventh bar's start time should be at least greater than the whole number we expect. // It cannot be less, as that can affect overlapping scroll algorithms // (the previous timing point might be chosen incorrectly if this is not the case) - Assert.GreaterOrEqual(barLine.StartTime, expectedTime); + ClassicAssert.GreaterOrEqual(barLine.StartTime, expectedTime); // on the other side, make sure we don't stray too far from the expected time either. - Assert.IsTrue(Precision.AlmostEquals(barLine.StartTime, expectedTime)); + ClassicAssert.True(Precision.AlmostEquals(barLine.StartTime, expectedTime)); // check major/minor lines for good measure too - Assert.AreEqual(i % signature.Numerator == 0, barLine.Major); + ClassicAssert.AreEqual(i % signature.Numerator == 0, barLine.Major); } } diff --git a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs index a229331ef0..574d07ec02 100644 --- a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs +++ b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs @@ -6,6 +6,7 @@ using System; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Extensions; using osu.Game.Models; @@ -22,8 +23,8 @@ namespace osu.Game.Tests.NonVisual var ourInfo = new BeatmapSetInfo { OnlineID = 123 }; var otherInfo = new BeatmapSetInfo { OnlineID = 123 }; - Assert.AreNotEqual(ourInfo, otherInfo); - Assert.IsTrue(ourInfo.MatchesOnlineID(otherInfo)); + ClassicAssert.AreNotEqual(ourInfo, otherInfo); + ClassicAssert.True(ourInfo.MatchesOnlineID(otherInfo)); } [Test] @@ -32,8 +33,8 @@ namespace osu.Game.Tests.NonVisual var beatmapSetA = TestResources.CreateTestBeatmapSetInfo(1); var beatmapSetB = TestResources.CreateTestBeatmapSetInfo(1); - Assert.AreNotEqual(beatmapSetA, beatmapSetB); - Assert.IsTrue(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); + ClassicAssert.AreNotEqual(beatmapSetA, beatmapSetB); + ClassicAssert.True(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); } [Test] @@ -49,8 +50,8 @@ namespace osu.Game.Tests.NonVisual addAudioFile(beatmapSetA, "abc", "AuDiO.mP3"); addAudioFile(beatmapSetB, "abc", "audio.mp3"); - Assert.AreNotEqual(beatmapSetA, beatmapSetB); - Assert.IsTrue(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); + ClassicAssert.AreNotEqual(beatmapSetA, beatmapSetB); + ClassicAssert.True(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); } [Test] @@ -62,8 +63,8 @@ namespace osu.Game.Tests.NonVisual addAudioFile(beatmapSetA, "abc"); addAudioFile(beatmapSetB, "abc"); - Assert.AreNotEqual(beatmapSetA, beatmapSetB); - Assert.IsTrue(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); + ClassicAssert.AreNotEqual(beatmapSetA, beatmapSetB); + ClassicAssert.True(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); } [Test] @@ -75,8 +76,8 @@ namespace osu.Game.Tests.NonVisual addAudioFile(beatmapSetA); addAudioFile(beatmapSetB); - Assert.AreNotEqual(beatmapSetA, beatmapSetB); - Assert.IsTrue(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); + ClassicAssert.AreNotEqual(beatmapSetA, beatmapSetB); + ClassicAssert.True(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single())); } [Test] @@ -89,8 +90,8 @@ namespace osu.Game.Tests.NonVisual var beatmap1 = beatmapSet.Beatmaps.First(); var beatmap2 = beatmapSet.Beatmaps.Last(); - Assert.AreNotEqual(beatmap1, beatmap2); - Assert.IsTrue(beatmap1.AudioEquals(beatmap2)); + ClassicAssert.AreNotEqual(beatmap1, beatmap2); + ClassicAssert.True(beatmap1.AudioEquals(beatmap2)); } [Test] @@ -107,12 +108,12 @@ namespace osu.Game.Tests.NonVisual var beatmap1 = beatmapSet.Beatmaps.First(); var beatmap2 = beatmapSet.Beatmaps.Last(); - Assert.AreNotEqual(beatmap1, beatmap2); + ClassicAssert.AreNotEqual(beatmap1, beatmap2); beatmap1.Metadata.AudioFile = filename1; beatmap2.Metadata.AudioFile = filename2; - Assert.IsFalse(beatmap1.AudioEquals(beatmap2)); + ClassicAssert.False(beatmap1.AudioEquals(beatmap2)); } private static void addAudioFile(BeatmapSetInfo beatmapSetInfo, string hash = null, string filename = null) @@ -128,7 +129,7 @@ namespace osu.Game.Tests.NonVisual var ourInfo = new BeatmapSetInfo { ID = guid }; var otherInfo = new BeatmapSetInfo { ID = guid }; - Assert.AreEqual(ourInfo, otherInfo); + ClassicAssert.AreEqual(ourInfo, otherInfo); } [Test] @@ -137,8 +138,8 @@ namespace osu.Game.Tests.NonVisual var ourInfo = new BeatmapSetInfo { ID = Guid.NewGuid(), OnlineID = 12 }; var otherInfo = new BeatmapSetInfo { OnlineID = 12 }; - Assert.AreNotEqual(ourInfo, otherInfo); - Assert.IsTrue(ourInfo.MatchesOnlineID(otherInfo)); + ClassicAssert.AreNotEqual(ourInfo, otherInfo); + ClassicAssert.True(ourInfo.MatchesOnlineID(otherInfo)); } [Test] @@ -147,7 +148,7 @@ namespace osu.Game.Tests.NonVisual var ourInfo = new BeatmapSetInfo { Hash = "1" }; var otherInfo = new BeatmapSetInfo { Hash = "2" }; - Assert.AreNotEqual(ourInfo, otherInfo); + ClassicAssert.AreNotEqual(ourInfo, otherInfo); } } } diff --git a/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs b/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs index a563bcd865..0da3041887 100644 --- a/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs +++ b/osu.Game.Tests/NonVisual/ClosestBeatDivisorTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Objects; @@ -97,7 +98,7 @@ namespace osu.Game.Tests.NonVisual }; for (int i = 0; i < divisors.Count; ++i) - Assert.AreEqual(closestDivisors[i], beatmap.ControlPointInfo.GetClosestBeatDivisor(beatmap.HitObjects[i].StartTime), $"at index {i}"); + ClassicAssert.AreEqual(closestDivisors[i], beatmap.ControlPointInfo.GetClosestBeatDivisor(beatmap.HitObjects[i].StartTime), $"at index {i}"); } } } diff --git a/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs b/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs index 6b1b883ce7..90671093a5 100644 --- a/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs +++ b/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; @@ -141,7 +142,7 @@ namespace osu.Game.Tests.NonVisual private void assertCombinations(Type[][] expectedCombinations, Mod[] actualCombinations) { - Assert.AreEqual(expectedCombinations.Length, actualCombinations.Length); + ClassicAssert.AreEqual(expectedCombinations.Length, actualCombinations.Length); Assert.Multiple(() => { diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs index 5455963ff8..eb75f75dee 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets; @@ -61,7 +62,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var criteria = new FilterCriteria(); var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.IsFalse(carouselItem.Filtered.Value); + ClassicAssert.False(carouselItem.Filtered.Value); } [Test] @@ -74,7 +75,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.IsTrue(carouselItem.Filtered.Value); + ClassicAssert.True(carouselItem.Filtered.Value); } [Test] @@ -88,7 +89,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.IsFalse(carouselItem.Filtered.Value); + ClassicAssert.False(carouselItem.Filtered.Value); } [Test] @@ -102,7 +103,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.IsFalse(carouselItem.Filtered.Value); + ClassicAssert.False(carouselItem.Filtered.Value); } [Test] @@ -123,7 +124,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(!inclusive, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(!inclusive, carouselItem.Filtered.Value); } [Test] @@ -144,7 +145,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(!inclusive, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(!inclusive, carouselItem.Filtered.Value); } [Test] @@ -166,7 +167,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -195,7 +196,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -215,7 +216,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -236,7 +237,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -260,7 +261,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -278,7 +279,7 @@ namespace osu.Game.Tests.NonVisual.Filtering }; var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [TestCase("202010", true)] @@ -295,7 +296,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -312,7 +313,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.True(carouselItem.Filtered.Value); + ClassicAssert.True(carouselItem.Filtered.Value); } [TestCase("simple", false)] @@ -327,7 +328,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(filtered, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(filtered, carouselItem.Filtered.Value); } [Test] @@ -345,7 +346,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(false, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(false, carouselItem.Filtered.Value); } [Test] @@ -363,7 +364,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(true, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(true, carouselItem.Filtered.Value); } [Test] @@ -380,7 +381,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(true, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(true, carouselItem.Filtered.Value); } [Test] @@ -398,7 +399,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(true, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(true, carouselItem.Filtered.Value); } [Test] @@ -410,7 +411,7 @@ namespace osu.Game.Tests.NonVisual.Filtering carouselItem.BeatmapInfo.Metadata.UserTags.Clear(); carouselItem.Filter(criteria); - Assert.True(carouselItem.Filtered.Value); + ClassicAssert.True(carouselItem.Filtered.Value); } [Test] @@ -423,7 +424,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var carouselItem = new CarouselBeatmap(beatmap); carouselItem.Filter(criteria); - Assert.AreEqual(matchCustomCriteria == false, carouselItem.Filtered.Value); + ClassicAssert.AreEqual(matchCustomCriteria == false, carouselItem.Filtered.Value); } [TestCase("title!=Title", new[] { 2, 4, 6 })] diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index 6a87cc1207..09f85a7def 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets.Filter; @@ -23,8 +24,8 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "looking for a beatmap"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("looking for a beatmap", filterCriteria.SearchText); - Assert.AreEqual(4, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("looking for a beatmap", filterCriteria.SearchText); + ClassicAssert.AreEqual(4, filterCriteria.SearchTerms.Length); } [Test] @@ -33,8 +34,8 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "looking for \"a beatmap\"! like \"this\""; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("looking for \"a beatmap\"! like \"this\"", filterCriteria.SearchText); - Assert.AreEqual(5, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("looking for \"a beatmap\"! like \"this\"", filterCriteria.SearchText); + ClassicAssert.AreEqual(5, filterCriteria.SearchTerms.Length); Assert.That(filterCriteria.SearchTerms[0].SearchTerm, Is.EqualTo("a beatmap")); Assert.That(filterCriteria.SearchTerms[0].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.FullPhrase)); @@ -58,8 +59,8 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "looking for \"circles!\"!"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("looking for \"circles!\"!", filterCriteria.SearchText); - Assert.AreEqual(3, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("looking for \"circles!\"!", filterCriteria.SearchText); + ClassicAssert.AreEqual(3, filterCriteria.SearchTerms.Length); Assert.That(filterCriteria.SearchTerms[0].SearchTerm, Is.EqualTo("circles!")); Assert.That(filterCriteria.SearchTerms[0].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.FullPhrase)); @@ -77,8 +78,8 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "\"!"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("\"!", filterCriteria.SearchText); - Assert.AreEqual(1, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("\"!", filterCriteria.SearchText); + ClassicAssert.AreEqual(1, filterCriteria.SearchTerms.Length); Assert.That(filterCriteria.SearchTerms[0].SearchTerm, Is.EqualTo("!")); Assert.That(filterCriteria.SearchTerms[0].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase)); @@ -91,11 +92,11 @@ namespace osu.Game.Tests.NonVisual.Filtering string query = $"{variant}<4 easy"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("easy", filterCriteria.SearchText.Trim()); - Assert.AreEqual(1, filterCriteria.SearchTerms.Length); - Assert.IsNotNull(filterCriteria.StarDifficulty.Max); - Assert.AreEqual(filterCriteria.StarDifficulty.Max, 4.00d); - Assert.IsNull(filterCriteria.StarDifficulty.Min); + ClassicAssert.AreEqual("easy", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(1, filterCriteria.SearchTerms.Length); + ClassicAssert.NotNull(filterCriteria.StarDifficulty.Max); + ClassicAssert.AreEqual(filterCriteria.StarDifficulty.Max!, 4.00d); + ClassicAssert.Null(filterCriteria.StarDifficulty.Min); } [Test] @@ -104,9 +105,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "stars>=6"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(filterCriteria.StarDifficulty.Min, 6.00d); - Assert.True(filterCriteria.StarDifficulty.IsLowerInclusive); - Assert.IsNull(filterCriteria.StarDifficulty.Max); + ClassicAssert.AreEqual(filterCriteria.StarDifficulty.Min!, 6.00d); + ClassicAssert.True(filterCriteria.StarDifficulty.IsLowerInclusive); + ClassicAssert.Null(filterCriteria.StarDifficulty.Max); } /* @@ -125,12 +126,12 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "ar>=9 difficult"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("difficult", filterCriteria.SearchText.Trim()); - Assert.AreEqual(1, filterCriteria.SearchTerms.Length); - Assert.IsNotNull(filterCriteria.ApproachRate.Min); - Assert.Greater(filterCriteria.ApproachRate.Min, 8.9f); - Assert.Less(filterCriteria.ApproachRate.Min, 9.0f); - Assert.IsNull(filterCriteria.ApproachRate.Max); + ClassicAssert.AreEqual("difficult", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(1, filterCriteria.SearchTerms.Length); + ClassicAssert.NotNull(filterCriteria.ApproachRate.Min); + ClassicAssert.Greater(filterCriteria.ApproachRate.Min!, 8.9f); + ClassicAssert.Less(filterCriteria.ApproachRate.Min!, 9.0f); + ClassicAssert.Null(filterCriteria.ApproachRate.Max); } [Test] @@ -139,12 +140,12 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "dr>2 quite specific dr<:6"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("quite specific", filterCriteria.SearchText.Trim()); - Assert.AreEqual(2, filterCriteria.SearchTerms.Length); - Assert.Greater(filterCriteria.DrainRate.Min, 2.0f); - Assert.Less(filterCriteria.DrainRate.Min, 2.1f); - Assert.Greater(filterCriteria.DrainRate.Max, 6.0f); - Assert.Less(filterCriteria.DrainRate.Min, 6.1f); + ClassicAssert.AreEqual("quite specific", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(2, filterCriteria.SearchTerms.Length); + ClassicAssert.Greater(filterCriteria.DrainRate.Min!, 2.0f); + ClassicAssert.Less(filterCriteria.DrainRate.Min!, 2.1f); + ClassicAssert.Greater(filterCriteria.DrainRate.Max!, 6.0f); + ClassicAssert.Less(filterCriteria.DrainRate.Min!, 6.1f); } [Test] @@ -153,12 +154,12 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "hp>2 quite specific hp<=6"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("quite specific", filterCriteria.SearchText.Trim()); - Assert.AreEqual(2, filterCriteria.SearchTerms.Length); - Assert.Greater(filterCriteria.DrainRate.Min, 2.0f); - Assert.Less(filterCriteria.DrainRate.Min, 2.1f); - Assert.Greater(filterCriteria.DrainRate.Max, 6.0f); - Assert.Less(filterCriteria.DrainRate.Min, 6.1f); + ClassicAssert.AreEqual("quite specific", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(2, filterCriteria.SearchTerms.Length); + ClassicAssert.Greater(filterCriteria.DrainRate.Min!, 2.0f); + ClassicAssert.Less(filterCriteria.DrainRate.Min!, 2.1f); + ClassicAssert.Greater(filterCriteria.DrainRate.Max!, 6.0f); + ClassicAssert.Less(filterCriteria.DrainRate.Min!, 6.1f); } [Test] @@ -167,12 +168,12 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "od>4 easy od<8"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("easy", filterCriteria.SearchText.Trim()); - Assert.AreEqual(1, filterCriteria.SearchTerms.Length); - Assert.Greater(filterCriteria.OverallDifficulty.Min, 4.0); - Assert.Less(filterCriteria.OverallDifficulty.Min, 4.1); - Assert.Greater(filterCriteria.OverallDifficulty.Max, 7.9); - Assert.Less(filterCriteria.OverallDifficulty.Max, 8.0); + ClassicAssert.AreEqual("easy", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(1, filterCriteria.SearchTerms.Length); + ClassicAssert.Greater(filterCriteria.OverallDifficulty.Min!, 4.0); + ClassicAssert.Less(filterCriteria.OverallDifficulty.Min!, 4.1); + ClassicAssert.Greater(filterCriteria.OverallDifficulty.Max!, 7.9); + ClassicAssert.Less(filterCriteria.OverallDifficulty.Max!, 8.0); } [Test] @@ -181,8 +182,8 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "bpm=200"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(filterCriteria.BPM.Min, 199.5d); - Assert.AreEqual(filterCriteria.BPM.Max, 200.5d); + ClassicAssert.AreEqual(filterCriteria.BPM.Min!, 199.5d); + ClassicAssert.AreEqual(filterCriteria.BPM.Max!, 200.5d); } [Test] @@ -191,11 +192,11 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "bpm>:200 gotta go fast"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("gotta go fast", filterCriteria.SearchText.Trim()); - Assert.AreEqual(3, filterCriteria.SearchTerms.Length); - Assert.IsNotNull(filterCriteria.BPM.Min); - Assert.AreEqual(filterCriteria.BPM.Min, 199.5d); - Assert.IsNull(filterCriteria.BPM.Max); + ClassicAssert.AreEqual("gotta go fast", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(3, filterCriteria.SearchTerms.Length); + ClassicAssert.NotNull(filterCriteria.BPM.Min); + ClassicAssert.AreEqual(filterCriteria.BPM.Min!, 199.5d); + ClassicAssert.Null(filterCriteria.BPM.Max); } private static readonly object[] correct_length_query_examples = @@ -228,10 +229,10 @@ namespace osu.Game.Tests.NonVisual.Filtering string query = $"length={lengthQuery} time"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("time", filterCriteria.SearchText.Trim()); - Assert.AreEqual(1, filterCriteria.SearchTerms.Length); - Assert.AreEqual(expectedLength.TotalMilliseconds - scale.TotalMilliseconds / 2.0, filterCriteria.Length.Min); - Assert.AreEqual(expectedLength.TotalMilliseconds + scale.TotalMilliseconds / 2.0, filterCriteria.Length.Max); + ClassicAssert.AreEqual("time", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(1, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual(expectedLength.TotalMilliseconds - scale.TotalMilliseconds / 2.0, filterCriteria.Length.Min); + ClassicAssert.AreEqual(expectedLength.TotalMilliseconds + scale.TotalMilliseconds / 2.0, filterCriteria.Length.Max); } private static readonly object[] incorrect_length_query_examples = @@ -254,7 +255,7 @@ namespace osu.Game.Tests.NonVisual.Filtering string query = $"length={lengthQuery} time"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(false, filterCriteria.Length.HasFilter); + ClassicAssert.AreEqual(false, filterCriteria.Length.HasFilter); } [Test] @@ -263,12 +264,12 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "that's a time signature alright! divisor:12"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("that's a time signature alright!", filterCriteria.SearchText.Trim()); - Assert.AreEqual(5, filterCriteria.SearchTerms.Length); - Assert.AreEqual(12, filterCriteria.BeatDivisor.Min); - Assert.IsTrue(filterCriteria.BeatDivisor.IsLowerInclusive); - Assert.AreEqual(12, filterCriteria.BeatDivisor.Max); - Assert.IsTrue(filterCriteria.BeatDivisor.IsUpperInclusive); + ClassicAssert.AreEqual("that's a time signature alright!", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(5, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual(12, filterCriteria.BeatDivisor.Min); + ClassicAssert.True(filterCriteria.BeatDivisor.IsLowerInclusive); + ClassicAssert.AreEqual(12, filterCriteria.BeatDivisor.Max); + ClassicAssert.True(filterCriteria.BeatDivisor.IsUpperInclusive); } [Test] @@ -277,7 +278,7 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "status=r"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); + ClassicAssert.IsNotEmpty(filterCriteria.OnlineStatus.Values); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); } @@ -287,9 +288,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "I want the pp status=ranked"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("I want the pp", filterCriteria.SearchText.Trim()); - Assert.AreEqual(4, filterCriteria.SearchTerms.Length); - Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); + ClassicAssert.AreEqual("I want the pp", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(4, filterCriteria.SearchTerms.Length); + ClassicAssert.IsNotEmpty(filterCriteria.OnlineStatus.Values); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); } @@ -308,7 +309,7 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "status!=r"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); + ClassicAssert.IsNotEmpty(filterCriteria.OnlineStatus.Values); Assert.That(filterCriteria.OnlineStatus.Values, Does.Not.Contain(BeatmapOnlineStatus.Ranked)); } @@ -374,9 +375,9 @@ namespace osu.Game.Tests.NonVisual.Filtering string query = $"beatmap specifically by {keyword}=my_fav"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("beatmap specifically by", filterCriteria.SearchText.Trim()); - Assert.AreEqual(3, filterCriteria.SearchTerms.Length); - Assert.AreEqual("my_fav", filterCriteria.Creator.SearchTerm); + ClassicAssert.AreEqual("beatmap specifically by", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(3, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("my_fav", filterCriteria.Creator.SearchTerm); } [Test] @@ -385,9 +386,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "find me songs with title=\"a certain title\" please"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("find me songs with please", filterCriteria.SearchText.Trim()); - Assert.AreEqual(5, filterCriteria.SearchTerms.Length); - Assert.AreEqual("a certain title", filterCriteria.Title.SearchTerm); + ClassicAssert.AreEqual("find me songs with please", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(5, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("a certain title", filterCriteria.Title.SearchTerm); Assert.That(filterCriteria.Title.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase)); } @@ -397,9 +398,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "find me songs by artist=singer please"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("find me songs by please", filterCriteria.SearchText.Trim()); - Assert.AreEqual(5, filterCriteria.SearchTerms.Length); - Assert.AreEqual("singer", filterCriteria.Artist.SearchTerm); + ClassicAssert.AreEqual("find me songs by please", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(5, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("singer", filterCriteria.Artist.SearchTerm); Assert.That(filterCriteria.Artist.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.Substring)); } @@ -409,9 +410,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "really like artist=\"name with space\" yes"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("really like yes", filterCriteria.SearchText.Trim()); - Assert.AreEqual(3, filterCriteria.SearchTerms.Length); - Assert.AreEqual("name with space", filterCriteria.Artist.SearchTerm); + ClassicAssert.AreEqual("really like yes", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(3, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("name with space", filterCriteria.Artist.SearchTerm); Assert.That(filterCriteria.Artist.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase)); } @@ -422,8 +423,8 @@ namespace osu.Game.Tests.NonVisual.Filtering var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.That(filterCriteria.SearchText.Trim(), Is.Empty); - Assert.AreEqual(0, filterCriteria.SearchTerms.Length); - Assert.AreEqual("The Only One", filterCriteria.Artist.SearchTerm); + ClassicAssert.AreEqual(0, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("The Only One", filterCriteria.Artist.SearchTerm); Assert.That(filterCriteria.Artist.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.FullPhrase)); } @@ -433,9 +434,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "weird artist=double\"quote"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual("weird", filterCriteria.SearchText.Trim()); - Assert.AreEqual(1, filterCriteria.SearchTerms.Length); - Assert.AreEqual("double\"quote", filterCriteria.Artist.SearchTerm); + ClassicAssert.AreEqual("weird", filterCriteria.SearchText.Trim()); + ClassicAssert.AreEqual(1, filterCriteria.SearchTerms.Length); + ClassicAssert.AreEqual("double\"quote", filterCriteria.Artist.SearchTerm); } [Test] @@ -444,7 +445,7 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "artist=> @@ -706,8 +707,8 @@ namespace osu.Game.Tests.NonVisual.Filtering { var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(true, filterCriteria.DateRanked.HasFilter); - Assert.AreEqual(expected, f(filterCriteria)); + ClassicAssert.AreEqual(true, filterCriteria.DateRanked.HasFilter); + ClassicAssert.AreEqual(expected, f(filterCriteria)); } private static readonly object[] ranked_date_invalid_test_cases = @@ -723,7 +724,7 @@ namespace osu.Game.Tests.NonVisual.Filtering { var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(false, filterCriteria.DateRanked.HasFilter); + ClassicAssert.AreEqual(false, filterCriteria.DateRanked.HasFilter); } private static readonly object[] submitted_date_test_cases = @@ -755,7 +756,7 @@ namespace osu.Game.Tests.NonVisual.Filtering { var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(expected, filterCriteria.DateSubmitted.HasFilter); + ClassicAssert.AreEqual(expected, filterCriteria.DateSubmitted.HasFilter); } private static readonly object[] played_query_tests = @@ -781,8 +782,8 @@ namespace osu.Game.Tests.NonVisual.Filtering { var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, $"played={query}"); - Assert.AreEqual(true, filterCriteria.LastPlayed.HasFilter); - Assert.AreEqual(matched, filterCriteria.LastPlayed.IsInRange(reference)); + ClassicAssert.AreEqual(true, filterCriteria.LastPlayed.HasFilter); + ClassicAssert.AreEqual(matched, filterCriteria.LastPlayed.IsInRange(reference)); } [Test] diff --git a/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs b/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs index 69c98351ad..174d14d226 100644 --- a/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs +++ b/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Audio; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Judgements; @@ -37,7 +38,7 @@ namespace osu.Game.Tests.NonVisual testObject.AddNested(nested); testDrawableRuleset.HitObjects = new List { testObject }; - Assert.AreSame(testDrawableRuleset.FirstAvailableHitWindows, nested.HitWindows); + ClassicAssert.AreSame(testDrawableRuleset.FirstAvailableHitWindows, nested.HitWindows); } [Test] @@ -48,7 +49,7 @@ namespace osu.Game.Tests.NonVisual testObject.AddNested(nested); testDrawableRuleset.HitObjects = new List { testObject }; - Assert.AreSame(testDrawableRuleset.FirstAvailableHitWindows, testObject.HitWindows); + ClassicAssert.AreSame(testDrawableRuleset.FirstAvailableHitWindows, testObject.HitWindows); } [Test] @@ -61,7 +62,7 @@ namespace osu.Game.Tests.NonVisual var secondObject = new TestHitObject(new DefaultHitWindows()); testDrawableRuleset.HitObjects = new List { firstObject, secondObject }; - Assert.AreSame(testDrawableRuleset.FirstAvailableHitWindows, secondObject.HitWindows); + ClassicAssert.AreSame(testDrawableRuleset.FirstAvailableHitWindows, secondObject.HitWindows); } [Test] @@ -73,7 +74,7 @@ namespace osu.Game.Tests.NonVisual testDrawableRuleset.HitObjects = new List { firstObject }; - Assert.IsNull(testDrawableRuleset.FirstAvailableHitWindows); + ClassicAssert.Null(testDrawableRuleset.FirstAvailableHitWindows); } [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] diff --git a/osu.Game.Tests/NonVisual/FormatUtilsTest.cs b/osu.Game.Tests/NonVisual/FormatUtilsTest.cs index 0fcf754cf6..169639f1d3 100644 --- a/osu.Game.Tests/NonVisual/FormatUtilsTest.cs +++ b/osu.Game.Tests/NonVisual/FormatUtilsTest.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Utils; namespace osu.Game.Tests.NonVisual @@ -19,7 +20,7 @@ namespace osu.Game.Tests.NonVisual [TestCase(1, "100.00%")] public void TestAccuracyFormatting(double input, string expectedOutput) { - Assert.AreEqual(expectedOutput, input.FormatAccuracy().ToString()); + ClassicAssert.AreEqual(expectedOutput, input.FormatAccuracy().ToString()); } [TestCase(3, "3.00")] @@ -32,7 +33,7 @@ namespace osu.Game.Tests.NonVisual [TestCase(4, "4.00")] public void TestStarRatingFormatting(double input, string expectedOutput) { - Assert.AreEqual(expectedOutput, input.FormatStarRating().ToString()); + ClassicAssert.AreEqual(expectedOutput, input.FormatStarRating().ToString()); } } } diff --git a/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs b/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs index ffb21f124c..0bfca14c9a 100644 --- a/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs +++ b/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Replays; using osu.Game.Rulesets.Replays; @@ -223,7 +224,7 @@ namespace osu.Game.Tests.NonVisual // no frames are arrived yet setTime(0, null); setTime(1000, null); - Assert.IsTrue(handler.WaitingForFrame, "Should be waiting for the first frame"); + ClassicAssert.True(handler.WaitingForFrame, "Should be waiting for the first frame"); replay.Frames.Add(new TestReplayFrame(0)); replay.Frames.Add(new TestReplayFrame(1000)); @@ -231,11 +232,11 @@ namespace osu.Game.Tests.NonVisual // should always play from beginning setTime(1000, 0); confirmCurrentFrame(0); - Assert.IsFalse(handler.WaitingForFrame, "Should not be waiting yet"); + ClassicAssert.False(handler.WaitingForFrame, "Should not be waiting yet"); setTime(1000, 1000); confirmCurrentFrame(1); confirmNextFrame(null); - Assert.IsTrue(handler.WaitingForFrame, "Should be waiting"); + ClassicAssert.True(handler.WaitingForFrame, "Should be waiting"); // cannot seek beyond the last frame setTime(1500, null); @@ -359,17 +360,17 @@ namespace osu.Game.Tests.NonVisual private void setTime(double set, double? expect) { - Assert.AreEqual(expect, handler.SetFrameFromTime(set), "Unexpected return value"); + ClassicAssert.AreEqual(expect, handler.SetFrameFromTime(set), "Unexpected return value"); } private void confirmCurrentFrame(int? frame) { - Assert.AreEqual(frame is int x ? replay.Frames[x].Time : null, handler.CurrentFrame?.Time, "Unexpected current frame"); + ClassicAssert.AreEqual(frame is int x ? replay.Frames[x].Time : null, handler.CurrentFrame?.Time, "Unexpected current frame"); } private void confirmNextFrame(int? frame) { - Assert.AreEqual(frame is int x ? replay.Frames[x].Time : null, handler.NextFrame?.Time, "Unexpected next frame"); + ClassicAssert.AreEqual(frame is int x ? replay.Frames[x].Time : null, handler.NextFrame?.Time, "Unexpected next frame"); } private class TestReplayFrame : ReplayFrame diff --git a/osu.Game.Tests/NonVisual/LimitedCapacityQueueTest.cs b/osu.Game.Tests/NonVisual/LimitedCapacityQueueTest.cs index 8809ce3adc..a33a36f2d9 100644 --- a/osu.Game.Tests/NonVisual/LimitedCapacityQueueTest.cs +++ b/osu.Game.Tests/NonVisual/LimitedCapacityQueueTest.cs @@ -5,6 +5,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Utils; namespace osu.Game.Tests.NonVisual @@ -25,7 +26,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestEmptyQueue() { - Assert.AreEqual(0, queue.Count); + ClassicAssert.AreEqual(0, queue.Count); Assert.Throws(() => _ = queue[0]); @@ -35,7 +36,7 @@ namespace osu.Game.Tests.NonVisual foreach (int _ in queue) count++; - Assert.AreEqual(0, count); + ClassicAssert.AreEqual(0, count); } [TestCase(1)] @@ -46,14 +47,14 @@ namespace osu.Game.Tests.NonVisual for (int i = 0; i < count; ++i) queue.Enqueue(i); - Assert.AreEqual(count, queue.Count); + ClassicAssert.AreEqual(count, queue.Count); for (int i = 0; i < count; ++i) - Assert.AreEqual(i, queue[i]); + ClassicAssert.AreEqual(i, queue[i]); int j = 0; foreach (int item in queue) - Assert.AreEqual(j++, item); + ClassicAssert.AreEqual(j++, item); for (int i = queue.Count; i < queue.Count + capacity; i++) Assert.Throws(() => _ = queue[i]); @@ -67,14 +68,14 @@ namespace osu.Game.Tests.NonVisual for (int i = 0; i < count; ++i) queue.Enqueue(i); - Assert.AreEqual(capacity, queue.Count); + ClassicAssert.AreEqual(capacity, queue.Count); for (int i = 0; i < queue.Count; ++i) - Assert.AreEqual(count - capacity + i, queue[i]); + ClassicAssert.AreEqual(count - capacity + i, queue[i]); int j = count - capacity; foreach (int item in queue) - Assert.AreEqual(j++, item); + ClassicAssert.AreEqual(j++, item); for (int i = queue.Count; i < queue.Count + capacity; i++) Assert.Throws(() => _ = queue[i]); @@ -90,8 +91,8 @@ namespace osu.Game.Tests.NonVisual for (int i = 0; i < capacity; ++i) { - Assert.AreEqual(count - capacity + i, queue.Dequeue()); - Assert.AreEqual(2 - i, queue.Count); + ClassicAssert.AreEqual(count - capacity + i, queue.Dequeue()); + ClassicAssert.AreEqual(2 - i, queue.Count); } Assert.Throws(() => queue.Dequeue()); @@ -102,20 +103,20 @@ namespace osu.Game.Tests.NonVisual { queue.Enqueue(3); queue.Enqueue(5); - Assert.AreEqual(2, queue.Count); + ClassicAssert.AreEqual(2, queue.Count); queue.Clear(); - Assert.AreEqual(0, queue.Count); + ClassicAssert.AreEqual(0, queue.Count); Assert.Throws(() => _ = queue[0]); queue.Enqueue(7); - Assert.AreEqual(1, queue.Count); - Assert.AreEqual(7, queue[0]); + ClassicAssert.AreEqual(1, queue.Count); + ClassicAssert.AreEqual(7, queue[0]); Assert.Throws(() => _ = queue[1]); queue.Enqueue(9); - Assert.AreEqual(2, queue.Count); - Assert.AreEqual(9, queue[1]); + ClassicAssert.AreEqual(2, queue.Count); + ClassicAssert.AreEqual(9, queue[1]); } } } diff --git a/osu.Game.Tests/NonVisual/PeriodTrackerTest.cs b/osu.Game.Tests/NonVisual/PeriodTrackerTest.cs index 664a499cc3..b502aa1782 100644 --- a/osu.Game.Tests/NonVisual/PeriodTrackerTest.cs +++ b/osu.Game.Tests/NonVisual/PeriodTrackerTest.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Utils; using osu.Game.Utils; @@ -28,9 +29,9 @@ namespace osu.Game.Tests.NonVisual var tracker = new PeriodTracker(single_period); var period = single_period.Single(); - Assert.IsTrue(tracker.IsInAny(period.Start)); - Assert.IsTrue(tracker.IsInAny(getMidpoint(period))); - Assert.IsTrue(tracker.IsInAny(period.End)); + ClassicAssert.True(tracker.IsInAny(period.Start)); + ClassicAssert.True(tracker.IsInAny(getMidpoint(period))); + ClassicAssert.True(tracker.IsInAny(period.End)); } [Test] @@ -39,7 +40,7 @@ namespace osu.Game.Tests.NonVisual var tracker = new PeriodTracker(unordered_periods); foreach (var period in unordered_periods) - Assert.IsTrue(tracker.IsInAny(getMidpoint(period))); + ClassicAssert.True(tracker.IsInAny(getMidpoint(period))); } [Test] @@ -48,7 +49,7 @@ namespace osu.Game.Tests.NonVisual var tracker = new PeriodTracker(unordered_periods); foreach (var period in unordered_periods.OrderBy(_ => RNG.Next())) - Assert.IsTrue(tracker.IsInAny(getMidpoint(period))); + ClassicAssert.True(tracker.IsInAny(getMidpoint(period))); } [Test] @@ -60,12 +61,12 @@ namespace osu.Game.Tests.NonVisual new Period(3.0, 4.0) }); - Assert.IsFalse(tracker.IsInAny(0.9), "Time before first period is being considered inside"); + ClassicAssert.False(tracker.IsInAny(0.9), "Time before first period is being considered inside"); - Assert.IsFalse(tracker.IsInAny(2.1), "Time right after first period is being considered inside"); - Assert.IsFalse(tracker.IsInAny(2.9), "Time right before second period is being considered inside"); + ClassicAssert.False(tracker.IsInAny(2.1), "Time right after first period is being considered inside"); + ClassicAssert.False(tracker.IsInAny(2.9), "Time right before second period is being considered inside"); - Assert.IsFalse(tracker.IsInAny(4.1), "Time after last period is being considered inside"); + ClassicAssert.False(tracker.IsInAny(4.1), "Time after last period is being considered inside"); } [Test] diff --git a/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs b/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs index 18ac5b4964..f68f743723 100644 --- a/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs +++ b/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs @@ -6,6 +6,7 @@ using System; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Utils; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; @@ -25,8 +26,8 @@ namespace osu.Game.Tests.NonVisual.Ranking var unstableRate = new UnstableRate(events); - Assert.IsNotNull(unstableRate.Value); - Assert.AreEqual(unstableRate.Value.Value, 10 * Math.Sqrt(10), Precision.DOUBLE_EPSILON); + Assert.That(unstableRate.Value, Is.Not.Null); + ClassicAssert.AreEqual(unstableRate.Value.Value, 10 * Math.Sqrt(10), Precision.DOUBLE_EPSILON); } [Test] @@ -50,8 +51,8 @@ namespace osu.Game.Tests.NonVisual.Ranking result = events.GetRange(0, 2).CalculateUnstableRate(result); - Assert.IsNotNull(result!.Result); - Assert.AreEqual(5, result.Result, Precision.DOUBLE_EPSILON); + ClassicAssert.NotNull(result!.Result); + ClassicAssert.AreEqual(5, result.Result, Precision.DOUBLE_EPSILON); } [Test] @@ -73,8 +74,8 @@ namespace osu.Game.Tests.NonVisual.Ranking .CalculateUnstableRate(result); } - Assert.IsNotNull(result!.Result); - Assert.AreEqual(10 * Math.Sqrt(10), result.Result, Precision.DOUBLE_EPSILON); + ClassicAssert.NotNull(result!.Result); + ClassicAssert.AreEqual(10 * Math.Sqrt(10), result.Result, Precision.DOUBLE_EPSILON); } [Test] @@ -89,7 +90,7 @@ namespace osu.Game.Tests.NonVisual.Ranking var unstableRate = new UnstableRate(events); - Assert.AreEqual(0, unstableRate.Value); + ClassicAssert.AreEqual(0, unstableRate.Value); } [Test] @@ -105,7 +106,7 @@ namespace osu.Game.Tests.NonVisual.Ranking var unstableRate = new UnstableRate(events); - Assert.AreEqual(10 * 100, unstableRate.Value); + ClassicAssert.AreEqual(10 * 100, unstableRate.Value); } [Test] @@ -121,7 +122,7 @@ namespace osu.Game.Tests.NonVisual.Ranking var unstableRate = new UnstableRate(events); - Assert.AreEqual(10 * 100, unstableRate.Value); + ClassicAssert.AreEqual(10 * 100, unstableRate.Value); } } } diff --git a/osu.Game.Tests/NonVisual/ReverseQueueTest.cs b/osu.Game.Tests/NonVisual/ReverseQueueTest.cs index d0ad2e22a4..7b87ba2481 100644 --- a/osu.Game.Tests/NonVisual/ReverseQueueTest.cs +++ b/osu.Game.Tests/NonVisual/ReverseQueueTest.cs @@ -5,6 +5,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Rulesets.Difficulty.Utils; namespace osu.Game.Tests.NonVisual @@ -23,7 +24,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestEmptyQueue() { - Assert.AreEqual(0, queue.Count); + ClassicAssert.AreEqual(0, queue.Count); Assert.Throws(() => { @@ -34,7 +35,7 @@ namespace osu.Game.Tests.NonVisual foreach (char unused in queue) count++; - Assert.AreEqual(0, count); + ClassicAssert.AreEqual(0, count); } [Test] @@ -45,21 +46,21 @@ namespace osu.Game.Tests.NonVisual queue.Enqueue('b'); queue.Enqueue('c'); - Assert.AreEqual('c', queue[0]); - Assert.AreEqual('b', queue[1]); - Assert.AreEqual('a', queue[2]); + ClassicAssert.AreEqual('c', queue[0]); + ClassicAssert.AreEqual('b', queue[1]); + ClassicAssert.AreEqual('a', queue[2]); // Assert correct values and reverse index after enqueueing beyond initial capacity of 4 queue.Enqueue('d'); queue.Enqueue('e'); queue.Enqueue('f'); - Assert.AreEqual('f', queue[0]); - Assert.AreEqual('e', queue[1]); - Assert.AreEqual('d', queue[2]); - Assert.AreEqual('c', queue[3]); - Assert.AreEqual('b', queue[4]); - Assert.AreEqual('a', queue[5]); + ClassicAssert.AreEqual('f', queue[0]); + ClassicAssert.AreEqual('e', queue[1]); + ClassicAssert.AreEqual('d', queue[2]); + ClassicAssert.AreEqual('c', queue[3]); + ClassicAssert.AreEqual('b', queue[4]); + ClassicAssert.AreEqual('a', queue[5]); } [Test] @@ -73,13 +74,13 @@ namespace osu.Game.Tests.NonVisual queue.Enqueue('f'); // Assert correct item return and no longer in queue after dequeueing - Assert.AreEqual('a', queue[5]); + ClassicAssert.AreEqual('a', queue[5]); char dequeuedItem = queue.Dequeue(); - Assert.AreEqual('a', dequeuedItem); - Assert.AreEqual(5, queue.Count); - Assert.AreEqual('f', queue[0]); - Assert.AreEqual('b', queue[4]); + ClassicAssert.AreEqual('a', dequeuedItem); + ClassicAssert.AreEqual(5, queue.Count); + ClassicAssert.AreEqual('f', queue[0]); + ClassicAssert.AreEqual('b', queue[4]); Assert.Throws(() => { char unused = queue[5]; @@ -97,8 +98,8 @@ namespace osu.Game.Tests.NonVisual queue.Dequeue(); queue.Dequeue(); - Assert.AreEqual(1, queue.Count); - Assert.AreEqual('i', queue[0]); + ClassicAssert.AreEqual(1, queue.Count); + ClassicAssert.AreEqual('i', queue[0]); } [Test] @@ -114,7 +115,7 @@ namespace osu.Game.Tests.NonVisual // Assert queue is empty after clearing queue.Clear(); - Assert.AreEqual(0, queue.Count); + ClassicAssert.AreEqual(0, queue.Count); Assert.Throws(() => { char unused = queue[0]; @@ -137,7 +138,7 @@ namespace osu.Game.Tests.NonVisual // Assert items are enumerated in correct order foreach (char item in queue) { - Assert.AreEqual(expectedValues[expectedValueIndex], item); + ClassicAssert.AreEqual(expectedValues[expectedValueIndex], item); expectedValueIndex++; } } diff --git a/osu.Game.Tests/NonVisual/SessionStaticsTest.cs b/osu.Game.Tests/NonVisual/SessionStaticsTest.cs index 5c8254b947..b437c95216 100644 --- a/osu.Game.Tests/NonVisual/SessionStaticsTest.cs +++ b/osu.Game.Tests/NonVisual/SessionStaticsTest.cs @@ -5,6 +5,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Configuration; using osu.Game.Online.API.Requests.Responses; @@ -26,20 +27,20 @@ namespace osu.Game.Tests.NonVisual sessionStatics.SetValue(Static.LastHoverSoundPlaybackTime, (double?)1d); sessionStatics.SetValue(Static.SeasonalBackgrounds, new APISeasonalBackgrounds { EndDate = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero) }); - Assert.IsFalse(sessionStatics.GetBindable(Static.LoginOverlayDisplayed).IsDefault); - Assert.IsFalse(sessionStatics.GetBindable(Static.MutedAudioNotificationShownOnce).IsDefault); - Assert.IsFalse(sessionStatics.GetBindable(Static.LowBatteryNotificationShownOnce).IsDefault); - Assert.IsFalse(sessionStatics.GetBindable(Static.LastHoverSoundPlaybackTime).IsDefault); - Assert.IsFalse(sessionStatics.GetBindable(Static.SeasonalBackgrounds).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.LoginOverlayDisplayed).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.MutedAudioNotificationShownOnce).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.LowBatteryNotificationShownOnce).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.LastHoverSoundPlaybackTime).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.SeasonalBackgrounds).IsDefault); sessionStatics.ResetAfterInactivity(); - Assert.IsTrue(sessionStatics.GetBindable(Static.LoginOverlayDisplayed).IsDefault); - Assert.IsTrue(sessionStatics.GetBindable(Static.MutedAudioNotificationShownOnce).IsDefault); - Assert.IsTrue(sessionStatics.GetBindable(Static.LowBatteryNotificationShownOnce).IsDefault); + ClassicAssert.True(sessionStatics.GetBindable(Static.LoginOverlayDisplayed).IsDefault); + ClassicAssert.True(sessionStatics.GetBindable(Static.MutedAudioNotificationShownOnce).IsDefault); + ClassicAssert.True(sessionStatics.GetBindable(Static.LowBatteryNotificationShownOnce).IsDefault); // some statics should not reset despite inactivity. - Assert.IsFalse(sessionStatics.GetBindable(Static.LastHoverSoundPlaybackTime).IsDefault); - Assert.IsFalse(sessionStatics.GetBindable(Static.SeasonalBackgrounds).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.LastHoverSoundPlaybackTime).IsDefault); + ClassicAssert.False(sessionStatics.GetBindable(Static.SeasonalBackgrounds).IsDefault); } } } diff --git a/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs b/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs index 98cb66a234..2012052dc8 100644 --- a/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs +++ b/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Audio; using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Dummy; @@ -93,9 +94,9 @@ namespace osu.Game.Tests.NonVisual.Skinning var texture = legacySkin.GetTexture(requestedComponent); - Assert.IsNotNull(texture); - Assert.AreEqual(textureStore.Textures[expectedTexture].Width, texture.Width); - Assert.AreEqual(expectedScale, texture.ScaleAdjust); + Assert.That(texture, Is.Not.Null); + ClassicAssert.AreEqual(textureStore.Textures[expectedTexture].Width, texture.Width); + ClassicAssert.AreEqual(expectedScale, texture.ScaleAdjust); } [Test] @@ -106,7 +107,7 @@ namespace osu.Game.Tests.NonVisual.Skinning var texture = legacySkin.GetTexture("Gameplay/osu/followpoint"); - Assert.IsNull(texture); + ClassicAssert.Null(texture); } [Test] @@ -117,15 +118,15 @@ namespace osu.Game.Tests.NonVisual.Skinning var texture = legacySkin.GetTexture("hitcircle"); - Assert.IsNotNull(texture); + Assert.That(texture, Is.Not.Null); Assert.That(texture.ScaleAdjust, Is.EqualTo(1)); var twoTimesTexture = legacySkin.GetTexture("hitcircle@2x"); - Assert.IsNotNull(twoTimesTexture); + Assert.That(twoTimesTexture, Is.Not.Null); Assert.That(twoTimesTexture.ScaleAdjust, Is.EqualTo(1)); - Assert.AreNotEqual(texture, twoTimesTexture); + ClassicAssert.AreNotEqual(texture, twoTimesTexture); } [Test] @@ -136,15 +137,15 @@ namespace osu.Game.Tests.NonVisual.Skinning var texture = legacySkin.GetTexture("hitcircle"); - Assert.IsNotNull(texture); + Assert.That(texture, Is.Not.Null); Assert.That(texture.ScaleAdjust, Is.EqualTo(2)); var twoTimesTexture = legacySkin.GetTexture("hitcircle@2x"); - Assert.IsNotNull(twoTimesTexture); + Assert.That(twoTimesTexture, Is.Not.Null); Assert.That(twoTimesTexture.ScaleAdjust, Is.EqualTo(2)); - Assert.AreEqual(texture, twoTimesTexture); + ClassicAssert.AreEqual(texture, twoTimesTexture); } private class TestLegacySkin : LegacySkin diff --git a/osu.Game.Tests/NonVisual/TimeDisplayExtensionTest.cs b/osu.Game.Tests/NonVisual/TimeDisplayExtensionTest.cs index 10d592364d..374659a48f 100644 --- a/osu.Game.Tests/NonVisual/TimeDisplayExtensionTest.cs +++ b/osu.Game.Tests/NonVisual/TimeDisplayExtensionTest.cs @@ -3,6 +3,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Extensions; namespace osu.Game.Tests.NonVisual @@ -21,7 +22,7 @@ namespace osu.Game.Tests.NonVisual [TestCaseSource(nameof(editor_formatted_duration_tests))] public void TestEditorFormat(TimeSpan input, string expectedOutput) { - Assert.AreEqual(expectedOutput, input.ToEditorFormattedString()); + ClassicAssert.AreEqual(expectedOutput, input.ToEditorFormattedString()); } private static readonly object[][] formatted_duration_tests = @@ -35,7 +36,7 @@ namespace osu.Game.Tests.NonVisual [TestCaseSource(nameof(formatted_duration_tests))] public void TestFormattedDuration(TimeSpan input, string expectedOutput) { - Assert.AreEqual(expectedOutput, input.ToFormattedDuration().ToString()); + ClassicAssert.AreEqual(expectedOutput, input.ToFormattedDuration().ToString()); } } } diff --git a/osu.Game.Tests/Online/Chat/MessageNotifierTest.cs b/osu.Game.Tests/Online/Chat/MessageNotifierTest.cs index a391ec4066..f129accfa3 100644 --- a/osu.Game.Tests/Online/Chat/MessageNotifierTest.cs +++ b/osu.Game.Tests/Online/Chat/MessageNotifierTest.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Online.Chat; namespace osu.Game.Tests.Online.Chat @@ -12,79 +13,79 @@ namespace osu.Game.Tests.Online.Chat [Test] public void TestContainsUsernameMidlinePositive() { - Assert.IsTrue(MessageNotifier.MatchUsername("This is a test message", "Test").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("This is a test message", "Test").Success); } [Test] public void TestContainsUsernameStartOfLinePositive() { - Assert.IsTrue(MessageNotifier.MatchUsername("Test message", "Test").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("Test message", "Test").Success); } [Test] public void TestContainsUsernameEndOfLinePositive() { - Assert.IsTrue(MessageNotifier.MatchUsername("This is a test", "Test").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("This is a test", "Test").Success); } [Test] public void TestContainsUsernameMidlineNegative() { - Assert.IsFalse(MessageNotifier.MatchUsername("This is a testmessage for notifications", "Test").Success); + ClassicAssert.False(MessageNotifier.MatchUsername("This is a testmessage for notifications", "Test").Success); } [Test] public void TestContainsUsernameStartOfLineNegative() { - Assert.IsFalse(MessageNotifier.MatchUsername("Testmessage", "Test").Success); + ClassicAssert.False(MessageNotifier.MatchUsername("Testmessage", "Test").Success); } [Test] public void TestContainsUsernameEndOfLineNegative() { - Assert.IsFalse(MessageNotifier.MatchUsername("This is a notificationtest", "Test").Success); + ClassicAssert.False(MessageNotifier.MatchUsername("This is a notificationtest", "Test").Success); } [Test] public void TestContainsUsernameBetweenPunctuation() { - Assert.IsTrue(MessageNotifier.MatchUsername("Hello 'test'-message", "Test").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("Hello 'test'-message", "Test").Success); } [Test] public void TestContainsUsernameUnicode() { - Assert.IsTrue(MessageNotifier.MatchUsername("Test \u0460\u0460 message", "\u0460\u0460").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("Test \u0460\u0460 message", "\u0460\u0460").Success); } [Test] public void TestContainsUsernameUnicodeNegative() { - Assert.IsFalse(MessageNotifier.MatchUsername("Test ha\u0460\u0460o message", "\u0460\u0460").Success); + ClassicAssert.False(MessageNotifier.MatchUsername("Test ha\u0460\u0460o message", "\u0460\u0460").Success); } [Test] public void TestContainsUsernameSpecialCharactersPositive() { - Assert.IsTrue(MessageNotifier.MatchUsername("Test [#^-^#] message", "[#^-^#]").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("Test [#^-^#] message", "[#^-^#]").Success); } [Test] public void TestContainsUsernameSpecialCharactersNegative() { - Assert.IsFalse(MessageNotifier.MatchUsername("Test pad[#^-^#]oru message", "[#^-^#]").Success); + ClassicAssert.False(MessageNotifier.MatchUsername("Test pad[#^-^#]oru message", "[#^-^#]").Success); } [Test] public void TestContainsUsernameAtSign() { - Assert.IsTrue(MessageNotifier.MatchUsername("@username hi", "username").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("@username hi", "username").Success); } [Test] public void TestContainsUsernameColon() { - Assert.IsTrue(MessageNotifier.MatchUsername("username: hi", "username").Success); + ClassicAssert.True(MessageNotifier.MatchUsername("username: hi", "username").Success); } } } diff --git a/osu.Game.Tests/Online/Matchmaking/MatchmakingRoomStateTest.cs b/osu.Game.Tests/Online/Matchmaking/MatchmakingRoomStateTest.cs index 25766d4645..9b99128154 100644 --- a/osu.Game.Tests/Online/Matchmaking/MatchmakingRoomStateTest.cs +++ b/osu.Game.Tests/Online/Matchmaking/MatchmakingRoomStateTest.cs @@ -3,6 +3,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Multiplayer.MatchTypes.Matchmaking; @@ -30,17 +31,17 @@ namespace osu.Game.Tests.Online.Matchmaking new SoloScoreInfo { UserID = 3, TotalScore = 750 }, ], placement_points); - Assert.AreEqual(8, state.Users.GetOrAdd(1).Points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(8, state.Users.GetOrAdd(1).Points); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Rounds.GetOrAdd(1).Placement); - Assert.AreEqual(6, state.Users.GetOrAdd(2).Points); - Assert.AreEqual(3, state.Users.GetOrAdd(2).Placement); - Assert.AreEqual(3, state.Users.GetOrAdd(2).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(6, state.Users.GetOrAdd(2).Points); + ClassicAssert.AreEqual(3, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(3, state.Users.GetOrAdd(2).Rounds.GetOrAdd(1).Placement); - Assert.AreEqual(7, state.Users.GetOrAdd(3).Points); - Assert.AreEqual(2, state.Users.GetOrAdd(3).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(3).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(7, state.Users.GetOrAdd(3).Points); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(3).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(3).Rounds.GetOrAdd(1).Placement); // 2 -> 1 -> 3 @@ -52,17 +53,17 @@ namespace osu.Game.Tests.Online.Matchmaking new SoloScoreInfo { UserID = 3, TotalScore = 500 }, ], placement_points); - Assert.AreEqual(15, state.Users.GetOrAdd(1).Points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(1).Rounds.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(15, state.Users.GetOrAdd(1).Points); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(1).Rounds.GetOrAdd(2).Placement); - Assert.AreEqual(14, state.Users.GetOrAdd(2).Points); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Placement); - Assert.AreEqual(1, state.Users.GetOrAdd(2).Rounds.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(14, state.Users.GetOrAdd(2).Points); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(2).Rounds.GetOrAdd(2).Placement); - Assert.AreEqual(13, state.Users.GetOrAdd(3).Points); - Assert.AreEqual(3, state.Users.GetOrAdd(3).Placement); - Assert.AreEqual(3, state.Users.GetOrAdd(3).Rounds.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(13, state.Users.GetOrAdd(3).Points); + ClassicAssert.AreEqual(3, state.Users.GetOrAdd(3).Placement); + ClassicAssert.AreEqual(3, state.Users.GetOrAdd(3).Rounds.GetOrAdd(2).Placement); } [Test] @@ -81,21 +82,21 @@ namespace osu.Game.Tests.Online.Matchmaking new SoloScoreInfo { UserID = 4, TotalScore = 500 }, ], placement_points); - Assert.AreEqual(7, state.Users.GetOrAdd(1).Points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(1).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(7, state.Users.GetOrAdd(1).Points); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(1).Rounds.GetOrAdd(1).Placement); - Assert.AreEqual(7, state.Users.GetOrAdd(2).Points); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(7, state.Users.GetOrAdd(2).Points); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Rounds.GetOrAdd(1).Placement); - Assert.AreEqual(5, state.Users.GetOrAdd(3).Points); - Assert.AreEqual(3, state.Users.GetOrAdd(3).Placement); - Assert.AreEqual(4, state.Users.GetOrAdd(3).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(5, state.Users.GetOrAdd(3).Points); + ClassicAssert.AreEqual(3, state.Users.GetOrAdd(3).Placement); + ClassicAssert.AreEqual(4, state.Users.GetOrAdd(3).Rounds.GetOrAdd(1).Placement); - Assert.AreEqual(5, state.Users.GetOrAdd(4).Points); - Assert.AreEqual(4, state.Users.GetOrAdd(4).Placement); - Assert.AreEqual(4, state.Users.GetOrAdd(4).Rounds.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(5, state.Users.GetOrAdd(4).Points); + ClassicAssert.AreEqual(4, state.Users.GetOrAdd(4).Placement); + ClassicAssert.AreEqual(4, state.Users.GetOrAdd(4).Rounds.GetOrAdd(1).Placement); } [Test] @@ -121,8 +122,8 @@ namespace osu.Game.Tests.Online.Matchmaking new SoloScoreInfo { UserID = 2, TotalScore = 1000 }, ], placement_points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Placement); } [Test] @@ -143,12 +144,12 @@ namespace osu.Game.Tests.Online.Matchmaking new SoloScoreInfo { UserID = 5, TotalScore = 1000 }, ], placement_points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Placement); - Assert.AreEqual(3, state.Users.GetOrAdd(3).Placement); - Assert.AreEqual(4, state.Users.GetOrAdd(4).Placement); - Assert.AreEqual(5, state.Users.GetOrAdd(5).Placement); - Assert.AreEqual(6, state.Users.GetOrAdd(6).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(3, state.Users.GetOrAdd(3).Placement); + ClassicAssert.AreEqual(4, state.Users.GetOrAdd(4).Placement); + ClassicAssert.AreEqual(5, state.Users.GetOrAdd(5).Placement); + ClassicAssert.AreEqual(6, state.Users.GetOrAdd(6).Placement); } [Test] @@ -163,20 +164,20 @@ namespace osu.Game.Tests.Online.Matchmaking new SoloScoreInfo { UserID = 2, TotalScore = 500 }, ], placement_points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Placement); state.Users.GetOrAdd(1).AbandonedAt = DateTimeOffset.Now; state.RecordScores([], placement_points); - Assert.AreEqual(2, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(1, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(2).Placement); state.Users.GetOrAdd(2).AbandonedAt = DateTimeOffset.Now - TimeSpan.FromMinutes(1); state.RecordScores([], placement_points); - Assert.AreEqual(1, state.Users.GetOrAdd(1).Placement); - Assert.AreEqual(2, state.Users.GetOrAdd(2).Placement); + ClassicAssert.AreEqual(1, state.Users.GetOrAdd(1).Placement); + ClassicAssert.AreEqual(2, state.Users.GetOrAdd(2).Placement); } } } diff --git a/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs b/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs index da250c1e05..55984278b1 100644 --- a/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs +++ b/osu.Game.Tests/Online/TestAPIModJsonSerialization.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Bindables; using osu.Framework.Localisation; using osu.Game.Beatmaps; @@ -36,7 +37,7 @@ namespace osu.Game.Tests.Online var converted = deserialized?.ToMod(new TestRuleset()); - Assert.NotNull(converted); + Assert.That(converted, Is.Not.Null); Assert.That(converted, Is.TypeOf(typeof(UnknownMod))); Assert.That(converted.Type, Is.EqualTo(ModType.System)); Assert.That(converted.Acronym, Is.EqualTo("WNG??")); @@ -157,7 +158,7 @@ namespace osu.Game.Tests.Online mod.TestSetting.Value = mod.TestSetting.Default; JObject serialised = JObject.Parse(JsonConvert.SerializeObject(new APIMod(mod))); - Assert.False(serialised.ContainsKey("settings")); + ClassicAssert.False(serialised.ContainsKey("settings")); } private class TestRuleset : Ruleset diff --git a/osu.Game.Tests/Online/TestMultiplayerMessagePackSerialization.cs b/osu.Game.Tests/Online/TestMultiplayerMessagePackSerialization.cs index c440f375fd..da21ff6fcb 100644 --- a/osu.Game.Tests/Online/TestMultiplayerMessagePackSerialization.cs +++ b/osu.Game.Tests/Online/TestMultiplayerMessagePackSerialization.cs @@ -3,6 +3,7 @@ using MessagePack; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Online; using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus; @@ -24,7 +25,7 @@ namespace osu.Game.Tests.Online var deserialized = MessagePackSerializer.Deserialize(serialized); - Assert.IsTrue(deserialized.MatchState is TeamVersusRoomState); + ClassicAssert.True(deserialized.MatchState is TeamVersusRoomState); } [Test] @@ -35,7 +36,7 @@ namespace osu.Game.Tests.Online byte[] serialized = MessagePackSerializer.Serialize(typeof(MatchUserState), state); var deserialized = MessagePackSerializer.Deserialize(serialized); - Assert.IsTrue(deserialized is TeamVersusUserState); + ClassicAssert.True(deserialized is TeamVersusUserState); } [Test] @@ -66,7 +67,7 @@ namespace osu.Game.Tests.Online // works with custom resolver. var deserialized = MessagePackSerializer.Deserialize(serialized, SignalRUnionWorkaroundResolver.OPTIONS); - Assert.IsTrue(deserialized is TeamVersusUserState); + ClassicAssert.True(deserialized is TeamVersusUserState); } } } diff --git a/osu.Game.Tests/Resources/TestResources.cs b/osu.Game.Tests/Resources/TestResources.cs index 469bc8ee73..d7e2ea48c5 100644 --- a/osu.Game.Tests/Resources/TestResources.cs +++ b/osu.Game.Tests/Resources/TestResources.cs @@ -9,7 +9,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading; -using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Extensions; using osu.Framework.IO.Stores; using osu.Framework.Logging; @@ -55,7 +55,7 @@ namespace osu.Game.Tests.Resources using (var newFile = File.Create(tempPath)) stream.CopyTo(newFile); - Assert.IsTrue(File.Exists(tempPath)); + ClassicAssert.True(File.Exists(tempPath)); return tempPath; } @@ -72,7 +72,7 @@ namespace osu.Game.Tests.Resources using (var newFile = File.Create(tempPath)) stream.CopyTo(newFile); - Assert.IsTrue(File.Exists(tempPath)); + ClassicAssert.True(File.Exists(tempPath)); return tempPath; } diff --git a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs index 9b87ce4bb4..db900d57fc 100644 --- a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs +++ b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Rulesets; @@ -174,7 +175,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [TestCase(HitResult.LargeBonus, HitResult.IgnoreMiss)] public void TestMinResults(HitResult hitResult, HitResult expectedMinResult) { - Assert.AreEqual(expectedMinResult, new TestJudgement(hitResult).MinResult); + ClassicAssert.AreEqual(expectedMinResult, new TestJudgement(hitResult).MinResult); } [TestCase(HitResult.None, false)] @@ -195,7 +196,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [TestCase(HitResult.LargeBonus, false)] public void TestAffectsCombo(HitResult hitResult, bool expectedReturnValue) { - Assert.AreEqual(expectedReturnValue, hitResult.AffectsCombo()); + ClassicAssert.AreEqual(expectedReturnValue, hitResult.AffectsCombo()); } [TestCase(HitResult.None, false)] @@ -216,7 +217,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [TestCase(HitResult.LargeBonus, false)] public void TestAffectsAccuracy(HitResult hitResult, bool expectedReturnValue) { - Assert.AreEqual(expectedReturnValue, hitResult.AffectsAccuracy()); + ClassicAssert.AreEqual(expectedReturnValue, hitResult.AffectsAccuracy()); } [TestCase(HitResult.None, false)] @@ -237,7 +238,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [TestCase(HitResult.LargeBonus, true)] public void TestIsBonus(HitResult hitResult, bool expectedReturnValue) { - Assert.AreEqual(expectedReturnValue, hitResult.IsBonus()); + ClassicAssert.AreEqual(expectedReturnValue, hitResult.IsBonus()); } [TestCase(HitResult.None, false)] @@ -258,7 +259,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [TestCase(HitResult.LargeBonus, true)] public void TestIsHit(HitResult hitResult, bool expectedReturnValue) { - Assert.AreEqual(expectedReturnValue, hitResult.IsHit()); + ClassicAssert.AreEqual(expectedReturnValue, hitResult.IsHit()); } [TestCase(HitResult.None, false)] @@ -279,7 +280,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [TestCase(HitResult.LargeBonus, true)] public void TestIsScorable(HitResult hitResult, bool expectedReturnValue) { - Assert.AreEqual(expectedReturnValue, hitResult.IsScorable()); + ClassicAssert.AreEqual(expectedReturnValue, hitResult.IsScorable()); } #pragma warning disable CS0618 diff --git a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs index 6558834a63..b1144c5bc2 100644 --- a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs +++ b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Platform; @@ -57,13 +58,13 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.User.Username, imported.User.Username); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.User.Username, imported.User.Username); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); } finally { @@ -110,13 +111,13 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.User.Username, imported.User.Username); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.User.Username, imported.User.Username); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); if (isLocalUser) Assert.That(imported.BeatmapInfo!.LastPlayed, Is.EqualTo(replayDate)); @@ -165,13 +166,13 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.User.Username, imported.User.Username); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.User.Username, imported.User.Username); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); Assert.That(imported.BeatmapInfo!.LastPlayed, Is.EqualTo(new DateTimeOffset(2023, 10, 30, 0, 0, 0, TimeSpan.Zero))); } @@ -204,8 +205,8 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.IsTrue(imported.Mods.Any(m => m is OsuModHardRock)); - Assert.IsTrue(imported.Mods.Any(m => m is OsuModDoubleTime)); + ClassicAssert.True(imported.Mods.Any(m => m is OsuModHardRock)); + ClassicAssert.True(imported.Mods.Any(m => m is OsuModDoubleTime)); Assert.That(imported.ClientVersion, Is.EqualTo(toImport.ClientVersion)); } finally @@ -269,8 +270,8 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Statistics[HitResult.Perfect], imported.Statistics[HitResult.Perfect]); - Assert.AreEqual(toImport.Statistics[HitResult.Miss], imported.Statistics[HitResult.Miss]); + ClassicAssert.AreEqual(toImport.Statistics[HitResult.Perfect], imported.Statistics[HitResult.Perfect]); + ClassicAssert.AreEqual(toImport.Statistics[HitResult.Miss], imported.Statistics[HitResult.Miss]); } finally { @@ -364,15 +365,15 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.User.Username, imported.User.Username); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); - Assert.AreEqual(toImport.User.Username, imported.RealmUser.Username); - Assert.AreEqual(1234, imported.RealmUser.OnlineID); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.User.Username, imported.User.Username); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual(toImport.User.Username, imported.RealmUser.Username); + ClassicAssert.AreEqual(1234, imported.RealmUser.OnlineID); } finally { @@ -430,15 +431,15 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.User.Username, imported.User.Username); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); - Assert.AreEqual(toImport.User.Username, imported.RealmUser.Username); - Assert.AreEqual(1234, imported.RealmUser.OnlineID); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.User.Username, imported.User.Username); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual(toImport.User.Username, imported.RealmUser.Username); + ClassicAssert.AreEqual(1234, imported.RealmUser.OnlineID); } finally { @@ -497,14 +498,14 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.User.Username, imported.User.Username); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); - Assert.AreEqual(toImport.User.Username, imported.RealmUser.Username); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.User.Username, imported.User.Username); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual(toImport.User.Username, imported.RealmUser.Username); Assert.That(imported.RealmUser.OnlineID, Is.LessThanOrEqualTo(1)); } finally @@ -564,15 +565,15 @@ namespace osu.Game.Tests.Scores.IO var imported = LoadScoreIntoOsu(osu, toImport); - Assert.AreEqual(toImport.Rank, imported.Rank); - Assert.AreEqual(toImport.TotalScore, imported.TotalScore); - Assert.AreEqual(toImport.Accuracy, imported.Accuracy); - Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo); - Assert.AreEqual(toImport.Date, imported.Date); - Assert.AreEqual(toImport.OnlineID, imported.OnlineID); - Assert.AreEqual("Some other guy", imported.RealmUser.Username); - Assert.AreEqual(5555, imported.RealmUser.OnlineID); - Assert.AreEqual(CountryCode.DE, imported.RealmUser.CountryCode); + ClassicAssert.AreEqual(toImport.Rank, imported.Rank); + ClassicAssert.AreEqual(toImport.TotalScore, imported.TotalScore); + ClassicAssert.AreEqual(toImport.Accuracy, imported.Accuracy); + ClassicAssert.AreEqual(toImport.MaxCombo, imported.MaxCombo); + ClassicAssert.AreEqual(toImport.Date, imported.Date); + ClassicAssert.AreEqual(toImport.OnlineID, imported.OnlineID); + ClassicAssert.AreEqual("Some other guy", imported.RealmUser.Username); + ClassicAssert.AreEqual(5555, imported.RealmUser.OnlineID); + ClassicAssert.AreEqual(CountryCode.DE, imported.RealmUser.CountryCode); } finally { diff --git a/osu.Game.Tests/ScrollAlgorithms/ConstantScrollTest.cs b/osu.Game.Tests/ScrollAlgorithms/ConstantScrollTest.cs index 0994803d83..94c34971d4 100644 --- a/osu.Game.Tests/ScrollAlgorithms/ConstantScrollTest.cs +++ b/osu.Game.Tests/ScrollAlgorithms/ConstantScrollTest.cs @@ -4,6 +4,7 @@ #nullable disable using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Rulesets.UI.Scrolling.Algorithms; namespace osu.Game.Tests.ScrollAlgorithms @@ -22,33 +23,33 @@ namespace osu.Game.Tests.ScrollAlgorithms [Test] public void TestPointDisplayStartTime() { - Assert.AreEqual(-8000, algorithm.GetDisplayStartTime(2000, 0, 10000, 1)); - Assert.AreEqual(-3000, algorithm.GetDisplayStartTime(2000, 0, 5000, 1)); - Assert.AreEqual(2000, algorithm.GetDisplayStartTime(7000, 0, 5000, 1)); - Assert.AreEqual(7000, algorithm.GetDisplayStartTime(17000, 0, 10000, 1)); + ClassicAssert.AreEqual(-8000, algorithm.GetDisplayStartTime(2000, 0, 10000, 1)); + ClassicAssert.AreEqual(-3000, algorithm.GetDisplayStartTime(2000, 0, 5000, 1)); + ClassicAssert.AreEqual(2000, algorithm.GetDisplayStartTime(7000, 0, 5000, 1)); + ClassicAssert.AreEqual(7000, algorithm.GetDisplayStartTime(17000, 0, 10000, 1)); } [Test] public void TestObjectDisplayStartTime() { - Assert.AreEqual(900, algorithm.GetDisplayStartTime(2000, 50, 1000, 500)); // 2000 - (1 + 50 / 500) * 1000 - Assert.AreEqual(8900, algorithm.GetDisplayStartTime(10000, 50, 1000, 500)); // 10000 - (1 + 50 / 500) * 1000 - Assert.AreEqual(13500, algorithm.GetDisplayStartTime(15000, 250, 1000, 500)); // 15000 - (1 + 250 / 500) * 1000 - Assert.AreEqual(19000, algorithm.GetDisplayStartTime(25000, 100, 5000, 500)); // 25000 - (1 + 100 / 500) * 5000 + ClassicAssert.AreEqual(900, algorithm.GetDisplayStartTime(2000, 50, 1000, 500)); // 2000 - (1 + 50 / 500) * 1000 + ClassicAssert.AreEqual(8900, algorithm.GetDisplayStartTime(10000, 50, 1000, 500)); // 10000 - (1 + 50 / 500) * 1000 + ClassicAssert.AreEqual(13500, algorithm.GetDisplayStartTime(15000, 250, 1000, 500)); // 15000 - (1 + 250 / 500) * 1000 + ClassicAssert.AreEqual(19000, algorithm.GetDisplayStartTime(25000, 100, 5000, 500)); // 25000 - (1 + 100 / 500) * 5000 } [Test] public void TestLength() { - Assert.AreEqual(1f / 5, algorithm.GetLength(0, 1000, 5000, 1)); - Assert.AreEqual(1f / 5, algorithm.GetLength(6000, 7000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(0, 1000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(6000, 7000, 5000, 1)); } [Test] public void TestPosition() { - Assert.AreEqual(1f / 5, algorithm.PositionAt(1000, 0, 5000, 1)); - Assert.AreEqual(1f / 5, algorithm.PositionAt(6000, 5000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(1000, 0, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(6000, 5000, 5000, 1)); } [TestCase(1000)] @@ -58,8 +59,8 @@ namespace osu.Game.Tests.ScrollAlgorithms [TestCase(25000)] public void TestTime(double time) { - Assert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 0, 5000, 1), 0, 5000, 1), 0.001); - Assert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 5000, 5000, 1), 5000, 5000, 1), 0.001); + ClassicAssert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 0, 5000, 1), 0, 5000, 1), 0.001); + ClassicAssert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 5000, 5000, 1), 5000, 5000, 1), 0.001); } } } diff --git a/osu.Game.Tests/ScrollAlgorithms/OverlappingScrollTest.cs b/osu.Game.Tests/ScrollAlgorithms/OverlappingScrollTest.cs index c1f647cb07..f954f13b0b 100644 --- a/osu.Game.Tests/ScrollAlgorithms/OverlappingScrollTest.cs +++ b/osu.Game.Tests/ScrollAlgorithms/OverlappingScrollTest.cs @@ -4,6 +4,7 @@ #nullable disable using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Lists; using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI.Scrolling.Algorithms; @@ -31,37 +32,37 @@ namespace osu.Game.Tests.ScrollAlgorithms [Test] public void TestPointDisplayStartTime() { - Assert.AreEqual(1000, algorithm.GetDisplayStartTime(2000, 0, 1000, 1)); // Like constant - Assert.AreEqual(10000, algorithm.GetDisplayStartTime(10500, 0, 1000, 1)); // 10500 - (1000 * 0.5) - Assert.AreEqual(20000, algorithm.GetDisplayStartTime(22000, 0, 1000, 1)); // 23000 - (1000 / 0.5) + ClassicAssert.AreEqual(1000, algorithm.GetDisplayStartTime(2000, 0, 1000, 1)); // Like constant + ClassicAssert.AreEqual(10000, algorithm.GetDisplayStartTime(10500, 0, 1000, 1)); // 10500 - (1000 * 0.5) + ClassicAssert.AreEqual(20000, algorithm.GetDisplayStartTime(22000, 0, 1000, 1)); // 23000 - (1000 / 0.5) } [Test] public void TestObjectDisplayStartTime() { - Assert.AreEqual(900, algorithm.GetDisplayStartTime(2000, 50, 1000, 500)); // 2000 - (1 + 50 / 500) * 1000 / 1 - Assert.AreEqual(9450, algorithm.GetDisplayStartTime(10000, 50, 1000, 500)); // 10000 - (1 + 50 / 500) * 1000 / 2 - Assert.AreEqual(14250, algorithm.GetDisplayStartTime(15000, 250, 1000, 500)); // 15000 - (1 + 250 / 500) * 1000 / 2 - Assert.AreEqual(16500, algorithm.GetDisplayStartTime(18000, 250, 2000, 500)); // 18000 - (1 + 250 / 500) * 2000 / 2 - Assert.AreEqual(17800, algorithm.GetDisplayStartTime(20000, 50, 1000, 500)); // 20000 - (1 + 50 / 500) * 1000 / 0.5 - Assert.AreEqual(19800, algorithm.GetDisplayStartTime(22000, 50, 1000, 500)); // 22000 - (1 + 50 / 500) * 1000 / 0.5 + ClassicAssert.AreEqual(900, algorithm.GetDisplayStartTime(2000, 50, 1000, 500)); // 2000 - (1 + 50 / 500) * 1000 / 1 + ClassicAssert.AreEqual(9450, algorithm.GetDisplayStartTime(10000, 50, 1000, 500)); // 10000 - (1 + 50 / 500) * 1000 / 2 + ClassicAssert.AreEqual(14250, algorithm.GetDisplayStartTime(15000, 250, 1000, 500)); // 15000 - (1 + 250 / 500) * 1000 / 2 + ClassicAssert.AreEqual(16500, algorithm.GetDisplayStartTime(18000, 250, 2000, 500)); // 18000 - (1 + 250 / 500) * 2000 / 2 + ClassicAssert.AreEqual(17800, algorithm.GetDisplayStartTime(20000, 50, 1000, 500)); // 20000 - (1 + 50 / 500) * 1000 / 0.5 + ClassicAssert.AreEqual(19800, algorithm.GetDisplayStartTime(22000, 50, 1000, 500)); // 22000 - (1 + 50 / 500) * 1000 / 0.5 } [Test] public void TestLength() { - Assert.AreEqual(1f / 5, algorithm.GetLength(0, 1000, 5000, 1)); // Like constant - Assert.AreEqual(1f / 5, algorithm.GetLength(10000, 10500, 5000, 1)); // (10500 - 10000) / 0.5 / 5000 - Assert.AreEqual(1f / 5, algorithm.GetLength(20000, 22000, 5000, 1)); // (22000 - 20000) * 0.5 / 5000 + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(0, 1000, 5000, 1)); // Like constant + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(10000, 10500, 5000, 1)); // (10500 - 10000) / 0.5 / 5000 + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(20000, 22000, 5000, 1)); // (22000 - 20000) * 0.5 / 5000 } [Test] public void TestPosition() { // Basically same calculations as TestLength() - Assert.AreEqual(1f / 5, algorithm.PositionAt(1000, 0, 5000, 1)); - Assert.AreEqual(1f / 5, algorithm.PositionAt(10500, 10000, 5000, 1)); - Assert.AreEqual(1f / 5, algorithm.PositionAt(22000, 20000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(1000, 0, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(10500, 10000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(22000, 20000, 5000, 1)); } [TestCase(1000)] @@ -73,8 +74,8 @@ namespace osu.Game.Tests.ScrollAlgorithms + "Ideally, scrolling should be changed to constant or sequential during editing of hitobjects.")] public void TestTime(double time) { - Assert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 0, 5000, 1), 0, 5000, 1), 0.001); - Assert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 5000, 5000, 1), 5000, 5000, 1), 0.001); + ClassicAssert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 0, 5000, 1), 0, 5000, 1), 0.001); + ClassicAssert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 5000, 5000, 1), 5000, 5000, 1), 0.001); } } } diff --git a/osu.Game.Tests/ScrollAlgorithms/SequentialScrollTest.cs b/osu.Game.Tests/ScrollAlgorithms/SequentialScrollTest.cs index ca6ac63619..e392c7030d 100644 --- a/osu.Game.Tests/ScrollAlgorithms/SequentialScrollTest.cs +++ b/osu.Game.Tests/ScrollAlgorithms/SequentialScrollTest.cs @@ -4,6 +4,7 @@ #nullable disable using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Lists; using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI.Scrolling.Algorithms; @@ -32,9 +33,9 @@ namespace osu.Game.Tests.ScrollAlgorithms public void TestDisplayStartTime() { // easy cases - time range adjusted for velocity fits within control point duration - Assert.AreEqual(2500, algorithm.GetDisplayStartTime(5000, 0, 2500, 1)); // 5000 - (2500 / 1) - Assert.AreEqual(13750, algorithm.GetDisplayStartTime(15000, 0, 2500, 1)); // 15000 - (2500 / 2) - Assert.AreEqual(20000, algorithm.GetDisplayStartTime(25000, 0, 2500, 1)); // 25000 - (2500 / 0.5) + ClassicAssert.AreEqual(2500, algorithm.GetDisplayStartTime(5000, 0, 2500, 1)); // 5000 - (2500 / 1) + ClassicAssert.AreEqual(13750, algorithm.GetDisplayStartTime(15000, 0, 2500, 1)); // 15000 - (2500 / 2) + ClassicAssert.AreEqual(20000, algorithm.GetDisplayStartTime(25000, 0, 2500, 1)); // 25000 - (2500 / 0.5) // hard case - time range adjusted for velocity exceeds control point duration @@ -46,24 +47,24 @@ namespace osu.Game.Tests.ScrollAlgorithms // minus one scroll length allowance = 12500 - 1000 = 11500 = 11.5 [scroll lengths] // therefore the start time lies within the second multiplier point (because 11.5 < 4 + 8) // its exact time position is = 10000 + 7.5 * (2500 / 2) = 19375 - Assert.AreEqual(19375, algorithm.GetDisplayStartTime(22500, 0, 2500, 1000)); + ClassicAssert.AreEqual(19375, algorithm.GetDisplayStartTime(22500, 0, 2500, 1000)); } [Test] public void TestLength() { - Assert.AreEqual(1f / 5, algorithm.GetLength(0, 1000, 5000, 1)); // Like constant - Assert.AreEqual(1f / 5, algorithm.GetLength(10000, 10500, 5000, 1)); // (10500 - 10000) / 0.5 / 5000 - Assert.AreEqual(1f / 5, algorithm.GetLength(20000, 22000, 5000, 1)); // (22000 - 20000) * 0.5 / 5000 + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(0, 1000, 5000, 1)); // Like constant + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(10000, 10500, 5000, 1)); // (10500 - 10000) / 0.5 / 5000 + ClassicAssert.AreEqual(1f / 5, algorithm.GetLength(20000, 22000, 5000, 1)); // (22000 - 20000) * 0.5 / 5000 } [Test] public void TestPosition() { // Basically same calculations as TestLength() - Assert.AreEqual(1f / 5, algorithm.PositionAt(1000, 0, 5000, 1)); - Assert.AreEqual(1f / 5, algorithm.PositionAt(10500, 10000, 5000, 1)); - Assert.AreEqual(1f / 5, algorithm.PositionAt(22000, 20000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(1000, 0, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(10500, 10000, 5000, 1)); + ClassicAssert.AreEqual(1f / 5, algorithm.PositionAt(22000, 20000, 5000, 1)); } [TestCase(1000)] @@ -73,8 +74,8 @@ namespace osu.Game.Tests.ScrollAlgorithms [TestCase(25000)] public void TestTime(double time) { - Assert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 0, 5000, 1), 0, 5000, 1), 0.001); - Assert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 5000, 5000, 1), 5000, 5000, 1), 0.001); + ClassicAssert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 0, 5000, 1), 0, 5000, 1), 0.001); + ClassicAssert.AreEqual(time, algorithm.TimeAt(algorithm.PositionAt(time, 5000, 5000, 1), 5000, 5000, 1), 0.001); } } } diff --git a/osu.Game.Tests/Skins/IO/ImportSkinTest.cs b/osu.Game.Tests/Skins/IO/ImportSkinTest.cs index 2535d5b2e2..ffb97eb5cc 100644 --- a/osu.Game.Tests/Skins/IO/ImportSkinTest.cs +++ b/osu.Game.Tests/Skins/IO/ImportSkinTest.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Allocation; using osu.Framework.Platform; using osu.Game.Database; @@ -15,6 +16,8 @@ using osu.Game.IO; using osu.Game.Skinning; using osu.Game.Tests.Resources; using SharpCompress.Archives.Zip; +using SharpCompress.Common; +using SharpCompress.Writers.Zip; namespace osu.Game.Tests.Skins.IO { @@ -241,21 +244,21 @@ namespace osu.Game.Tests.Skins.IO await skinManager.CurrentSkinInfo.Value.PerformRead(async s => { - Assert.IsFalse(s.Protected); - Assert.AreEqual(typeof(ArgonSkin), s.CreateInstance(skinManager).GetType()); + ClassicAssert.False(s.Protected); + ClassicAssert.AreEqual(typeof(ArgonSkin), s.CreateInstance(skinManager).GetType()); await new LegacySkinExporter(osu.Dependencies.Get()).ExportToStreamAsync(skinManager.CurrentSkinInfo.Value, exportStream); - Assert.Greater(exportStream.Length, 0); + ClassicAssert.Greater(exportStream.Length, 0); }); var imported = await skinManager.Import(new ImportTask(exportStream, "exported.osk")); imported.PerformRead(s => { - Assert.IsFalse(s.Protected); - Assert.AreNotEqual(originalSkinId, s.ID); - Assert.AreEqual(typeof(ArgonSkin), s.CreateInstance(skinManager).GetType()); + ClassicAssert.False(s.Protected); + ClassicAssert.AreNotEqual(originalSkinId, s.ID); + ClassicAssert.AreEqual(typeof(ArgonSkin), s.CreateInstance(skinManager).GetType()); }); }); @@ -274,21 +277,21 @@ namespace osu.Game.Tests.Skins.IO await skinManager.CurrentSkinInfo.Value.PerformRead(async s => { - Assert.IsFalse(s.Protected); - Assert.AreEqual(typeof(DefaultLegacySkin), s.CreateInstance(skinManager).GetType()); + ClassicAssert.False(s.Protected); + ClassicAssert.AreEqual(typeof(DefaultLegacySkin), s.CreateInstance(skinManager).GetType()); await new LegacySkinExporter(osu.Dependencies.Get()).ExportToStreamAsync(skinManager.CurrentSkinInfo.Value, exportStream); - Assert.Greater(exportStream.Length, 0); + ClassicAssert.Greater(exportStream.Length, 0); }); var imported = await skinManager.Import(new ImportTask(exportStream, "exported.osk")); imported.PerformRead(s => { - Assert.IsFalse(s.Protected); - Assert.AreNotEqual(originalSkinId, s.ID); - Assert.AreEqual(typeof(DefaultLegacySkin), s.CreateInstance(skinManager).GetType()); + ClassicAssert.False(s.Protected); + ClassicAssert.AreNotEqual(originalSkinId, s.ID); + ClassicAssert.AreEqual(typeof(DefaultLegacySkin), s.CreateInstance(skinManager).GetType()); }); }); @@ -304,9 +307,9 @@ namespace osu.Game.Tests.Skins.IO var osu = LoadOsuIntoHost(host); var zipStream = new MemoryStream(); - using var zip = ZipArchive.Create(); - zip.AddEntry("folder/test.png", new MemoryStream(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF })); - zip.SaveTo(zipStream); + using var zip = ZipArchive.CreateArchive(); + zip.AddEntry("folder/test.png", new MemoryStream(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }), true); + zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate)); var import = await loadSkinIntoOsu(osu, new ImportTask(zipStream, "test skin.osk")); @@ -353,9 +356,9 @@ namespace osu.Game.Tests.Skins.IO var osu = LoadOsuIntoHost(host); var zipStream = new MemoryStream(); - using var zip = ZipArchive.Create(); - zip.AddEntry("test?.png", new MemoryStream(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF })); - zip.SaveTo(zipStream); + using var zip = ZipArchive.CreateArchive(); + zip.AddEntry("test?.png", new MemoryStream(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }), true); + zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate)); var import = await loadSkinIntoOsu(osu, new ImportTask(zipStream, "test skin.osk")); @@ -419,26 +422,26 @@ namespace osu.Game.Tests.Skins.IO private MemoryStream createEmptyOsk() { var zipStream = new MemoryStream(); - using var zip = ZipArchive.Create(); - zip.SaveTo(zipStream); + using var zip = ZipArchive.CreateArchive(); + zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate)); return zipStream; } private MemoryStream createOskWithNonIniFile() { var zipStream = new MemoryStream(); - using var zip = ZipArchive.Create(); - zip.AddEntry("hitcircle.png", new MemoryStream(new byte[] { 0, 1, 2, 3 })); - zip.SaveTo(zipStream); + using var zip = ZipArchive.CreateArchive(); + zip.AddEntry("hitcircle.png", new MemoryStream(new byte[] { 0, 1, 2, 3 }), true); + zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate)); return zipStream; } private MemoryStream createOskWithIni(string name, string author, bool makeUnique = false, string iniFilename = @"skin.ini", bool includeSectionHeader = true) { var zipStream = new MemoryStream(); - using var zip = ZipArchive.Create(); - zip.AddEntry(iniFilename, generateSkinIni(name, author, makeUnique, includeSectionHeader)); - zip.SaveTo(zipStream); + using var zip = ZipArchive.CreateArchive(); + zip.AddEntry(iniFilename, generateSkinIni(name, author, makeUnique, includeSectionHeader), true); + zip.SaveTo(zipStream, new ZipWriterOptions(CompressionType.Deflate)); return zipStream; } diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs index 9466fdf888..4bf685fc9f 100644 --- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs +++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.IO; using osu.Game.Skinning; using osu.Game.Tests.Resources; @@ -32,9 +33,9 @@ namespace osu.Game.Tests.Skins new Color4(100, 100, 100, 255), // alpha is specified as 100, but should be ignored. }; - Assert.AreEqual(expectedColors.Count, comboColors?.Count); + ClassicAssert.AreEqual(expectedColors.Count, comboColors?.Count); for (int i = 0; i < expectedColors.Count; i++) - Assert.AreEqual(expectedColors[i], comboColors[i]); + ClassicAssert.AreEqual(expectedColors[i], comboColors![i]); } } @@ -49,9 +50,9 @@ namespace osu.Game.Tests.Skins var comboColors = decoder.Decode(stream).ComboColours; var expectedColors = SkinConfiguration.DefaultComboColours; - Assert.AreEqual(expectedColors.Count, comboColors?.Count); + ClassicAssert.AreEqual(expectedColors.Count, comboColors?.Count); for (int i = 0; i < expectedColors.Count; i++) - Assert.AreEqual(expectedColors[i], comboColors[i]); + ClassicAssert.AreEqual(expectedColors[i], comboColors![i]); } } @@ -65,7 +66,7 @@ namespace osu.Game.Tests.Skins { var skinConfiguration = decoder.Decode(stream); skinConfiguration.AllowDefaultComboColoursFallback = false; - Assert.IsNull(skinConfiguration.ComboColours); + ClassicAssert.Null(skinConfiguration.ComboColours); } } @@ -79,8 +80,8 @@ namespace osu.Game.Tests.Skins { var config = decoder.Decode(stream); - Assert.AreEqual("test skin", config.SkinInfo.Name); - Assert.AreEqual("TestValue", config.ConfigDictionary["TestLookup"]); + ClassicAssert.AreEqual("test skin", config.SkinInfo.Name); + ClassicAssert.AreEqual("TestValue", config.ConfigDictionary["TestLookup"]); } } @@ -90,7 +91,7 @@ namespace osu.Game.Tests.Skins var decoder = new LegacySkinDecoder(); using (var resStream = TestResources.OpenResource("skin-20.ini")) using (var stream = new LineBufferedReader(resStream)) - Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion); + ClassicAssert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion); } [Test] @@ -99,7 +100,7 @@ namespace osu.Game.Tests.Skins var decoder = new LegacySkinDecoder(); using (var resStream = TestResources.OpenResource("skin-with-space.ini")) using (var stream = new LineBufferedReader(resStream)) - Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion); + ClassicAssert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion); } [Test] @@ -108,7 +109,7 @@ namespace osu.Game.Tests.Skins var decoder = new LegacySkinDecoder(); using (var resStream = TestResources.OpenResource("skin-latest.ini")) using (var stream = new LineBufferedReader(resStream)) - Assert.AreEqual(SkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion); + ClassicAssert.AreEqual(SkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion); } [Test] diff --git a/osu.Game.Tests/Skins/TestSceneSkinResources.cs b/osu.Game.Tests/Skins/TestSceneSkinResources.cs index e77affd817..17e9c9b654 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinResources.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinResources.cs @@ -66,7 +66,7 @@ namespace osu.Game.Tests.Skins mockResourceStore = new Mock>(); mockResourceStore.Setup(r => r.Get(It.IsAny())) .Callback(n => lookedUpFileNames.Add(n)) - .Returns(null); + .Returns(null!); }); AddStep("query sample", () => diff --git a/osu.Game.Tests/Utils/NamingUtilsTest.cs b/osu.Game.Tests/Utils/NamingUtilsTest.cs index 1f7e06f996..7e85171bb4 100644 --- a/osu.Game.Tests/Utils/NamingUtilsTest.cs +++ b/osu.Game.Tests/Utils/NamingUtilsTest.cs @@ -3,6 +3,7 @@ using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Utils; namespace osu.Game.Tests.Utils @@ -15,7 +16,7 @@ namespace osu.Game.Tests.Utils { string nextBestName = NamingUtils.GetNextBestName(Enumerable.Empty(), "New Difficulty"); - Assert.AreEqual("New Difficulty", nextBestName); + ClassicAssert.AreEqual("New Difficulty", nextBestName); } [Test] @@ -30,7 +31,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty", nextBestName); + ClassicAssert.AreEqual("New Difficulty", nextBestName); } [Test] @@ -45,7 +46,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty", nextBestName); + ClassicAssert.AreEqual("New Difficulty", nextBestName); } [Test] @@ -58,7 +59,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty (1)", nextBestName); + ClassicAssert.AreEqual("New Difficulty (1)", nextBestName); } [Test] @@ -71,7 +72,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty (1)", nextBestName); + ClassicAssert.AreEqual("New Difficulty (1)", nextBestName); } [Test] @@ -84,7 +85,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty (copy)"); - Assert.AreEqual("New Difficulty (copy) (1)", nextBestName); + ClassicAssert.AreEqual("New Difficulty (copy) (1)", nextBestName); } [Test] @@ -100,7 +101,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty (4)", nextBestName); + ClassicAssert.AreEqual("New Difficulty (4)", nextBestName); } [Test] @@ -110,7 +111,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty (31)", nextBestName); + ClassicAssert.AreEqual("New Difficulty (31)", nextBestName); } [Test] @@ -126,7 +127,7 @@ namespace osu.Game.Tests.Utils string nextBestName = NamingUtils.GetNextBestName(existingNames, "New Difficulty"); - Assert.AreEqual("New Difficulty (2)", nextBestName); + ClassicAssert.AreEqual("New Difficulty (2)", nextBestName); } [Test] @@ -134,7 +135,7 @@ namespace osu.Game.Tests.Utils { string nextBestFilename = NamingUtils.GetNextBestFilename(Enumerable.Empty(), "test_file.osr"); - Assert.AreEqual("test_file.osr", nextBestFilename); + ClassicAssert.AreEqual("test_file.osr", nextBestFilename); } [Test] @@ -149,7 +150,7 @@ namespace osu.Game.Tests.Utils string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "test_file.osr"); - Assert.AreEqual("test_file.osr", nextBestFilename); + ClassicAssert.AreEqual("test_file.osr", nextBestFilename); } [Test] @@ -164,7 +165,7 @@ namespace osu.Game.Tests.Utils string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file.osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file.osr", nextBestFilename); } [Test] @@ -177,7 +178,7 @@ namespace osu.Game.Tests.Utils string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file (1).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (1).osr", nextBestFilename); } [Test] @@ -191,7 +192,7 @@ namespace osu.Game.Tests.Utils }; string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file (3).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (3).osr", nextBestFilename); } [Test] @@ -204,10 +205,10 @@ namespace osu.Game.Tests.Utils }; string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file (1).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (1).osr", nextBestFilename); nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file (copy).osr"); - Assert.AreEqual("replay_file (copy) (1).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (copy) (1).osr", nextBestFilename); } [Test] @@ -223,7 +224,7 @@ namespace osu.Game.Tests.Utils string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file (4).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (4).osr", nextBestFilename); } [Test] @@ -240,7 +241,7 @@ namespace osu.Game.Tests.Utils string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file (3).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (3).osr", nextBestFilename); } [Test] @@ -254,10 +255,10 @@ namespace osu.Game.Tests.Utils }; string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "surely"); - Assert.AreEqual("surely", nextBestFilename); + ClassicAssert.AreEqual("surely", nextBestFilename); nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "those"); - Assert.AreEqual("those (1)", nextBestFilename); + ClassicAssert.AreEqual("those (1)", nextBestFilename); } [Test] @@ -271,10 +272,10 @@ namespace osu.Game.Tests.Utils }; string nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.osr"); - Assert.AreEqual("replay_file (2).osr", nextBestFilename); + ClassicAssert.AreEqual("replay_file (2).osr", nextBestFilename); nextBestFilename = NamingUtils.GetNextBestFilename(existingFiles, "replay_file.txt"); - Assert.AreEqual("replay_file (1).txt", nextBestFilename); + ClassicAssert.AreEqual("replay_file (1).txt", nextBestFilename); } } } diff --git a/osu.Game.Tests/Visual/Editing/TestSceneComposerSelection.cs b/osu.Game.Tests/Visual/Editing/TestSceneComposerSelection.cs index 6a9ca1292c..df5b58f310 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneComposerSelection.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneComposerSelection.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.UserInterface; @@ -662,11 +663,11 @@ namespace osu.Game.Tests.Visual.Editing AddStep("move mouse", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(50, 0))); - AddStep("aspect ratio does not equal", () => Assert.AreNotEqual(aspectRatioBeforeDrag, getAspectRatio())); + AddStep("aspect ratio does not equal", () => ClassicAssert.AreNotEqual(aspectRatioBeforeDrag, getAspectRatio())); AddStep("press shift", () => InputManager.PressKey(Key.ShiftLeft)); - AddStep("aspect ratio does equal", () => Assert.AreEqual(aspectRatioBeforeDrag, getAspectRatio())); + AddStep("aspect ratio does equal", () => ClassicAssert.AreEqual(aspectRatioBeforeDrag, getAspectRatio())); AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left)); @@ -701,11 +702,11 @@ namespace osu.Game.Tests.Visual.Editing AddStep("move mouse", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(50, 0))); - AddStep("center does not equal", () => Assert.AreNotEqual(centerBeforeDrag, getCenter())); + AddStep("center does not equal", () => ClassicAssert.AreNotEqual(centerBeforeDrag, getCenter())); AddStep("press alt", () => InputManager.PressKey(Key.AltLeft)); - AddStep("center does equal", () => Assert.AreEqual(centerBeforeDrag, getCenter())); + AddStep("center does equal", () => ClassicAssert.AreEqual(centerBeforeDrag, getCenter())); AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left)); @@ -745,19 +746,19 @@ namespace osu.Game.Tests.Visual.Editing AddStep("move mouse", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(50, 0))); - AddStep("aspect ratio does not equal", () => Assert.AreNotEqual(aspectRatioBeforeDrag, getAspectRatio())); + AddStep("aspect ratio does not equal", () => ClassicAssert.AreNotEqual(aspectRatioBeforeDrag, getAspectRatio())); - AddStep("center does not equal", () => Assert.AreNotEqual(centerBeforeDrag, getCenter())); + AddStep("center does not equal", () => ClassicAssert.AreNotEqual(centerBeforeDrag, getCenter())); AddStep("press shift", () => InputManager.PressKey(Key.ShiftLeft)); - AddStep("aspect ratio does equal", () => Assert.AreEqual(aspectRatioBeforeDrag, getAspectRatio())); + AddStep("aspect ratio does equal", () => ClassicAssert.AreEqual(aspectRatioBeforeDrag, getAspectRatio())); - AddStep("center does not equal", () => Assert.AreNotEqual(centerBeforeDrag, getCenter())); + AddStep("center does not equal", () => ClassicAssert.AreNotEqual(centerBeforeDrag, getCenter())); AddStep("press alt", () => InputManager.PressKey(Key.AltLeft)); - AddStep("center does equal", () => Assert.AreEqual(centerBeforeDrag, getCenter())); + AddStep("center does equal", () => ClassicAssert.AreEqual(centerBeforeDrag, getCenter())); AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left)); diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs index 7440697ba0..ed91fe848a 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs @@ -881,7 +881,7 @@ namespace osu.Game.Tests.Visual.Editing try { - using (var zip = ZipArchive.Open(temp)) + using (var zip = ZipArchive.OpenArchive(temp)) zip.WriteToDirectory(extractedFolder); return func(extractedFolder); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs index d8817e563c..57d1f26926 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs @@ -146,7 +146,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("wait for frame starvation", () => replayHandler.WaitingForFrame); checkPaused(true); - AddAssert("time advanced", () => currentFrameStableTime, () => Is.GreaterThan(pausedTime)); + AddAssert("time advanced", () => currentFrameStableTime, () => Is.GreaterThan(pausedTime!)); } [Test] diff --git a/osu.Game.Tests/Visual/Online/TestSceneDrawableChannel.cs b/osu.Game.Tests/Visual/Online/TestSceneDrawableChannel.cs index b475071f6e..fcae9ab7be 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDrawableChannel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDrawableChannel.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Framework.Utils; @@ -142,7 +143,7 @@ namespace osu.Game.Tests.Visual.Online AddRepeatStep("check background", () => { // +1 because the day separator take one index - Assert.AreEqual((checkCount + 1) % 2 == 0, drawableChannel.ChildrenOfType().ToList()[checkCount].AlternatingBackground); + ClassicAssert.AreEqual((checkCount + 1) % 2 == 0, drawableChannel.ChildrenOfType().ToList()[checkCount].AlternatingBackground); checkCount++; }, 10); } diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index c86f05c257..6f970df4c5 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -1,13 +1,12 @@  - - - + + - - - + + + WinExe diff --git a/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs b/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs index 6ee7808099..c488f4ae80 100644 --- a/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Allocation; using osu.Framework.Platform; using osu.Framework.Testing; @@ -38,8 +39,8 @@ namespace osu.Game.Tournament.Tests.NonVisual WaitForOrAssert(() => (ipc = osu.Dependencies.Get() as FileBasedIPC)?.IsLoaded == true, @"ipc could not be populated in a reasonable amount of time"); - Assert.True(ipc!.SetIPCLocation(testStableInstallDirectory)); - Assert.True(storage.AllTournaments.Exists("stable.json")); + ClassicAssert.True(ipc!.SetIPCLocation(testStableInstallDirectory)); + ClassicAssert.True(storage.AllTournaments.Exists("stable.json")); } finally { diff --git a/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs b/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs index e4a35913cc..eb5865bb97 100644 --- a/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs @@ -5,6 +5,7 @@ using System; using System.Threading; using System.Threading.Tasks; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Platform; namespace osu.Game.Tournament.Tests.NonVisual @@ -27,7 +28,7 @@ namespace osu.Game.Tournament.Tests.NonVisual while (!result()) Thread.Sleep(200); }); - Assert.IsTrue(task.Wait(timeout), failureMessage); + ClassicAssert.True(task.Wait(timeout), failureMessage); } } } diff --git a/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj b/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj index 8437a1bc4e..83637ab251 100644 --- a/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj +++ b/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj @@ -4,9 +4,9 @@ osu.Game.Tournament.Tests.TournamentTestRunner - - - + + + WinExe diff --git a/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs b/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs index c591dac36f..d9e72d7c91 100644 --- a/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs +++ b/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs @@ -205,7 +205,7 @@ namespace osu.Game.Beatmaps // ensure to clobber any and all existing data to avoid accidental corruption. outStream.SetLength(0); - using (var bz2 = new BZip2Stream(stream, CompressionMode.Decompress, false)) + using (var bz2 = BZip2Stream.Create(stream, CompressionMode.Decompress, false)) bz2.CopyTo(outStream); } diff --git a/osu.Game/Database/LegacyArchiveExporter.cs b/osu.Game/Database/LegacyArchiveExporter.cs index e4d3ed4681..9e8f5ad9c9 100644 --- a/osu.Game/Database/LegacyArchiveExporter.cs +++ b/osu.Game/Database/LegacyArchiveExporter.cs @@ -38,7 +38,7 @@ namespace osu.Game.Database { var zipWriterOptions = new ZipWriterOptions(CompressionType.Deflate) { - ArchiveEncoding = UseFixedEncoding ? ZipArchiveReader.DEFAULT_ENCODING : new ArchiveEncoding(Encoding.UTF8, Encoding.UTF8) + ArchiveEncoding = UseFixedEncoding ? ZipArchiveReader.DEFAULT_ENCODING : new ArchiveEncoding { Default = Encoding.UTF8, Password = Encoding.UTF8 } }; using (var writer = new ZipWriter(outputStream, zipWriterOptions)) diff --git a/osu.Game/Database/RealmObjectExtensions.cs b/osu.Game/Database/RealmObjectExtensions.cs index 2c4d36f7d0..c334f1152d 100644 --- a/osu.Game/Database/RealmObjectExtensions.cs +++ b/osu.Game/Database/RealmObjectExtensions.cs @@ -299,7 +299,7 @@ namespace osu.Game.Database throw new InvalidOperationException($"Make sure to call {nameof(RealmAccess)}.{nameof(RealmAccess.RegisterForNotifications)}"); bool initial = true; - return collection.SubscribeForNotifications(((sender, changes) => + return collection.SubscribeForNotifications((sender, changes) => { if (initial) { @@ -315,7 +315,7 @@ namespace osu.Game.Database } callback(sender, changes); - })); + }); } /// diff --git a/osu.Game/IO/Archives/ZipArchiveReader.cs b/osu.Game/IO/Archives/ZipArchiveReader.cs index 8b9ecc7462..44cc6b69da 100644 --- a/osu.Game/IO/Archives/ZipArchiveReader.cs +++ b/osu.Game/IO/Archives/ZipArchiveReader.cs @@ -11,6 +11,7 @@ using System.Text; using Microsoft.Toolkit.HighPerformance; using osu.Framework.Extensions; using osu.Framework.IO.Stores; +using SharpCompress.Archives; using SharpCompress.Archives.Zip; using SharpCompress.Common; using SharpCompress.Readers; @@ -28,14 +29,18 @@ namespace osu.Game.IO.Archives public static readonly ArchiveEncoding DEFAULT_ENCODING; private readonly Stream archiveStream; - private readonly ZipArchive archive; + private readonly IWritableArchive archive; static ZipArchiveReader() { // Required to support rare code pages. Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - DEFAULT_ENCODING = new ArchiveEncoding(Encoding.GetEncoding(932), Encoding.GetEncoding(932)); + DEFAULT_ENCODING = new ArchiveEncoding + { + Default = Encoding.GetEncoding(932), + Password = Encoding.GetEncoding(932), + }; } public ZipArchiveReader(Stream archiveStream, string name = null) @@ -43,7 +48,7 @@ namespace osu.Game.IO.Archives { this.archiveStream = archiveStream; - archive = ZipArchive.Open(archiveStream, new ReaderOptions + archive = ZipArchive.OpenArchive(archiveStream, new ReaderOptions { ArchiveEncoding = DEFAULT_ENCODING }); @@ -51,7 +56,7 @@ namespace osu.Game.IO.Archives public override Stream GetStream(string name) { - ZipArchiveEntry entry = archive.Entries.SingleOrDefault(e => e.Key == name); + IArchiveEntry entry = archive.Entries.SingleOrDefault(e => e.Key == name); if (entry == null) return null; diff --git a/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs b/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs index 02c1dfb8df..f6fe576dc2 100644 --- a/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/QuickActionSettings.cs @@ -16,6 +16,8 @@ using osu.Game.Online.Chat; using osu.Game.Overlays.Notifications; using osu.Game.Utils; using SharpCompress.Archives.Zip; +using SharpCompress.Common; +using SharpCompress.Writers.Zip; namespace osu.Game.Overlays.Settings.Sections.General { @@ -93,12 +95,12 @@ namespace osu.Game.Overlays.Settings.Sections.General var logStorage = Logger.Storage; using (var outStream = exportStorage.CreateFileSafely(archive_filename)) - using (var zip = ZipArchive.Create()) + using (var zip = ZipArchive.CreateArchive()) { foreach (string? f in logStorage.GetFiles(string.Empty, "*.log")) FileUtils.AttemptOperation(z => z.AddEntry(f, logStorage.GetStream(f), closeStream: true), zip, throwOnFailure: false); - zip.SaveTo(outStream); + zip.SaveTo(outStream, new ZipWriterOptions(CompressionType.Deflate)); } } catch diff --git a/osu.Game/Rulesets/Edit/Checks/Components/IssueTemplate.cs b/osu.Game/Rulesets/Edit/Checks/Components/IssueTemplate.cs index 97df79ecd8..955bc0265b 100644 --- a/osu.Game/Rulesets/Edit/Checks/Components/IssueTemplate.cs +++ b/osu.Game/Rulesets/Edit/Checks/Components/IssueTemplate.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using Humanizer; using osu.Framework.Graphics; using osuTK.Graphics; @@ -42,7 +41,7 @@ namespace osu.Game.Rulesets.Edit.Checks.Components /// Returns the formatted message given the arguments used to format it. /// /// The arguments used to format the message. - public string GetMessage(params object[] args) => UnformattedMessage.FormatWith(args); + public string GetMessage(params object[] args) => string.Format(UnformattedMessage, args); /// /// Returns the colour corresponding to the type of this issue. diff --git a/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs index 05070d96ec..a03fee5cfd 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs @@ -188,7 +188,7 @@ namespace osu.Game.Scoring.Legacy long compressedSize = replayInStream.Length - replayInStream.Position; - using (var lzma = new LzmaStream(properties, replayInStream, compressedSize, outSize)) + using (var lzma = LzmaStream.Create(properties, replayInStream, compressedSize, outSize)) using (var reader = new StreamReader(lzma)) readFunc(reader); } diff --git a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs index b575c02337..ed1df16573 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs @@ -120,7 +120,7 @@ namespace osu.Game.Scoring.Legacy using (var outStream = new MemoryStream()) { - using (var lzma = new LzmaStream(new LzmaEncoderProperties(false, 1 << 21, 255), false, outStream)) + using (var lzma = LzmaStream.Create(new LzmaEncoderProperties(false, 1 << 21, 255), false, outStream)) { outStream.Write(lzma.Properties); diff --git a/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs b/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs index e84b6bfc72..06f2279ce0 100644 --- a/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs +++ b/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs @@ -179,22 +179,25 @@ namespace osu.Game.Screens.Edit removedIndices = new List(); addedIndices = new List(); + string[] oldArr = result.PiecesOld.ToArray(); + string[] newArr = result.PiecesNew.ToArray(); + // Find the start and end indices of the relevant section headers in both the old and the new beatmap file. Lines changed outside of the modified ranges are ignored. - int oldSectionStartIndex = Array.IndexOf(result.PiecesOld, $"[{section}]"); + int oldSectionStartIndex = Array.IndexOf(oldArr, $"[{section}]"); if (oldSectionStartIndex == -1) return; - int oldSectionEndIndex = Array.FindIndex(result.PiecesOld, oldSectionStartIndex + 1, s => s.StartsWith('[')); + int oldSectionEndIndex = Array.FindIndex(oldArr, oldSectionStartIndex + 1, s => s.StartsWith('[')); if (oldSectionEndIndex == -1) - oldSectionEndIndex = result.PiecesOld.Length; + oldSectionEndIndex = oldArr.Length; - int newSectionStartIndex = Array.IndexOf(result.PiecesNew, $"[{section}]"); + int newSectionStartIndex = Array.IndexOf(newArr, $"[{section}]"); if (newSectionStartIndex == -1) return; - int newSectionEndIndex = Array.FindIndex(result.PiecesNew, newSectionStartIndex + 1, s => s.StartsWith('[')); + int newSectionEndIndex = Array.FindIndex(newArr, newSectionStartIndex + 1, s => s.StartsWith('[')); if (newSectionEndIndex == -1) - newSectionEndIndex = result.PiecesNew.Length; + newSectionEndIndex = newArr.Length; foreach (var block in result.DiffBlocks) { diff --git a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs index b57b0daa1b..15cd54baad 100644 --- a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs +++ b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs @@ -11,6 +11,7 @@ using System.Reflection; using System.Threading.Tasks; using Newtonsoft.Json; using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Framework.Audio.Track; using osu.Framework.Extensions; using osu.Framework.Extensions.ObjectExtensions; @@ -133,7 +134,7 @@ namespace osu.Game.Tests.Beatmaps string afterConversion = beatmap.Serialize(); - Assert.AreEqual(beforeConversion, afterConversion, "Conversion altered original beatmap"); + ClassicAssert.AreEqual(beforeConversion, afterConversion, "Conversion altered original beatmap"); return new ConvertResult { diff --git a/osu.Game/Tests/Beatmaps/LegacyModConversionTest.cs b/osu.Game/Tests/Beatmaps/LegacyModConversionTest.cs index b7803f3420..4cab848648 100644 --- a/osu.Game/Tests/Beatmaps/LegacyModConversionTest.cs +++ b/osu.Game/Tests/Beatmaps/LegacyModConversionTest.cs @@ -3,7 +3,7 @@ using System; using System.Linq; -using NUnit.Framework; +using NUnit.Framework.Legacy; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets; @@ -23,11 +23,11 @@ namespace osu.Game.Tests.Beatmaps { var ruleset = CreateRuleset(); var mods = ruleset.ConvertFromLegacyMods(legacyMods).ToList(); - Assert.AreEqual(expectedMods.Length, mods.Count); + ClassicAssert.AreEqual(expectedMods.Length, mods.Count); foreach (var modType in expectedMods) { - Assert.IsNotNull(mods.SingleOrDefault(mod => mod.GetType() == modType)); + ClassicAssert.NotNull(mods.SingleOrDefault(mod => mod.GetType() == modType)); } } @@ -38,7 +38,7 @@ namespace osu.Game.Tests.Beatmaps .Where(mod => providedModTypes.Contains(mod.GetType())) .ToArray(); var actualLegacyMods = ruleset.ConvertToLegacyMods(modInstances); - Assert.AreEqual(expectedLegacyMods, actualLegacyMods); + ClassicAssert.AreEqual(expectedLegacyMods, actualLegacyMods); } } } diff --git a/osu.Game/Utils/ZipUtils.cs b/osu.Game/Utils/ZipUtils.cs index bebeff29d8..8eb4c04914 100644 --- a/osu.Game/Utils/ZipUtils.cs +++ b/osu.Game/Utils/ZipUtils.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Linq; using SharpCompress.Archives.Zip; namespace osu.Game.Utils @@ -15,7 +16,7 @@ namespace osu.Game.Utils { stream.Seek(0, SeekOrigin.Begin); - using (var arc = ZipArchive.Open(stream)) + using (var arc = ZipArchive.OpenArchive(stream)) { foreach (var entry in arc.Entries) { @@ -30,7 +31,7 @@ namespace osu.Game.Utils // the worst case is that it's actually *not* a zip and instead a stream of binary // which *accidentally* happened to contain the magic sequence of bytes for the zip header (50 4b 05 06), // and if that's the case, then we are *misclassifying* it as a zip by returning `true` unconditionally. - return arc.Entries.Count > 0; + return arc.Entries.Any(); } } catch (Exception) @@ -50,7 +51,7 @@ namespace osu.Game.Utils try { - using (var arc = ZipArchive.Open(path)) + using (var arc = ZipArchive.OpenArchive(path)) { foreach (var entry in arc.Entries) { @@ -65,7 +66,7 @@ namespace osu.Game.Utils // the worst case is that it's actually *not* a zip and instead a stream of binary // which *accidentally* happened to contain the magic sequence of bytes for the zip header (50 4b 05 06), // and if that's the case, then we are *misclassifying* it as a zip by returning `true` unconditionally. - return arc.Entries.Count > 0; + return arc.Entries.Any(); } } catch (Exception) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 384d5412a8..60b3546d85 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,18 +18,22 @@ - - - + + + NU1903 + + + + - - - - - - + + + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -37,11 +41,11 @@ - + - - - + + +