Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade target framework from NET Standard 2.0 to .NET 6.0 #393

Merged
merged 33 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
827bf53
All Set and done
YBTopaz8 Nov 28, 2024
72754d6
Update UI elements, add icons, and conditional compilation
YBTopaz8 Nov 28, 2024
dbb9ad1
Refactor and enhance UI and services
YBTopaz8 Nov 29, 2024
4bdec70
Refactor and update ParseLiveQueryClient and projects
YBTopaz8 Nov 30, 2024
ac325b2
Refactor and enhance FlowHub-MAUI and ParseLiveQuery
YBTopaz8 Nov 30, 2024
b13afac
Refactor methods to use block bodies for readability
YBTopaz8 Dec 1, 2024
b5057d4
save
YBTopaz8 Dec 1, 2024
1c29bc1
Finally Fixed for .net 9 and MAUI
YBTopaz8 Dec 2, 2024
fe93551
Upgraded to .NET6+ & Updated UnitTests
YBTopaz8 Dec 8, 2024
838e2d8
Enhance .NET Compatibility & Complete TODOs
YBTopaz8 Dec 10, 2024
ece8084
Merge branch 'master' into Testt
mtrezza Dec 10, 2024
d3164c5
Update Parse/Infrastructure/CacheController.cs
YBTopaz8 Dec 11, 2024
ccf2807
Improved Locking Mechanism, now using SemaphoreLock and some minor ch…
YBTopaz8 Dec 11, 2024
e5bbeba
Fully Fixed Parse SDK
YBTopaz8 Dec 12, 2024
e478005
update CI
mtrezza Dec 13, 2024
9124596
Update ci.yml
mtrezza Dec 13, 2024
281130f
Update ci.yml
mtrezza Dec 13, 2024
4940f44
Simplify targets, update tests, and enhance error handling
YBTopaz8 Dec 13, 2024
60e9356
Merge branch 'Testt' of https://github.com/YBTopaz8/Parse-SDK-dotNET …
YBTopaz8 Dec 13, 2024
c35b893
Fixed compat issue brought by VS
YBTopaz8 Dec 13, 2024
8b2af66
Re-Added several .net target versions to now 6,7,8,9 instead of only 8
YBTopaz8 Dec 13, 2024
b0e6082
Reverted Proj changes not destined here
YBTopaz8 Dec 13, 2024
d28e03c
All set.
YBTopaz8 Dec 13, 2024
760e11e
Update ci.yml
mtrezza Dec 13, 2024
369a1a6
Update ci.yml
mtrezza Dec 13, 2024
848d6eb
Update ci.yml
mtrezza Dec 13, 2024
09965a5
Test in multiple NET frameworks
mtrezza Dec 13, 2024
50b8671
Update ci.yml
mtrezza Dec 13, 2024
5bcc989
add .NET badge to README
mtrezza Dec 13, 2024
513955c
add compat table to README
mtrezza Dec 13, 2024
5623f88
Fixed LogOut Issues in Parse SDK itself.
YBTopaz8 Dec 17, 2024
d68e0b1
Merge branch 'Testt' of https://github.com/YBTopaz8/Parse-SDK-dotNET …
YBTopaz8 Dec 17, 2024
c694198
Fixed Test TargetFramework
YBTopaz8 Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ on:
paths-ignore:
- '**/**.md'
jobs:
check-ci:
check-dotnet:
strategy:
matrix:
DOTNET_VERSION: ['6.0', '7.0', '8.0', '9.0']
fail-fast: false
name: .NET ${{ matrix.DOTNET_VERSION }}
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.x'
dotnet-version: ${{ matrix.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.nuget/packages
Expand All @@ -36,7 +41,7 @@ jobs:
run: dotnet build Parse.sln --configuration Debug --no-restore
- name: Run tests with coverage
run: |
OpenCover.Console.exe -target:dotnet.exe -targetargs:"test --configuration Debug --test-adapter-path:. --logger:console /p:DebugType=full .\Parse.Tests\Parse.Tests.csproj" -filter:"+[Parse*]* -[Parse.Tests*]*" -oldstyle -output:parse_sdk_dotnet_coverage.xml -register:user
OpenCover.Console.exe -target:dotnet.exe -targetargs:"test --framework net${{ matrix.DOTNET_VERSION }} --configuration Debug --test-adapter-path:. --logger:console /p:DebugType=full .\Parse.Tests\Parse.Tests.csproj" -filter:"+[Parse*]* -[Parse.Tests*]*" -oldstyle -output:parse_sdk_dotnet_coverage.xml -register:user
- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
Expand Down
162 changes: 117 additions & 45 deletions Parse.Tests/ACLTests.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,130 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq; // Add Moq for mocking if not already added
using Parse.Infrastructure;
using Parse.Platform.Objects;
using Parse.Abstractions.Infrastructure;
using Parse.Abstractions.Platform.Objects;

namespace Parse.Tests
namespace Parse.Tests;

[TestClass]
public class ACLTests
{
[TestClass]
public class ACLTests
ParseClient Client { get; set; }

Mock<IServiceHub> ServiceHubMock { get; set; }
Mock<IParseObjectClassController> ClassControllerMock { get; set; }

[TestInitialize]
public void Initialize()
{
ParseClient Client { get; set; } = new ParseClient(new ServerConnectionData { Test = true });
// Mock ServiceHub
ServiceHubMock = new Mock<IServiceHub>();
ClassControllerMock = new Mock<IParseObjectClassController>();

[TestInitialize]
public void Initialize()
{
Client.AddValidClass<ParseUser>();
Client.AddValidClass<ParseSession>();
}
// Mock ClassController behavior
ServiceHubMock.Setup(hub => hub.ClassController).Returns(ClassControllerMock.Object);

[TestCleanup]
public void Clean() => (Client.Services as ServiceHub).Reset();
// Mock ClassController.Instantiate behavior
ClassControllerMock.Setup(controller => controller.Instantiate(It.IsAny<string>(), It.IsAny<IServiceHub>()))
.Returns<string, IServiceHub>((className, hub) =>
{
var user = new ParseUser();
user.Bind(hub); // Ensure the object is bound to the service hub
return user;
});

[TestMethod]
public void TestCheckPermissionsWithParseUserConstructor()
// Set up ParseClient with the mocked ServiceHub
Client = new ParseClient(new ServerConnectionData { Test = true })
{
ParseUser owner = GenerateUser("OwnerUser");
ParseUser user = GenerateUser("OtherUser");
ParseACL acl = new ParseACL(owner);
Assert.IsTrue(acl.GetReadAccess(owner.ObjectId));
Assert.IsTrue(acl.GetWriteAccess(owner.ObjectId));
Assert.IsTrue(acl.GetReadAccess(owner));
Assert.IsTrue(acl.GetWriteAccess(owner));
}

[TestMethod]
public void TestReadWriteMutationWithParseUserConstructor()
{
ParseUser owner = GenerateUser("OwnerUser");
ParseUser otherUser = GenerateUser("OtherUser");
ParseACL acl = new ParseACL(owner);
acl.SetReadAccess(otherUser, true);
acl.SetWriteAccess(otherUser, true);
acl.SetReadAccess(owner.ObjectId, false);
acl.SetWriteAccess(owner.ObjectId, false);
Assert.IsTrue(acl.GetReadAccess(otherUser.ObjectId));
Assert.IsTrue(acl.GetWriteAccess(otherUser.ObjectId));
Assert.IsTrue(acl.GetReadAccess(otherUser));
Assert.IsTrue(acl.GetWriteAccess(otherUser));
Assert.IsFalse(acl.GetReadAccess(owner));
Assert.IsFalse(acl.GetWriteAccess(owner));
}

[TestMethod]
public void TestParseACLCreationWithNullObjectIdParseUser() => Assert.ThrowsException<ArgumentException>(() => new ParseACL(GenerateUser(default)));

ParseUser GenerateUser(string objectID) => Client.GenerateObjectFromState<ParseUser>(new MutableObjectState { ObjectId = objectID }, "_User");
Services = ServiceHubMock.Object
};

// Publicize the client to set ParseClient.Instance
Client.Publicize();

// Add valid classes to the client
Client.AddValidClass<ParseUser>();
Client.AddValidClass<ParseSession>();
}

[TestCleanup]
public void Clean() => (Client.Services as ServiceHub)?.Reset();

[TestMethod]
public void TestCheckPermissionsWithParseUserConstructor()
{
// Arrange
ParseUser owner = GenerateUser("OwnerUser");
ParseUser user = GenerateUser("OtherUser");

// Act
ParseACL acl = new ParseACL(owner);

// Assert
Assert.IsTrue(acl.GetReadAccess(owner.ObjectId));
Assert.IsTrue(acl.GetWriteAccess(owner.ObjectId));
Assert.IsTrue(acl.GetReadAccess(owner));
Assert.IsTrue(acl.GetWriteAccess(owner));
}

[TestMethod]
public void TestReadWriteMutationWithParseUserConstructor()
{
// Arrange
ParseUser owner = GenerateUser("OwnerUser");
ParseUser otherUser = GenerateUser("OtherUser");

// Act
ParseACL acl = new ParseACL(owner);
acl.SetReadAccess(otherUser, true);
acl.SetWriteAccess(otherUser, true);
acl.SetReadAccess(owner.ObjectId, false);
acl.SetWriteAccess(owner.ObjectId, false);

// Assert
Assert.IsTrue(acl.GetReadAccess(otherUser.ObjectId));
Assert.IsTrue(acl.GetWriteAccess(otherUser.ObjectId));
Assert.IsTrue(acl.GetReadAccess(otherUser));
Assert.IsTrue(acl.GetWriteAccess(otherUser));
Assert.IsFalse(acl.GetReadAccess(owner));
Assert.IsFalse(acl.GetWriteAccess(owner));
}

[TestMethod]
public void TestParseACLCreationWithNullObjectIdParseUser()
{
// Assert
Assert.ThrowsException<ArgumentException>(() => new ParseACL(GenerateUser(default)));
}

ParseUser GenerateUser(string objectID)
{
// Use the mock to simulate generating a ParseUser
var state = new MutableObjectState { ObjectId = objectID };
return Client.GenerateObjectFromState<ParseUser>(state, "_User");
}

[TestMethod]
public void TestGenerateObjectFromState()
{
// Arrange
var state = new MutableObjectState { ObjectId = "123", ClassName = null };
var defaultClassName = "_User";

var serviceHubMock = new Mock<IServiceHub>();
var classControllerMock = new Mock<IParseObjectClassController>();

classControllerMock.Setup(controller => controller.Instantiate(It.IsAny<string>(), It.IsAny<IServiceHub>()))
.Returns<string, IServiceHub>((className, hub) => new ParseUser());

// Act
var user = classControllerMock.Object.GenerateObjectFromState<ParseUser>(state, defaultClassName, serviceHubMock.Object);

// Assert
Assert.IsNotNull(user);
Assert.AreEqual(defaultClassName, user.ClassName);
}

}
Loading
Loading