A game framework written with osu! in mind.
at master 3.2 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using System.Collections; 5using NUnit.Framework; 6using osu.Framework.Graphics.Containers; 7 8namespace osu.Framework.Tests.Visual.Testing 9{ 10 public class TestSceneTestWithSource : FrameworkTestScene 11 { 12 protected static object[][] SourceField = 13 { 14 new object[] { 1, 2 }, 15 new object[] { 3, 4 }, 16 new object[] { 5, 6 }, 17 new object[] { 7, 8 }, 18 }; 19 20 protected static object[][] SourceProperty => SourceField; 21 22 protected static object[][] SourceMethod() => SourceField; 23 24 protected static object[][] SourceMethodWithParameters(int x, int y) => new[] 25 { 26 new object[] { x + 1, y + 2 }, 27 new object[] { x + 3, y + 4 }, 28 new object[] { x + 5, y + 6 }, 29 new object[] { x + 7, y + 8 }, 30 }; 31 32 protected static object[] SingleParameterSource = { 1, 2, 3, 4 }; 33 34 protected static object[][] DifferentTypesSource = 35 { 36 new object[] { Visibility.Visible, FillDirection.Horizontal, false }, 37 new object[] { Visibility.Hidden, FillDirection.Vertical, true }, 38 new object[] { Visibility.Hidden, FillDirection.Full, false }, 39 }; 40 41 public static object[][] ExposedSourceField = SourceField; 42 43 public static object[][] ExposedSourceProperty => SourceProperty; 44 45 public static object[][] ExposedSourceMethod() => SourceMethod(); 46 47 [TestCaseSource(nameof(SourceField))] 48 public void TestSourceField(int a, int b) 49 { 50 } 51 52 [TestCaseSource(nameof(SourceProperty))] 53 public void TestSourceProperty(int a, int b) 54 { 55 } 56 57 [TestCaseSource(nameof(SourceMethod))] 58 public void TestSourceMethod(int a, int b) 59 { 60 } 61 62 [TestCaseSource(nameof(SourceMethodWithParameters), new object[] { 10, 20 })] 63 public void TestSourceParamsMethod(int a, int b) 64 { 65 } 66 67 [TestCaseSource(nameof(SourceField))] 68 [TestCaseSource(nameof(SourceProperty))] 69 [TestCaseSource(nameof(SourceMethod))] 70 [TestCaseSource(nameof(SourceMethodWithParameters), new object[] { 10, 20 })] 71 public void TestMultipleSources(int a, int b) 72 { 73 } 74 75 [TestCaseSource(nameof(SingleParameterSource))] 76 public void TestSingleParameterSource(int x) 77 { 78 } 79 80 [TestCaseSource(nameof(DifferentTypesSource))] 81 public void TestDifferentTypesSource(Visibility a, FillDirection b, bool c) 82 { 83 } 84 85 [TestCaseSource(typeof(TestEnumerable))] 86 public void TestCustomEnumerableSource(int a, int b) 87 { 88 } 89 90 private class TestEnumerable : IEnumerable 91 { 92 public IEnumerator GetEnumerator() 93 { 94 yield return new[] { 1, 2 }; 95 yield return new[] { 3, 4 }; 96 yield return new[] { 5, 6 }; 97 yield return new[] { 7, 8 }; 98 } 99 } 100 } 101}