// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; namespace osu.Framework.Tests.Containers { [TestFixture] public class ContainerEnumerableTest { /// /// Ensures that adding container as an enumerable of drawables to another container results in an exception. /// Tests with a regular , and an which doesn't directly inherit from . /// [TestCase(typeof(Container))] [TestCase(typeof(Container))] [TestCase(typeof(Container))] [TestCase(typeof(AudioContainer))] [TestCase(typeof(AudioContainer))] [TestCase(typeof(AudioContainer))] public void TestAddingContainerAsEnumerableRangeThrows(Type containerType) { Assert.Throws(() => { var unused = new Container { Children = (IReadOnlyList)Activator.CreateInstance(containerType) }; }); Assert.Throws(() => { var unused = new Container(); unused.AddRange((IEnumerable)Activator.CreateInstance(containerType)); }); Assert.Throws(() => { var unused = new AudioContainer { Children = (IReadOnlyList)Activator.CreateInstance(containerType) }; }); Assert.Throws(() => { var unused = new AudioContainer(); unused.AddRange((IEnumerable)Activator.CreateInstance(containerType)); }); } } }