Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions libraries/Microsoft.Bot.Schema/ActivityEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,13 @@ public ConversationReference GetReplyConversationReference(ResourceResponse repl
/// activity to get a conversation reference that you can then use to update an
/// outgoing activity with the correct delivery information.
/// </remarks>
/// <returns>This activy, updated with the delivery information.</returns>
/// <returns>This activity, updated with the delivery information.</returns>
public Activity ApplyConversationReference(ConversationReference reference, bool isIncoming = false)
{
ChannelId = reference.ChannelId;
ServiceUrl = reference.ServiceUrl;
Conversation = reference.Conversation;
Locale = reference.Locale ?? Locale;
Locale ??= reference.Locale;

if (isIncoming)
{
Expand Down
18 changes: 9 additions & 9 deletions tests/Microsoft.Bot.Schema.Tests/ActivityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void RemoveRecipientMention_forNonTeamsScenario()
[Fact]
public void ApplyConversationReference_isIncoming()
{
var activity = CreateActivity("en-us");
var activity = CreateActivity("en-uS"); // Intentionally oddly-cased to check that it isn't defaulted somewhere, but tests stay in English
var conversationReference = new ConversationReference
{
ChannelId = "cr_123",
Expand All @@ -125,27 +125,27 @@ public void ApplyConversationReference_isIncoming()
Id = "cr_def",
},
ActivityId = "cr_12345",
Locale = "en-uS" // Intentionally oddly-cased to check that it isn't defaulted somewhere, but tests stay in English
Locale = "en-us"
};

activity.ApplyConversationReference(conversationReference, true);
var activityToSend = activity.ApplyConversationReference(conversationReference, true);

Assert.Equal(conversationReference.ChannelId, activity.ChannelId);
Assert.Equal(conversationReference.Locale, activity.Locale);
Assert.Equal(conversationReference.ServiceUrl, activity.ServiceUrl);
Assert.Equal(conversationReference.Conversation.Id, activity.Conversation.Id);

Assert.Equal(conversationReference.User.Id, activity.From.Id);
Assert.Equal(conversationReference.Bot.Id, activity.Recipient.Id);
Assert.Equal(conversationReference.ActivityId, activity.Id);
Assert.Equal(activity.Locale, activityToSend.Locale);
}

[Theory]
[InlineData("en-uS")] // Intentionally oddly-cased to check that it isn't defaulted somewhere, but tests stay in English
[InlineData(null)]
public void ApplyConversationReference(string convoRefLocale)
{
var activity = CreateActivity("en-us");
var activity = CreateActivity(convoRefLocale);

var conversationReference = new ConversationReference
{
Expand All @@ -164,10 +164,10 @@ public void ApplyConversationReference(string convoRefLocale)
Id = "def",
},
ActivityId = "12345",
Locale = convoRefLocale
Locale = "en-us"
};

activity.ApplyConversationReference(conversationReference, false);
var activityToSend = activity.ApplyConversationReference(conversationReference, false);

Assert.Equal(conversationReference.ChannelId, activity.ChannelId);
Assert.Equal(conversationReference.ServiceUrl, activity.ServiceUrl);
Expand All @@ -179,11 +179,11 @@ public void ApplyConversationReference(string convoRefLocale)

if (convoRefLocale == null)
{
Assert.NotEqual(conversationReference.Locale, activity.Locale);
Assert.Equal(conversationReference.Locale, activityToSend.Locale);
}
else
{
Assert.Equal(conversationReference.Locale, activity.Locale);
Assert.Equal(activity.Locale, activityToSend.Locale);
}
}

Expand Down