Skip to content
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e0d63ab
Add ParseLiveQuery and dependencies
theSlyest Jun 19, 2025
d7c8c71
Added ParseLiveQuerySubscription and refactored accordingly
theSlyest Jun 20, 2025
0932e35
Added EventArgs
theSlyest Jun 21, 2025
8740db2
ParseLiveQueryController initialization
theSlyest Jun 22, 2025
542e3cb
Subscription bug fixes
theSlyest Jun 23, 2025
40044a2
Updated event argument types
theSlyest Jun 23, 2025
0f737a0
Added DualParseLiveQueryEventArgs
theSlyest Jun 23, 2025
98e295a
Live query server error management
theSlyest Jun 23, 2025
c0a6bec
Renamed DualParseLiveQueryEventArgs to ParseLiveQueryDualEventArgs
theSlyest Jun 24, 2025
a267f63
Code quality
theSlyest Jun 25, 2025
4b83d23
Improve code quality
theSlyest Jun 25, 2025
65c73e4
Add null safety for the "where" clause extraction
theSlyest Jun 25, 2025
340f6fb
Improve code quality
theSlyest Jun 25, 2025
7e66bb6
Improvements
theSlyest Jun 25, 2025
84f7060
Null checks
theSlyest Jun 25, 2025
834ff89
Move TimeOut and BufferSize to new LiveQueryServerConnectionData and …
theSlyest Jun 27, 2025
bd36b7d
Minor improvements
theSlyest Jun 28, 2025
e9c6bcc
Improve message parsing
theSlyest Jun 30, 2025
8938a4d
Improve the retrieval of data objects from a message
theSlyest Jun 30, 2025
b65e230
Null safety and small changes
theSlyest Jun 30, 2025
cc5168c
Improve controller disposal
theSlyest Jun 30, 2025
e70789e
Fix race conditions
theSlyest Jun 30, 2025
2cfef04
Websocket exception handling
theSlyest Jun 30, 2025
97313bf
Small clean up
theSlyest Jun 30, 2025
f3374f6
Fix test error
theSlyest Jul 9, 2025
62e81fb
Fix RelationTests
theSlyest Jul 10, 2025
a76014f
Fix UserTests
theSlyest Jul 10, 2025
fbe273a
Fix RelationTests for net9.0
theSlyest Jul 10, 2025
c59316b
Add live query and live query event arg tests
theSlyest Jul 26, 2025
d9ec311
Live query event args test corrections
theSlyest Jul 26, 2025
e3b5df9
Code quality improvement
theSlyest Jul 26, 2025
70e587a
Fix tests
theSlyest Aug 11, 2025
6a50ce4
Tests code quality
theSlyest Aug 29, 2025
871f015
Replaced "int TimeOut" by "TimeSpan Timeout" and other improvements
theSlyest Aug 29, 2025
5444d5d
Improve code quality
theSlyest Aug 29, 2025
96b20f6
Code rabbits improvements
theSlyest Aug 29, 2025
854beaa
Refactor and add tests
theSlyest Sep 8, 2025
a13c7ab
Moved responsibilities from ParseLiveQueryController to 2 new classes
theSlyest Sep 10, 2025
b86a45a
Fine tuning some tests
theSlyest Sep 11, 2025
ea60936
Added TextWebSocketClientTests
theSlyest Sep 16, 2025
8341e12
CodeRabbit required changes
theSlyest Sep 16, 2025
a608262
CodeRabbit requested changes
theSlyest Sep 16, 2025
75b3816
Added tests
theSlyest Feb 24, 2026
b676df1
CodeRabbitAI suggested changes
theSlyest Feb 24, 2026
da1aea7
Merge branch 'master' into livequery
theSlyest Feb 24, 2026
5ae15c6
CodeRabbitAI suggestions
theSlyest Feb 24, 2026
e983359
CodeRabbitAI suggested changes
theSlyest Feb 24, 2026
d9669e9
Suggested changes
theSlyest Feb 25, 2026
ed1a751
CodeRabbitAI suggestions
theSlyest Feb 25, 2026
86cdeac
Add ParseClient constructor test with LiveQuery
theSlyest Feb 26, 2026
172a4fc
Add missing tests
theSlyest Feb 26, 2026
1fc8184
Add ServiceHub unit tests
theSlyest Feb 26, 2026
38dd690
Suggested changes
theSlyest Feb 26, 2026
43c5da1
Requested changes
theSlyest Feb 27, 2026
e90c570
Fixed failing test
theSlyest Feb 27, 2026
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
45 changes: 45 additions & 0 deletions Parse.Tests/ClientTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parse.Infrastructure;

