-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extensions.Find incorrectly compares the kvp.Key to the T type. It is using an `is` operator, which is a cast check. This is incorrect because the Key is always a System.Type. Instead it should be comparing the Key to typeof(T).
- Loading branch information
Showing
3 changed files
with
39 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Test.Microsoft.Azure.Amqp | ||
{ | ||
using global::Microsoft.Azure.Amqp; | ||
using System; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
[Trait("Category", TestCategory.Current)] | ||
public class AmqpExtensionsTests | ||
{ | ||
[Fact] | ||
public void TestFind() | ||
{ | ||
Dictionary<Type, object> dictionary = new Dictionary<Type, object>(); | ||
|
||
Assert.Null(dictionary.Find<TestClass>()); | ||
|
||
var testValue = new TestClass(); | ||
dictionary.Add(typeof(TestClass), testValue); | ||
Assert.Same(testValue, dictionary.Find<TestClass>()); | ||
|
||
dictionary.Remove(typeof(TestClass)); | ||
|
||
Assert.Null(dictionary.Find<TestClass>()); | ||
} | ||
|
||
private class TestClass | ||
{ | ||
} | ||
} | ||
} |