Skip to content

Commit

Permalink
test: FluentAssertions removed (#346)
Browse files Browse the repository at this point in the history
* test: FluentAssertions removed

* test: Removed linter errors

* test: Code cleanup

* test: Fixed linter errors

* build: Set DOTNET_INSTALL_DIR
  • Loading branch information
marklechtermann authored Jan 25, 2025
1 parent 205f0d9 commit 74f069c
Show file tree
Hide file tree
Showing 23 changed files with 828 additions and 862 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ jobs:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v4.2.0
with:
global-json-file: global.json

env:
# https://github.com/dotnet/sdk/issues/44957
DOTNET_INSTALL_DIR: ${{ runner.temp }}/.dotnet
- name: Restore dependencies
run: dotnet restore

Expand Down
8 changes: 3 additions & 5 deletions src/dscom.test/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static class Extensions
public static DisposableStruct<VARDESC>? GetVarDescByName(this ITypeInfo2 typeInfo, string name)
{
using var attributes = typeInfo.GetTypeInfoAttributes();
attributes.Should().NotBeNull();
Assert.NotNull(attributes);

int numberOfVars = attributes!.Value.cVars;
for (var i = 0; i < numberOfVars; i++)
Expand Down Expand Up @@ -113,8 +113,7 @@ public static class Extensions
{
typeInfo.GetTypeAttr(out var ppTypAttr);

using var attribute = typeInfo.GetTypeInfoAttributes();
attribute.Should().NotBeNull();
using var attribute = typeInfo.GetTypeInfoAttributes() ?? throw new InvalidOperationException("TypeInfo attributes should not be null.");
int numberOfFunction = attribute!.Value.cFuncs;
for (var i = 0; i < numberOfFunction; i++)
{
Expand Down Expand Up @@ -154,8 +153,7 @@ public static bool ContainsFuncDescByName(this ITypeInfo2 typeInfo, string name)
public static KeyValuePair<string, object>[] GetAllEnumValues(this ITypeInfo2 typeInfo)
{
var retVal = new List<KeyValuePair<string, object>>();
using var attribute = typeInfo.GetTypeInfoAttributes();
attribute.Should().NotBeNull();
using var attribute = typeInfo.GetTypeInfoAttributes() ?? throw new InvalidOperationException("TypeInfo attributes should not be null.");
var count = attribute!.Value.cVars;
for (short i = 0; i < count; i++)
{
Expand Down
8 changes: 8 additions & 0 deletions src/dscom.test/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Style", "IDE0005:Using directive is unnecessary.", Justification = "<Pending>")]
1 change: 0 additions & 1 deletion src/dscom.test/GlobalUsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
global using System.Reflection.Emit;
global using System.Runtime.CompilerServices;
global using System.Text.RegularExpressions;
global using FluentAssertions;
global using Xunit;

#pragma warning disable CS8019
Expand Down
1 change: 0 additions & 1 deletion src/dscom.test/dscom.test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="[7.0.0]" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="moq" Version="4.20.72" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
Expand Down
17 changes: 9 additions & 8 deletions src/dscom.test/tests/AttributeFlagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

using dSPACE.Runtime.InteropServices.Attributes;
using Xunit;
using FUNCFLAGS = System.Runtime.InteropServices.ComTypes.FUNCFLAGS;

namespace dSPACE.Runtime.InteropServices.Tests;
Expand All @@ -39,11 +40,11 @@ public void HiddenAttributes_Considered(bool? interfacesHiddenAttribute, bool in

if (interfaceIsHidden)
{
flags.Should().HaveFlag(TYPEFLAGS.TYPEFLAG_FHIDDEN);
Assert.True(flags.HasValue && flags.Value.HasFlag(TYPEFLAGS.TYPEFLAG_FHIDDEN));
}
else
{
flags.Should().NotHaveFlag(TYPEFLAGS.TYPEFLAG_FHIDDEN);
Assert.False(flags.HasValue && flags.Value.HasFlag(TYPEFLAGS.TYPEFLAG_FHIDDEN));
}
}

Expand All @@ -68,11 +69,11 @@ public void HiddenMemberAttributes_Considered(bool? memberHdden, bool memberIsHi

if (memberIsHidden)
{
flags.Should().HaveFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN);
Assert.True(flags.HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN));
}
else
{
flags.Should().NotHaveFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN);
Assert.False(flags.HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN));
}
}

Expand All @@ -96,11 +97,11 @@ public void RestrictedAttributes_Considered(bool? interfacesRestrictedAttribute,

if (interfaceIsRestricted)
{
flags.Should().HaveFlag(TYPEFLAGS.TYPEFLAG_FRESTRICTED);
Assert.True(flags.HasValue && flags.Value.HasFlag(TYPEFLAGS.TYPEFLAG_FRESTRICTED));
}
else
{
flags.Should().NotHaveFlag(TYPEFLAGS.TYPEFLAG_FRESTRICTED);
Assert.False(flags.HasValue && flags.Value.HasFlag(TYPEFLAGS.TYPEFLAG_FRESTRICTED));
}
}

Expand All @@ -125,11 +126,11 @@ public void RestrictedMemberAttributes_Considered(bool? memberHdden, bool member

if (memberIsRestricted)
{
flags.Should().HaveFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED);
Assert.True(flags.HasFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED));
}
else
{
flags.Should().NotHaveFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED);
Assert.False(flags.HasFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED));
}
}
}
Loading

0 comments on commit 74f069c

Please sign in to comment.