namespace Parse.Tests;

[TestClass]
public class ClientTests
{
[TestMethod]
public void TestParseClientConstructor()
{
ParseClient client = new("appId", "https://parse.example.com/", "dotnetKey");
Assert.AreEqual("appId", client.ServerConnectionData.ApplicationID);
Assert.AreEqual("https://parse.example.com/", client.ServerConnectionData.ServerURI);
Assert.AreEqual("dotnetKey", client.ServerConnectionData.Key);
}

[TestMethod]
public void TestPublicize()
{
ParseClient previous = ParseClient.Instance;
ParseClient client = new("appId", "https://parse.example.com/", "dotnetKey");
try {
client.Publicize();
Assert.AreSame(client, ParseClient.Instance);
} finally {
previous?.Publicize();
}
}
Comment thread
theSlyest marked this conversation as resolved.

[TestMethod]
public void TestConstructorWithTestTrue()
{
ServerConnectionData data = new()
{
ApplicationID = "appId",
ServerURI = "https://parse.example.com/",
Key = "key",
Test = true
};
ParseClient client = new(data);
Assert.AreEqual("https://parse.example.com/", client.ServerConnectionData.ServerURI);
}
}
5 changes: 5 additions & 0 deletions Parse.Tests/DecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public class DecoderTests
{
ParseClient Client { get; } = new ParseClient(new ServerConnectionData { Test = true });

public DecoderTests()
{
Client.Publicize();
}

[TestMethod]
public void TestParseDate()
{
Expand Down
5 changes: 5 additions & 0 deletions Parse.Tests/EncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class ParseEncoderTestClass : ParseDataEncoder
protected override IDictionary<string, object> EncodeObject(ParseObject value) => null;
}

public EncoderTests()
{
Client.Publicize();
}

[TestMethod]
public void TestIsValidType()
{
Expand Down
73 changes: 73 additions & 0 deletions Parse.Tests/InfrastructureTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parse.Infrastructure.Utilities;

namespace Parse.Tests;

[TestClass]
public class InfrastructureTests
{
[TestMethod]
public void TestFlexibleDictionaryWrapper()
{
// Arrange
Dictionary<string, int> inner = new()
{
{ "char", 1 },
{ "string", 594 }
};
FlexibleDictionaryWrapper<int, int> wrapper = new(inner);

// Act & Assert
Assert.AreEqual<int>(1, wrapper["char"]);
Assert.AreEqual<int>(594, wrapper["string"]);

wrapper["new"] = 615;
Assert.AreEqual<int>(615, inner["new"]);
}

[TestMethod]
public void TestFlexibleListWrapper()
{
// Arrange
List<object> inner = [1, 6.7f];
FlexibleListWrapper<int, object> wrapper = new(inner);

// Act & Assert
Assert.AreEqual(1, wrapper[0]);
Assert.AreEqual(7, wrapper[1]);

wrapper.Add(2);
Assert.AreEqual(2, inner[2]);
}

[TestMethod]
public void TestConversion()
{
// Test basic conversions
Assert.AreEqual(123, Conversion.ConvertTo<int>("123"));
Assert.AreEqual(123L, Conversion.ConvertTo<long>(123));
Assert.AreEqual(123.45, (double)Conversion.ConvertTo<double>("123.45"), 1e-10);
}

[TestMethod]
public void TestGetOrDefault()
{
Dictionary<string, string> dict = new Dictionary<string, string> { { "key", "value" } };
Assert.AreEqual("value", dict.GetOrDefault("key", "default"));
Assert.AreEqual("default", dict.GetOrDefault("missing", "default"));
}

[TestMethod]
public void TestCollectionsEqual()
{
List<int> list1 = [1, 2, 3];
List<int> list2 = [1, 2, 3];
List<int> list3 = [1, 2, 4];

Assert.IsTrue(list1.CollectionsEqual(list2));
Assert.IsFalse(list1.CollectionsEqual(list3));
Assert.IsFalse(list1.CollectionsEqual(null));
Assert.IsTrue(((List<int>)null).CollectionsEqual(null));
}
}
83 changes: 83 additions & 0 deletions Parse.Tests/LiveQueryDualEventArgsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parse.Abstractions.Platform.Objects;
using Parse.Infrastructure;
using Parse.Platform.LiveQueries;
using Parse.Platform.Objects;

namespace Parse.Tests;

[TestClass]
public class LiveQueryDualEventArgsTests
{
private ParseClient Client { get; } = new ParseClient(new ServerConnectionData { Test = true });

public LiveQueryDualEventArgsTests()
{
Client.Publicize();
}

[TestMethod]
public void TestConstructor()
{
IObjectState state = new MutableObjectState
{
ObjectId = "waGiManPutr4Pet1r",
ClassName = "Pagi",
CreatedAt = new DateTime { },
ServerData = new Dictionary<string, object>
{
["username"] = "kevin",
["sessionToken"] = "se551onT0k3n"
}
};

ParseObject obj = Client.GenerateObjectFromState<ParseObject>(state, "Corgi");
obj.Set("test", "after");
ParseObject objOrig = Client.GenerateObjectFromState<ParseObject>(state, "Corgi");
objOrig.Set("test", "before");
ParseLiveQueryDualEventArgs args = new ParseLiveQueryDualEventArgs(obj, objOrig);

Assert.AreSame(obj, args.Object);
Assert.AreSame(objOrig, args.Original);
}

[TestMethod]
public void TestCurrent()
{
IObjectState state = new MutableObjectState
{
ObjectId = "waGiManPutr4Pet1r",
ClassName = "Pagi",
CreatedAt = new DateTime { },
ServerData = new Dictionary<string, object>
{
["username"] = "kevin",
["sessionToken"] = "se551onT0k3n"
}
};

ParseObject objOrig = Client.GenerateObjectFromState<ParseObject>(state, "Corgi");
Assert.ThrowsExactly<ArgumentNullException>(() => new ParseLiveQueryDualEventArgs(null, objOrig));
}

[TestMethod]
public void TestConstructorExceptionOriginal()
{
IObjectState state = new MutableObjectState
{
ObjectId = "waGiManPutr4Pet1r",
ClassName = "Pagi",
CreatedAt = new DateTime { },
ServerData = new Dictionary<string, object>
{
["username"] = "kevin",
["sessionToken"] = "se551onT0k3n"
}
};

ParseObject obj = Client.GenerateObjectFromState<ParseObject>(state, "Corgi");
Assert.ThrowsExactly<ArgumentNullException>(() => new ParseLiveQueryDualEventArgs(obj, null));
}
}
34 changes: 34 additions & 0 deletions Parse.Tests/LiveQueryErrorEventArgsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parse.Platform.LiveQueries;

namespace Parse.Tests;

[TestClass]
public class LiveQueryErrorEventArgsTests
{
[TestMethod]
public void TestConstructor()
{
InvalidOperationException exception = new InvalidOperationException("Test exception");
ParseLiveQueryErrorEventArgs args = new ParseLiveQueryErrorEventArgs(42, "Test error", false, exception);

// Assert
Assert.AreEqual(42, args.Code);
Assert.AreEqual("Test error", args.Error);
Assert.AreEqual(false, args.Reconnect);
Assert.AreEqual(exception, args.LocalException);
}

[TestMethod]
public void TestConstructorWithoutException()
{
ParseLiveQueryErrorEventArgs args = new ParseLiveQueryErrorEventArgs(42, "Test error", true);

// Assert
Assert.AreEqual(42, args.Code);
Assert.AreEqual("Test error", args.Error);
Assert.AreEqual(true, args.Reconnect);
Assert.AreEqual(null, args.LocalException);
}
}
46 changes: 46 additions & 0 deletions Parse.Tests/LiveQueryEventArgsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parse.Abstractions.Platform.Objects;
using Parse.Infrastructure;
using Parse.Platform.LiveQueries;
using Parse.Platform.Objects;

namespace Parse.Tests;

[TestClass]
public class LiveQueryEventArgsTests
{
private ParseClient Client { get; } = new ParseClient(new ServerConnectionData { Test = true });

public LiveQueryEventArgsTests()
{
Client.Publicize();
}

[TestMethod]
public void TestConstructor()
{
IObjectState state = new MutableObjectState
{
ObjectId = "waGiManPutr4Pet1r",
ClassName = "Pagi",
CreatedAt = new DateTime { },
ServerData = new Dictionary<string, object>
{
["username"] = "kevin",
["sessionToken"] = "se551onT0k3n"
}
};

ParseObject obj = Client.GenerateObjectFromState<ParseObject>(state, "Corgi");
ParseLiveQueryEventArgs args = new ParseLiveQueryEventArgs(obj);

// Assert
Assert.AreEqual(obj, args.Object);
}

[TestMethod]
public void TestConstructorException()
=> Assert.ThrowsExactly<ArgumentNullException>(() => new ParseLiveQueryEventArgs(null));
}
Loading