#if !(UNITY_WSA && ENABLE_DOTNET) using System.Linq; using ModestTree; using NUnit.Framework; using UnityEngine; using Assert = ModestTree.Assert; namespace Zenject.Tests.Convention { [TestFixture] public class TestConvention : ZenjectUnitTestFixture { [Test] public void TestDerivingFrom() { Container.Bind() .To(x => x.AllTypes().DerivingFrom().FromThisAssembly()).AsTransient(); Assert.IsEqual(Container.ResolveAll().Count(), 4); } [Test] public void TestDerivingFrom2() { Container.Bind() .To(x => x.AllTypes().DerivingFrom()).AsTransient(); Assert.IsEqual(Container.ResolveAll().Count(), 4); } [Test] public void TestMatchAll() { // Should automatically filter by contract types Container.Bind().To(x => x.AllNonAbstractClasses()).AsTransient(); Assert.IsEqual(Container.ResolveAll().Count(), 4); } #if !NOT_UNITY3D [Test] public void TestDerivingFromFail() { Container.Bind() .To(x => x.AllTypes().DerivingFrom().FromAssemblyContaining()).AsTransient(); Assert.That(Container.ResolveAll().IsEmpty()); } #endif [Test] public void TestAttributeFilter() { Container.Bind() .To(x => x.AllTypes().WithAttribute()).AsTransient(); Assert.IsEqual(Container.ResolveAll().Count(), 2); } [Test] public void TestAttributeWhereFilter() { Container.Bind() .To(x => x.AllTypes().WithAttributeWhere(a => a.Num == 1)).AsTransient(); Assert.IsEqual(Container.ResolveAll().Count(), 1); } [Test] public void TestInNamespace() { Container.Bind() .To(x => x.AllTypes().DerivingFrom().InNamespace("Zenject.Tests.Convention.NamespaceTest")).AsTransient(); Assert.IsEqual(Container.ResolveAll().Count(), 1); } } } #endif