Skip to content

Commit

Permalink
Fixed nullable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
leMicin committed Jul 25, 2024
1 parent d251ec2 commit 796149e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/Sidekick.Mock/MockClipboardProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sidekick.Mock
{
public class MockClipboardProvider : IClipboardProvider
{
public Task<string> Copy()
public Task<string?> Copy()
{
throw new NotImplementedException();
}
Expand All @@ -16,12 +16,12 @@ public Task<string> CopyAdvanced()
throw new NotImplementedException();
}

public Task<string> GetText()
public Task<string?> GetText()
{
throw new NotImplementedException();
}

public Task SetText(string text)
public Task SetText(string? text)
{
return Task.CompletedTask;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sidekick.Mock/MockKeyboardProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MockKeyboardProvider : IKeyboardProvider

#pragma warning disable CS0067

public event Action<string> OnKeyDown;
public event Action<string>? OnKeyDown;

#pragma warning restore CS0067

Expand Down
4 changes: 2 additions & 2 deletions src/Sidekick.Mock/MockProcessProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class MockProcessProvider : IProcessProvider
{
public string ClientLogPath => string.Empty;

public event Action OnFocus;
public event Action? OnFocus;

public event Action OnBlur;
public event Action? OnBlur;

public bool IsPathOfExileInFocus => true;
public bool IsSidekickInFocus => false;
Expand Down
17 changes: 8 additions & 9 deletions tests/Sidekick.Apis.Poe.Tests/ItemExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using Sidekick.Common.Game.Items;
using Xunit;

Expand All @@ -8,7 +7,7 @@ public static class ItemExtensions
{
public static void AssertHasModifier(this Item actual, ModifierCategory expectedCategory, string expectedText, params double[] expectedValues)
{
var modifiers = actual?.ModifierLines
var modifiers = actual.ModifierLines
.SelectMany(line => line.Modifiers.Select(modifier => new
{
Line = line,
Expand All @@ -19,7 +18,7 @@ public static void AssertHasModifier(this Item actual, ModifierCategory expected
Assert.Equal(expectedText, actualModifier?.Modifier.Text);
Assert.Equal(expectedCategory, actualModifier?.Modifier.Category);

Assert.True(actualModifier.Line.Values.Count == expectedValues.Length);
Assert.True(actualModifier?.Line.Values.Count == expectedValues.Length);

for (var i = 0; i < expectedValues.Length; i++)
{
Expand All @@ -29,18 +28,18 @@ public static void AssertHasModifier(this Item actual, ModifierCategory expected

public static void AssertHasAlternateModifier(this Item actual, ModifierCategory expectedCategory, string expectedText, params double[] expectedValues)
{
var modifiers = actual?.ModifierLines
var modifiers = actual.ModifierLines
.SelectMany(line => line.Modifiers.Select(modifier => new
{
Line = line,
Modifier = modifier,
}));

var actualModifier = modifiers?.FirstOrDefault(x => expectedCategory == x.Modifier.Category && expectedText == x.Modifier.Text);
var actualModifier = modifiers.FirstOrDefault(x => expectedCategory == x.Modifier.Category && expectedText == x.Modifier.Text);
Assert.Equal(expectedText, actualModifier?.Modifier.Text);
Assert.Equal(expectedCategory, actualModifier?.Modifier.Category);

Assert.True(actualModifier.Line.Values.Count >= expectedValues.Length);
Assert.True(actualModifier?.Line.Values.Count >= expectedValues.Length);

for (var i = 0; i < expectedValues.Length; i++)
{
Expand All @@ -50,12 +49,12 @@ public static void AssertHasAlternateModifier(this Item actual, ModifierCategory

public static void AssertHasPseudoModifier(this Item actual, string expectedText, double? expectedValue = null)
{
var actualModifier = actual?.PseudoModifiers?.FirstOrDefault(x => expectedText == x.Text);
Assert.Equal(expectedText, actualModifier.Text);
var actualModifier = actual.PseudoModifiers.FirstOrDefault(x => expectedText == x.Text);
Assert.Equal(expectedText, actualModifier?.Text);

if (expectedValue != null)
{
Assert.Equal(expectedValue, actualModifier.Value);
Assert.Equal(expectedValue, actualModifier?.Value);
}
}
}
Expand Down

0 comments on commit 796149e

Please sign in to comment.