Skip to content

Commit

Permalink
chore: add test for AddComponentMenu attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Jun 28, 2023
1 parent 35bec38 commit 0474293
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Test~/AddComponentMenuTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using UnityEngine;

namespace Anatawa12.AvatarOptimizer.Test
{
public class AddComponentMenuTest
{
[Test]
[TestCaseSource(nameof(ComponentTypes))]
public void CheckAddComponentMenuIsInAvatarOptimizer(Type type)
{
var addComponentMenu = type.GetCustomAttribute<AddComponentMenu>();
Assert.That(addComponentMenu, Is.Not.Null);
Assert.That(addComponentMenu.componentMenu, Does.StartWith("Avatar Optimizer/").Or.Empty);
}

static IEnumerable<Type> ComponentTypes()
{
return
typeof(AvatarTagComponent).Assembly
.GetTypes()
.Where(x => x.IsClass && !x.IsAbstract)
.Where(x => typeof(MonoBehaviour).IsAssignableFrom(x));
}
}
}
3 changes: 3 additions & 0 deletions Test~/AddComponentMenuTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0474293

Please sign in to comment.