Disable warnings for SkillConversationIdFactoryBase methods in tests (#3518)

* Disable warnings for SkillConversationIdFactoryBase methods in tests

* add comments for deprecated warnings disable
This commit is contained in:
Eric Dahlvang 2020-03-07 15:19:08 -08:00 коммит произвёл GitHub
Родитель e248cf460b
Коммит ec7d10aa46
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -159,7 +159,8 @@ namespace Microsoft.Bot.Builder.Skills
{
// Attempt to get SkillConversationReference using deprecated method.
// this catch should be removed once we remove the deprecated method.
#pragma warning disable 618 // We need to use the deprecated method for backward compatibility.
// We need to use the deprecated method for backward compatibility.
#pragma warning disable 618
var conversationReference = await _conversationIdFactory.GetConversationReferenceAsync(conversationId, cancellationToken).ConfigureAwait(false);
#pragma warning restore 618
skillConversationReference = new SkillConversationReference

Просмотреть файл

@ -33,7 +33,10 @@ namespace Microsoft.Bot.Builder.TestProtocol
protected override async Task<ResourceResponse> OnReplyToActivityAsync(ClaimsIdentity claimsIdentity, string conversationId, string activityId, Activity activity, CancellationToken cancellationToken = default)
{
// Using the deprecated method for backward compatibility.
#pragma warning disable 618
var conversationReference = await _factory.GetConversationReferenceAsync(conversationId, cancellationToken);
#pragma warning restore 618
var connectorClient = GetConnectorClient(conversationReference.ServiceUrl);
activity.ApplyConversationReference(conversationReference);
@ -42,7 +45,10 @@ namespace Microsoft.Bot.Builder.TestProtocol
protected override async Task<ResourceResponse> OnSendToConversationAsync(ClaimsIdentity claimsIdentity, string conversationId, Activity activity, CancellationToken cancellationToken = default)
{
// Using the deprecated method for backward compatibility.
#pragma warning disable 618
var conversationReference = await _factory.GetConversationReferenceAsync(conversationId, cancellationToken);
#pragma warning restore 618
var connectorClient = GetConnectorClient(conversationReference.ServiceUrl);
activity.ApplyConversationReference(conversationReference);
@ -51,7 +57,10 @@ namespace Microsoft.Bot.Builder.TestProtocol
protected override async Task<ResourceResponse> OnUpdateActivityAsync(ClaimsIdentity claimsIdentity, string conversationId, string activityId, Activity activity, CancellationToken cancellationToken = default)
{
// Using the deprecated method for backward compatibility.
#pragma warning disable 618
var conversationReference = await _factory.GetConversationReferenceAsync(conversationId, cancellationToken);
#pragma warning restore 618
var connectorClient = GetConnectorClient(conversationReference.ServiceUrl);
activity.ApplyConversationReference(conversationReference);
@ -60,7 +69,10 @@ namespace Microsoft.Bot.Builder.TestProtocol
protected override async Task OnDeleteActivityAsync(ClaimsIdentity claimsIdentity, string conversationId, string activityId, CancellationToken cancellationToken = default)
{
// Using the deprecated method for backward compatibility.
#pragma warning disable 618
var conversationReference = await _factory.GetConversationReferenceAsync(conversationId, cancellationToken);
#pragma warning restore 618
var connectorClient = GetConnectorClient(conversationReference.ServiceUrl);
await connectorClient.Conversations.DeleteActivityAsync(conversationReference.Conversation.Id, activityId, cancellationToken);

Просмотреть файл

@ -72,7 +72,10 @@ namespace Microsoft.Bot.Builder.Tests.Skills
ServiceUrl = "http://testbot.com/api/messages"
};
// Testing the deprecated method for backward compatibility.
#pragma warning disable 618
var conversationId = await legacycFatory.CreateSkillConversationIdAsync(conversationReference, CancellationToken.None);
#pragma warning restore 618
BotCallbackHandler botCallback = null;
_mockAdapter.Setup(x => x.ContinueConversationAsync(It.IsAny<ClaimsIdentity>(), It.IsAny<ConversationReference>(), It.IsAny<string>(), It.IsAny<BotCallbackHandler>(), It.IsAny<CancellationToken>()))
.Callback<ClaimsIdentity, ConversationReference, string, BotCallbackHandler, CancellationToken>((identity, reference, audience, callback, cancellationToken) =>
@ -330,16 +333,22 @@ namespace Microsoft.Bot.Builder.Tests.Skills
{
private readonly ConcurrentDictionary<string, string> _conversationRefs = new ConcurrentDictionary<string, string>();
// Testing the deprecated method for backward compatibility.
#pragma warning disable 618
public override Task<string> CreateSkillConversationIdAsync(ConversationReference conversationReference, CancellationToken cancellationToken)
{
#pragma warning restore 618
var crJson = JsonConvert.SerializeObject(conversationReference);
var key = (conversationReference.Conversation.Id + conversationReference.ServiceUrl).GetHashCode().ToString(CultureInfo.InvariantCulture);
_conversationRefs.GetOrAdd(key, crJson);
return Task.FromResult(key);
}
// Testing the deprecated method for backward compatibility.
#pragma warning disable 618
public override Task<ConversationReference> GetConversationReferenceAsync(string skillConversationId, CancellationToken cancellationToken)
{
#pragma warning restore 618
var conversationReference = JsonConvert.DeserializeObject<ConversationReference>(_conversationRefs[skillConversationId]);
return Task.FromResult(conversationReference);
}