Skip to content

Commit

Permalink
unused return value in TestableReflectHelper (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishkk authored and jayaranigarg committed Dec 21, 2018
1 parent b460dd1 commit eeb2b7f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,32 @@ public void GetTestCategoryAttributeShouldIncludeTestCategoriesAtClassLevel()
[TestMethod]
public void GetTestCategoryAttributeShouldIncludeTestCategoriesAtAllLevels()
{
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("AsmLevel") }, MemberTypes.All);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("AsmLevel1"), new UTF.TestCategoryAttribute("AsmLevel2") }, MemberTypes.All);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("AsmLevel3") }, MemberTypes.All);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("ClassLevel") }, MemberTypes.TypeInfo);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("MethodLevel") }, MemberTypes.Method);

var actual = this.reflectHelper.GetCategories(this.method.Object).ToArray();
string[] expected = new[] { "MethodLevel", "ClassLevel", "AsmLevel" };
string[] expected = new[] { "MethodLevel", "ClassLevel", "AsmLevel1", "AsmLevel2", "AsmLevel3" };

CollectionAssert.AreEqual(expected, actual);
}

/// <summary>
/// Testing test category attributes adorned at calss, assembly and method level are getting collected.
/// </summary>
[TestMethod]
public void GetTestCategoryAttributeShouldConcatCustomAttributeOfSameType()
{
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("AsmLevel1") }, MemberTypes.All);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("AsmLevel2") }, MemberTypes.All);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("ClassLevel1") }, MemberTypes.TypeInfo);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("ClassLevel2") }, MemberTypes.TypeInfo);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("MethodLevel1") }, MemberTypes.Method);
this.reflectHelper.SetCustomAttribute(typeof(UTF.TestCategoryBaseAttribute), new[] { new UTF.TestCategoryAttribute("MethodLevel2") }, MemberTypes.Method);

var actual = this.reflectHelper.GetCategories(this.method.Object).ToArray();
string[] expected = new[] { "MethodLevel1", "MethodLevel2", "ClassLevel1", "ClassLevel2", "AsmLevel1", "AsmLevel2" };

CollectionAssert.AreEqual(expected, actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void SetCustomAttribute(Type type, Attribute[] values, MemberTypes member
var hashcode = type.FullName.GetHashCode() + memberTypes.GetHashCode();
if (this.customAttributes.ContainsKey(hashcode))
{
this.customAttributes[hashcode].Concat(values);
this.customAttributes[hashcode] = this.customAttributes[hashcode].Concat(values).ToArray();
}
else
{
Expand Down

0 comments on commit eeb2b7f

Please sign in to comment.