Skip to content

Commit

Permalink
fix: test implementation of customMessageType
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Nov 20, 2024
1 parent 43dee13 commit a868459
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public void GivenTheDemoKeyset()
{
Origin = acceptance_test_origin,
Secure = false,
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"),
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY")??"test",
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")??"test""

Check failure on line 133 in src/UnitTests/AcceptanceTests/Steps/FilesCustomMessageTypeSteps.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

Syntax error, ',' expected

Check failure on line 133 in src/UnitTests/AcceptanceTests/Steps/FilesCustomMessageTypeSteps.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

Newline in constant

Check failure on line 133 in src/UnitTests/AcceptanceTests/Steps/FilesCustomMessageTypeSteps.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

Syntax error, ',' expected

Check failure on line 133 in src/UnitTests/AcceptanceTests/Steps/FilesCustomMessageTypeSteps.cs

View workflow job for this annotation

GitHub Actions / Acceptance tests

Newline in constant
};
}

Expand All @@ -143,7 +143,6 @@ public async Task WhenSendFileWithCustomMessageType(string customMessageType)
fileResult = result.Result;
}

//I receive a successful response
[Then(@"I receive a successful response")]
public void ThenIReceiveASuccessfulResponse()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public void GivenTheDemoKeysetWithEnabledStorage()
{
Origin = acceptance_test_origin,
Secure = false,
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"),
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY")??"test",
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")??"test"
};
}

Expand All @@ -152,7 +152,6 @@ public async Task WhenIFetchMessageHistoryWithCustomMessageTypeForChannel(string
pnStatus = historyResult.Status;
}

// I fetch message history with 'include_custom_message_type' set to 'false' for 'some-channel' channel
[When(@"I fetch message history with 'include_custom_message_type' set to '(.*)' for '(.*)' channel")]
public async Task WhenIFetchMessageHistoryWithCustomMessageTypeForChannel(bool include,string channel)
{
Expand All @@ -171,13 +170,16 @@ public async Task ThenIReceiveASuccessfulResponse()
public void ThenHistoryResponseContainsMessageTypes(string valueOne, string valueTwo)
{
var channelMessages = historyResult.Result.Messages[channel];
if (currentContract == "fetchHistoryWithPubNubMessageTypes"){
Assert.IsTrue(channelMessages.Where(m=> m.MessageType == int.Parse(valueOne)).ToList().Count >0);
Assert.IsTrue(channelMessages.Where(m=> m.MessageType == int.Parse(valueTwo)).ToList().Count >0);
} else {
Assert.IsTrue(channelMessages.Where(m=> m.CustomMessageType == valueOne).ToList().Count >0);
Assert.IsTrue(channelMessages.Where(m=> m.CustomMessageType == valueTwo).ToList().Count >0);
}
}

[Then(@"history response contains messages with '(.*)' and '(.*)' types")]
public void ThenHistoryResponseContainsTypes(string valueOne, string valueTwo)
{
var channelMessages = historyResult.Result.Messages[channel];
Assert.IsTrue(channelMessages.Where(m=> m.CustomMessageType == valueOne).ToList().Count >0);
Assert.IsTrue(channelMessages.Where(m=> m.CustomMessageType == valueTwo).ToList().Count >0);
}

[Then(@"history response contains messages without customMessageType")]
Expand All @@ -186,4 +188,5 @@ public void ThenHistoryMessagesDoNotContainCustomMessageType()
var channelMessages = historyResult.Result.Messages[channel];
Assert.IsTrue(channelMessages.Where(m=> m.CustomMessageType != null).ToList().Count == 0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public void GivenTheDemoKeyset()
{
Origin = acceptance_test_origin,
Secure = false,
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"),
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY")??"test",
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")??"test"
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public void WhenISubscribe(string channel)
{
Origin = acceptance_test_origin,
Secure = false,
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"),
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")
PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY")??"test",
SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY")??"test"
};
pn = new Pubnub(config);

Expand Down

0 comments on commit a868459

Please sign in to comment.