Skip to content

Commit

Permalink
Re-enable tests and remove SynchronizationContext solution
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-grzesiowski committed Feb 6, 2025
1 parent 49fb23f commit 0fdb06e
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -199,4 +199,4 @@ public async Task TestEmitUserMention()
var received = receivedManualEvent.WaitOne(7000);
Assert.True(received);
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -55,4 +55,4 @@ public async Task TestModerationEvents()
var moderationEventReceived = manualModerationEvent.WaitOne(5000);
Assert.IsTrue(moderationEventReceived);
}
}*/
}
4 changes: 2 additions & 2 deletions c-sharp-chat/PubnubChatApi/PubNubChatApi.Tests/ChatTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;
using PubnubChatApi.Enums;
Expand Down Expand Up @@ -227,4 +227,4 @@ public async Task TestCanI()
Assert.True(await accessChat.ChatAccessManager.CanI(PubnubAccessPermission.Read, PubnubAccessResourceType.Channels,
"can_i_test_channel"));
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -147,4 +147,4 @@ public async Task TestUnreadMessagesCount()
.FirstOrDefault(x => x.ChannelId == unreadChannel.Id);
Assert.True(membership != null && await membership.GetUnreadMessagesCount() == 3);
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using PubNubChatAPI.Entities;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

namespace PubNubChatApi.Tests;
Expand Down Expand Up @@ -166,4 +166,4 @@ public async Task TestSend()
var gotCallback = successReset.WaitOne(6000);
Assert.True(gotCallback);
}
}*/
}
12 changes: 6 additions & 6 deletions c-sharp-chat/PubnubChatApi/PubNubChatApi.Tests/MessageTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -250,9 +250,9 @@ public async Task TestCreateThread()
try
{
var thread = await message.CreateThread();
await Task.Delay(3000);
await Task.Delay(2000);
await thread.SendText("thread_init_text");
await Task.Delay(3000);
await Task.Delay(2000);
hasThread = message.HasThread();
}
catch (Exception e)
Expand All @@ -265,7 +265,7 @@ public async Task TestCreateThread()
Assert.True(message.TryGetThread(out var threadChannel));
await message.RemoveThread();

await Task.Delay(8000);
await Task.Delay(5000);

//TODO: temporary way to get latest message pointer since remove_thread doesn't return a new pointer
chat.TryGetMessage(channel.Id, message.Id, out message);
Expand All @@ -275,7 +275,7 @@ public async Task TestCreateThread()
};
await channel.SendText("thread_start_message");

var received = manualReceiveEvent.WaitOne(20000);
var received = manualReceiveEvent.WaitOne(25000);
Assert.IsTrue(received);
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -79,4 +79,4 @@ public async Task TestGetRestrictionsSets()
Assert.True(a.Restrictions.Any(x => x.UserId == user.Id));
Assert.True(b.Restrictions.Any(x => x.ChannelId == channel.Id));
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -184,4 +184,4 @@ public async Task TestThreadMessageUpdate()
var updated = messageUpdatedReset.WaitOne(255000);
Assert.True(updated);
}
}*/
}
4 changes: 2 additions & 2 deletions c-sharp-chat/PubnubChatApi/PubNubChatApi.Tests/UserTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*using System.Diagnostics;
using System.Diagnostics;
using PubNubChatAPI.Entities;
using PubnubChatApi.Entities.Data;

Expand Down Expand Up @@ -76,4 +76,4 @@ await testUser.Update(new ChatUserData()
var updated = updatedReset.WaitOne(8000);
Assert.True(updated);
}
}*/
}
8 changes: 8 additions & 0 deletions c-sharp-chat/PubnubChatApi/PubnubChatApi/Entities/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ public MessageDraft CreateMessageDraft(UserSuggestionSource userSuggestionSource
/// <seealso cref="Join"/>
public async Task Connect()
{
if (connected)
{
return;
}
connected = true;
var buffer = new StringBuilder(4096);
CUtilities.CheckCFunctionResult(await Task.Run(() => pn_channel_connect(pointer, buffer)));
Expand Down Expand Up @@ -588,6 +592,10 @@ public async Task Connect()
/// <seealso cref="Disconnect"/>
public async Task Join()
{
if (connected)
{
return;
}
connected = true;
var buffer = new StringBuilder(4096);
CUtilities.CheckCFunctionResult(await Task.Run(() => pn_channel_join(pointer, string.Empty, buffer)));
Expand Down
Loading

0 comments on commit 0fdb06e

Please sign in to comment.