├── .gitignore ├── Assets ├── Editor.meta ├── Editor │ ├── TestEnemyController.cs │ └── TestEnemyController.cs.meta ├── Resources.meta ├── Resources │ ├── Enemy.prefab │ └── Enemy.prefab.meta ├── Scenes.meta ├── Scenes │ ├── MainScene.unity │ └── MainScene.unity.meta ├── Scripts.meta ├── Scripts │ ├── EnemyClickedEventArgs.cs │ ├── EnemyClickedEventArgs.cs.meta │ ├── EnemyController.cs │ ├── EnemyController.cs.meta │ ├── EnemyHealthChangedEventArgs.cs │ ├── EnemyHealthChangedEventArgs.cs.meta │ ├── EnemyModelView.cs │ ├── EnemyModelView.cs.meta │ ├── EnemyPositionChangedEventArgs.cs │ ├── EnemyPositionChangedEventArgs.cs.meta │ ├── IEnemyModelView.cs │ ├── IEnemyModelView.cs.meta │ ├── TestScript.cs │ └── TestScript.cs.meta ├── UnityTestTools.meta └── UnityTestTools │ ├── Assertions.meta │ ├── Assertions │ ├── AssertionComponent.cs │ ├── AssertionComponent.cs.meta │ ├── AssertionException.cs │ ├── AssertionException.cs.meta │ ├── Assertions.cs │ ├── Assertions.cs.meta │ ├── CheckMethod.cs │ ├── CheckMethod.cs.meta │ ├── Comparers.meta │ ├── Comparers │ │ ├── ActionBase.cs │ │ ├── ActionBase.cs.meta │ │ ├── BoolComparer.cs │ │ ├── BoolComparer.cs.meta │ │ ├── ColliderComparer.cs │ │ ├── ColliderComparer.cs.meta │ │ ├── ComparerBase.cs │ │ ├── ComparerBase.cs.meta │ │ ├── FloatComparer.cs │ │ ├── FloatComparer.cs.meta │ │ ├── GeneralComparer.cs │ │ ├── GeneralComparer.cs.meta │ │ ├── IntComparer.cs │ │ ├── IntComparer.cs.meta │ │ ├── IsRenderedByCamera.cs │ │ ├── IsRenderedByCamera.cs.meta │ │ ├── StringComparer.cs │ │ ├── StringComparer.cs.meta │ │ ├── TransformComparer.cs │ │ ├── TransformComparer.cs.meta │ │ ├── ValueDoesNotChange.cs │ │ ├── ValueDoesNotChange.cs.meta │ │ ├── Vector2Comparer.cs │ │ ├── Vector2Comparer.cs.meta │ │ ├── Vector3Comparer.cs │ │ ├── Vector3Comparer.cs.meta │ │ ├── Vector4Comparer.cs │ │ ├── Vector4Comparer.cs.meta │ │ ├── VectorComparerBase.cs │ │ └── VectorComparerBase.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── AssertionComponentEditor.cs │ │ ├── AssertionComponentEditor.cs.meta │ │ ├── AssertionExplorerWindow.cs │ │ ├── AssertionExplorerWindow.cs.meta │ │ ├── AssertionListRenderer.cs │ │ ├── AssertionListRenderer.cs.meta │ │ ├── AssertionStripper.cs │ │ ├── AssertionStripper.cs.meta │ │ ├── DropDownControl.cs │ │ ├── DropDownControl.cs.meta │ │ ├── GroupByComparerRenderer.cs │ │ ├── GroupByComparerRenderer.cs.meta │ │ ├── GroupByExecutionMethodRenderer.cs │ │ ├── GroupByExecutionMethodRenderer.cs.meta │ │ ├── GroupByGORenderer.cs │ │ ├── GroupByGORenderer.cs.meta │ │ ├── GroupByNothingRenderer.cs │ │ ├── GroupByNothingRenderer.cs.meta │ │ ├── GroupByTestsRenderer.cs │ │ ├── GroupByTestsRenderer.cs.meta │ │ ├── PropertyPathSelector.cs │ │ ├── PropertyPathSelector.cs.meta │ │ ├── PropertyResolver.cs │ │ └── PropertyResolver.cs.meta │ ├── InvalidPathException.cs │ ├── InvalidPathException.cs.meta │ ├── MemberResolver.cs │ └── MemberResolver.cs.meta │ ├── Common.meta │ ├── Common │ ├── Editor.meta │ ├── Editor │ │ ├── Icons.cs │ │ ├── Icons.cs.meta │ │ ├── ProjectSettingsBase.cs │ │ ├── ProjectSettingsBase.cs.meta │ │ ├── ResultWriter.meta │ │ ├── ResultWriter │ │ │ ├── ResultSummarizer.cs │ │ │ ├── ResultSummarizer.cs.meta │ │ │ ├── StackTraceFilter.cs │ │ │ ├── StackTraceFilter.cs.meta │ │ │ ├── XmlResultWriter.cs │ │ │ └── XmlResultWriter.cs.meta │ │ ├── Styles.cs │ │ ├── Styles.cs.meta │ │ ├── TestFilterSettings.cs │ │ ├── TestFilterSettings.cs.meta │ │ ├── icons.meta │ │ └── icons │ │ │ ├── failed.png │ │ │ ├── failed.png.meta │ │ │ ├── ignored.png │ │ │ ├── ignored.png.meta │ │ │ ├── inconclusive.png │ │ │ ├── inconclusive.png.meta │ │ │ ├── normal.png │ │ │ ├── normal.png.meta │ │ │ ├── passed.png │ │ │ ├── passed.png.meta │ │ │ ├── stopwatch.png │ │ │ └── stopwatch.png.meta │ ├── ITestResult.cs │ ├── ITestResult.cs.meta │ ├── TestResultState.cs │ └── TestResultState.cs.meta │ ├── Documentation.url │ ├── Documentation.url.meta │ ├── IntegrationTestsFramework.meta │ ├── IntegrationTestsFramework │ ├── Libs.meta │ ├── Libs │ │ ├── Mono.Cecil.Mdb.dll │ │ ├── Mono.Cecil.Mdb.dll.meta │ │ ├── Mono.Cecil.dll │ │ └── Mono.Cecil.dll.meta │ ├── TestRunner.meta │ ├── TestRunner │ │ ├── DTOFormatter.cs │ │ ├── DTOFormatter.cs.meta │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── Batch.cs │ │ │ ├── Batch.cs.meta │ │ │ ├── EditorReferencesUtil.cs │ │ │ ├── EditorReferencesUtil.cs.meta │ │ │ ├── GuiHelper.cs │ │ │ ├── GuiHelper.cs.meta │ │ │ ├── IntegrationTestsHierarchyAnnotation.cs │ │ │ ├── IntegrationTestsHierarchyAnnotation.cs.meta │ │ │ ├── IntegrationTestsRunnerSettings.cs │ │ │ ├── IntegrationTestsRunnerSettings.cs.meta │ │ │ ├── IntegrationTestsRunnerWindow.cs │ │ │ ├── IntegrationTestsRunnerWindow.cs.meta │ │ │ ├── PlatformRunner.meta │ │ │ ├── PlatformRunner │ │ │ │ ├── NetworkResultsReceiver.cs │ │ │ │ ├── NetworkResultsReceiver.cs.meta │ │ │ │ ├── PlatformRunner.cs │ │ │ │ ├── PlatformRunner.cs.meta │ │ │ │ ├── PlatformRunnerConfiguration.cs │ │ │ │ ├── PlatformRunnerConfiguration.cs.meta │ │ │ │ ├── PlatformRunnerSettings.cs │ │ │ │ ├── PlatformRunnerSettings.cs.meta │ │ │ │ ├── PlatformRunnerSettingsWindow.cs │ │ │ │ ├── PlatformRunnerSettingsWindow.cs.meta │ │ │ │ ├── PlayerSettingConfigurator.cs │ │ │ │ └── PlayerSettingConfigurator.cs.meta │ │ │ ├── Renderer.meta │ │ │ ├── Renderer │ │ │ │ ├── IntegrationTestGroupLine.cs │ │ │ │ ├── IntegrationTestGroupLine.cs.meta │ │ │ │ ├── IntegrationTestLine.cs │ │ │ │ ├── IntegrationTestLine.cs.meta │ │ │ │ ├── IntegrationTestRendererBase.cs │ │ │ │ ├── IntegrationTestRendererBase.cs.meta │ │ │ │ ├── RenderingOptions.cs │ │ │ │ └── RenderingOptions.cs.meta │ │ │ ├── TestComponentEditor.cs │ │ │ └── TestComponentEditor.cs.meta │ │ ├── ITestRunnerCallback.cs │ │ ├── ITestRunnerCallback.cs.meta │ │ ├── IntegrationTest.cs │ │ ├── IntegrationTest.cs.meta │ │ ├── IntegrationTestAttribute.cs │ │ ├── IntegrationTestAttribute.cs.meta │ │ ├── IntegrationTestsProvider.cs │ │ ├── IntegrationTestsProvider.cs.meta │ │ ├── NetworkResultSender.cs │ │ ├── NetworkResultSender.cs.meta │ │ ├── ResultDTO.cs │ │ ├── ResultDTO.cs.meta │ │ ├── TestComponent.cs │ │ ├── TestComponent.cs.meta │ │ ├── TestResult.cs │ │ ├── TestResult.cs.meta │ │ ├── TestResultRenderer.cs │ │ ├── TestResultRenderer.cs.meta │ │ ├── TestRunner.cs │ │ ├── TestRunner.cs.meta │ │ ├── TestRunnerCallbackList.cs │ │ ├── TestRunnerCallbackList.cs.meta │ │ ├── TestRunnerConfigurator.cs │ │ └── TestRunnerConfigurator.cs.meta │ ├── TestingAssets.meta │ └── TestingAssets │ │ ├── CallTesting.cs │ │ ├── CallTesting.cs.meta │ │ ├── CubeCollisionFailure.prefab │ │ ├── CubeCollisionFailure.prefab.meta │ │ ├── CubeCollisionSuccess.prefab │ │ ├── CubeCollisionSuccess.prefab.meta │ │ ├── CubeTriggerFailure.prefab │ │ ├── CubeTriggerFailure.prefab.meta │ │ ├── CubeTriggerSuccess.prefab │ │ ├── CubeTriggerSuccess.prefab.meta │ │ ├── Materials.meta │ │ ├── Materials │ │ ├── green.mat │ │ ├── green.mat.meta │ │ ├── red.mat │ │ └── red.mat.meta │ │ ├── green.png │ │ ├── green.png.meta │ │ ├── red.png │ │ └── red.png.meta │ ├── LICENSE.txt │ ├── LICENSE.txt.meta │ ├── UnitTesting.meta │ ├── UnitTesting │ ├── Editor.meta │ └── Editor │ │ ├── NSubstitute.meta │ │ └── NSubstitute │ │ ├── NSubstitute.dll │ │ └── NSubstitute.dll.meta │ ├── changelog.txt │ └── changelog.txt.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/unity,monodevelop 3 | 4 | ### Unity ### 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /Assets/AssetStoreTools* 11 | 12 | # Autogenerated VS/MD/Consulo solution and project files 13 | ExportedObj/ 14 | .consulo/ 15 | *.csproj 16 | *.unityproj 17 | *.sln 18 | *.suo 19 | *.tmp 20 | *.user 21 | *.userprefs 22 | *.pidb 23 | *.booproj 24 | *.svd 25 | 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | 30 | # Unity3D Generated File On Crash Reports 31 | sysinfo.txt 32 | 33 | # Builds 34 | *.apk 35 | *.unitypackage 36 | 37 | 38 | ### MonoDevelop ### 39 | #User Specific 40 | *.usertasks 41 | 42 | #Mono Project Files 43 | *.resources 44 | test-results/ 45 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: abab888c04582411e9103dd02b604948 3 | folderAsset: yes 4 | timeCreated: 1476658239 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Editor/TestEnemyController.cs: -------------------------------------------------------------------------------- 1 | using NSubstitute; 2 | using NUnit.Framework; 3 | 4 | #pragma warning disable 0168, 0219 // unused variables 5 | 6 | // Class with tests 7 | [TestFixture] 8 | public class TestEnemyController 9 | { 10 | // A single test 11 | [Test] 12 | public void ReducesHealthByClickDamageWhenClicked() 13 | { 14 | // Make a fake model-view and give it to a real controller 15 | var modelView = Substitute.For(); 16 | modelView.Health = 1; 17 | var controller = new EnemyController(modelView, 0.25f); 18 | 19 | // Fake the OnClicked event 20 | modelView.OnClicked += Raise.EventWith(new EnemyClickedEventArgs()); 21 | 22 | // Make sure the controller damaged the enemy 23 | Assert.That(modelView.Health, Is.EqualTo(0.75f).Within(0.001f)); 24 | } 25 | 26 | // Three tests in one. Specify parameters for each run of this function. 27 | [TestCase(0.1f, 0)] 28 | [TestCase(0, 1)] 29 | [TestCase(-0.1f, 1)] 30 | public void OnlyDestroysWhenHealthChangesToLessThanOrEqualToZero( 31 | float health, 32 | int numDestroyCalls 33 | ) 34 | { 35 | // Make a fake model-view and give it to a real controller 36 | var modelView = Substitute.For(); 37 | modelView.Health = 1; 38 | var controller = new EnemyController(modelView, 0.25f); 39 | 40 | // Fake the OnHealthChanged event 41 | modelView.OnHealthChanged += Raise.EventWith(new EnemyHealthChangedEventArgs(health)); 42 | 43 | // Make sure the controller called Destroy() the right number of times 44 | modelView.Received(numDestroyCalls).Destroy(); 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/Editor/TestEnemyController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83f3077f2f6fb4166aba476f04aa6d71 3 | timeCreated: 1476658262 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23d818d1250bd48f4b8f7e51c2511f96 3 | folderAsset: yes 4 | timeCreated: 1476654916 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/Enemy.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/Resources/Enemy.prefab -------------------------------------------------------------------------------- /Assets/Resources/Enemy.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05c98c179d92b4ddc958fc3d3c68b91e 3 | timeCreated: 1476654907 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b9f4a5d5bc75441b80eb8ed89cd4396 3 | folderAsset: yes 4 | timeCreated: 1476655527 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scenes/MainScene.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/Scenes/MainScene.unity -------------------------------------------------------------------------------- /Assets/Scenes/MainScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdd215f974b3a4b6c9f4b990e7a70c88 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b99b817e7e31401dbaa6502b7dcdda5 3 | folderAsset: yes 4 | timeCreated: 1476655514 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/EnemyClickedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class EnemyClickedEventArgs : EventArgs 4 | { 5 | } -------------------------------------------------------------------------------- /Assets/Scripts/EnemyClickedEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cb99dd2a390b4a33ae7e2794edd6a71 3 | timeCreated: 1476655984 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EnemyController.cs: -------------------------------------------------------------------------------- 1 | // The logic for an enemy. Relies on a model-view to store the data representation, gather input, 2 | // and output to the user. 3 | public class EnemyController 4 | { 5 | private readonly IEnemyModelView modelView; 6 | private float clickDamage; 7 | 8 | public EnemyController(IEnemyModelView modelView, float clickDamage) 9 | { 10 | this.modelView = modelView; 11 | this.clickDamage = clickDamage; 12 | 13 | // Listen to input from the model-view 14 | modelView.OnClicked += HandleClicked; 15 | 16 | // Listen to changes in the model-view's data 17 | modelView.OnHealthChanged += HandleHealthChanged; 18 | } 19 | 20 | private void HandleClicked(object sender, EnemyClickedEventArgs e) 21 | { 22 | // Perform logic as a result of this input 23 | // Here it's just a simple calculation to damage the enemy by reducing its health 24 | // Update the model-view's data representation accordingly if this is the case 25 | modelView.Health -= clickDamage; 26 | } 27 | 28 | private void HandleHealthChanged(object sender, EnemyHealthChangedEventArgs e) 29 | { 30 | // Perform logic as a result of this data change 31 | // Here it's just a simple rule that an enemy with no health is dead and gets destroyed 32 | // Output to the model-view accordingly if this is the case 33 | if (e.Health <= 0) 34 | { 35 | modelView.Destroy(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/Scripts/EnemyController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcb947f5facd94d52ac3758331a207d0 3 | timeCreated: 1476656152 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EnemyHealthChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class EnemyHealthChangedEventArgs : EventArgs 4 | { 5 | public float Health { get; private set; } 6 | 7 | public EnemyHealthChangedEventArgs(float health) 8 | { 9 | Health = health; 10 | } 11 | } -------------------------------------------------------------------------------- /Assets/Scripts/EnemyHealthChangedEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e888457019944118b0ed363b8732896 3 | timeCreated: 1476657198 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EnemyModelView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | // The combined model (data representation) and view (input and output) for an enemy. Does no logic. 6 | public class EnemyModelView : MonoBehaviour, IEnemyModelView 7 | { 8 | // Data events 9 | public event EventHandler OnHealthChanged = (s, e) => {}; 10 | public event EventHandler OnPositionChanged = (s, e) => {}; 11 | 12 | // Input events 13 | public event EventHandler OnClicked = (s, e) => {}; 14 | 15 | // Data stored by the model-view 16 | // Outputs the data by mapping it to the material color 17 | private float health; 18 | public float Health 19 | { 20 | get { return health; } 21 | set 22 | { 23 | if (value != health) 24 | { 25 | health = value; 26 | GetComponent().material.color = Color.Lerp(Color.red, Color.green, value); 27 | OnHealthChanged(this, new EnemyHealthChangedEventArgs(health)); 28 | } 29 | } 30 | } 31 | 32 | // Wrapper for data already stored by Unity 33 | // Outputs the data by direct pass-through: no logic 34 | public Vector3 Position 35 | { 36 | get { return transform.position; } 37 | set 38 | { 39 | if (value != transform.position) 40 | { 41 | transform.position = value; 42 | OnPositionChanged(this, new EnemyPositionChangedEventArgs(value)); 43 | } 44 | } 45 | } 46 | 47 | // Default values can be set where appropriate 48 | void Awake() 49 | { 50 | Health = 1; 51 | } 52 | 53 | // Handle input by dispatching an event, not performing logic 54 | void Update() 55 | { 56 | if (Input.GetMouseButtonDown(0)) 57 | { 58 | var ray = Camera.main.ScreenPointToRay(Input.mousePosition); 59 | RaycastHit hit; 60 | if (Physics.Raycast(ray, out hit) && hit.transform == transform) 61 | { 62 | OnClicked(this, new EnemyClickedEventArgs()); 63 | } 64 | } 65 | } 66 | 67 | // Destroy the enemy, but we don't know why 68 | public void Destroy() 69 | { 70 | Destroy(gameObject); 71 | } 72 | } -------------------------------------------------------------------------------- /Assets/Scripts/EnemyModelView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 922d1a7dc1dc64af7806a4f98cd0ff9e 3 | timeCreated: 1476655451 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EnemyPositionChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | public class EnemyPositionChangedEventArgs : EventArgs 6 | { 7 | public Vector3 Position { get; protected set; } 8 | 9 | public EnemyPositionChangedEventArgs(Vector3 position) 10 | { 11 | Position = position; 12 | } 13 | } -------------------------------------------------------------------------------- /Assets/Scripts/EnemyPositionChangedEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb02993656efe497d8ba8427263f3a76 3 | timeCreated: 1476657894 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/IEnemyModelView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | // Interface for the model-view 6 | public interface IEnemyModelView 7 | { 8 | // Dispatched when the health changes 9 | event EventHandler OnHealthChanged; 10 | 11 | // Dispatched when the position changes 12 | event EventHandler OnPositionChanged; 13 | 14 | // Dispatched when the enemy is clicked 15 | event EventHandler OnClicked; 16 | 17 | // Position of the enemy 18 | Vector3 Position { get; set; } 19 | 20 | // Health of the enemy 21 | float Health { get; set; } 22 | 23 | // Destroy the enemy 24 | void Destroy(); 25 | } -------------------------------------------------------------------------------- /Assets/Scripts/IEnemyModelView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f737ca313726a4c49b1c195c4b22f1f9 3 | timeCreated: 1476655912 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/TestScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | public class TestScript : MonoBehaviour 6 | { 7 | void Awake() 8 | { 9 | // Create the model-view 10 | var prefab = Resources.Load("Enemy"); 11 | var instance = Instantiate(prefab); 12 | var modelView = instance.GetComponent(); 13 | modelView.Position = new Vector3(1, 2, 3); 14 | 15 | // Create the controller 16 | // No need to keep a reference because the model-view already has at least one 17 | new EnemyController(modelView, 0.25f); 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/Scripts/TestScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b5575a60b7c04c7a87ff4e161573c66 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11c14d564b27f45f8b8d2aab50a84555 3 | folderAsset: yes 4 | timeCreated: 1476661213 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b27b28700d3365146808b6e082748201 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/AssertionComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bafa54482a87ac4cbd7ff1bfd1ac93a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/AssertionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class AssertionException : Exception 8 | { 9 | private readonly AssertionComponent m_Assertion; 10 | 11 | public AssertionException(AssertionComponent assertion) : base(assertion.Action.GetFailureMessage()) 12 | { 13 | m_Assertion = assertion; 14 | } 15 | 16 | public override string StackTrace 17 | { 18 | get 19 | { 20 | return "Created in " + m_Assertion.GetCreationLocation(); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/AssertionException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef3769ab00d50bc4fbb05a9a91c741d9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Assertions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Object = UnityEngine.Object; 5 | 6 | namespace UnityTest 7 | { 8 | public static class Assertions 9 | { 10 | public static void CheckAssertions() 11 | { 12 | var assertions = Object.FindObjectsOfType(typeof(AssertionComponent)) as AssertionComponent[]; 13 | CheckAssertions(assertions); 14 | } 15 | 16 | public static void CheckAssertions(AssertionComponent assertion) 17 | { 18 | CheckAssertions(new[] {assertion}); 19 | } 20 | 21 | public static void CheckAssertions(GameObject gameObject) 22 | { 23 | CheckAssertions(gameObject.GetComponents()); 24 | } 25 | 26 | public static void CheckAssertions(AssertionComponent[] assertions) 27 | { 28 | if (!Debug.isDebugBuild) 29 | return; 30 | foreach (var assertion in assertions) 31 | { 32 | assertion.checksPerformed++; 33 | var result = assertion.Action.Compare(); 34 | if (!result) 35 | { 36 | assertion.hasFailed = true; 37 | assertion.Action.Fail(assertion); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Assertions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85280dad1e618c143bd3fb07a197b469 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/CheckMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | [Flags] 8 | public enum CheckMethod 9 | { 10 | AfterPeriodOfTime = 1 << 0, 11 | Start = 1 << 1, 12 | Update = 1 << 2, 13 | FixedUpdate = 1 << 3, 14 | LateUpdate = 1 << 4, 15 | OnDestroy = 1 << 5, 16 | OnEnable = 1 << 6, 17 | OnDisable = 1 << 7, 18 | OnControllerColliderHit = 1 << 8, 19 | OnParticleCollision = 1 << 9, 20 | OnJointBreak = 1 << 10, 21 | OnBecameInvisible = 1 << 11, 22 | OnBecameVisible = 1 << 12, 23 | OnTriggerEnter = 1 << 13, 24 | OnTriggerExit = 1 << 14, 25 | OnTriggerStay = 1 << 15, 26 | OnCollisionEnter = 1 << 16, 27 | OnCollisionExit = 1 << 17, 28 | OnCollisionStay = 1 << 18, 29 | OnTriggerEnter2D = 1 << 19, 30 | OnTriggerExit2D = 1 << 20, 31 | OnTriggerStay2D = 1 << 21, 32 | OnCollisionEnter2D = 1 << 22, 33 | OnCollisionExit2D = 1 << 23, 34 | OnCollisionStay2D = 1 << 24, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/CheckMethod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cbb75d1643c5a55439f8861a827f411b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb9e10c25f478c84f826ea85b03ec179 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ActionBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | public abstract class ActionBase : ScriptableObject 10 | { 11 | public GameObject go; 12 | protected object m_ObjVal; 13 | 14 | private MemberResolver m_MemberResolver; 15 | 16 | public string thisPropertyPath = ""; 17 | public virtual Type[] GetAccepatbleTypesForA() 18 | { 19 | return null; 20 | } 21 | public virtual int GetDepthOfSearch() { return 2; } 22 | 23 | public virtual string[] GetExcludedFieldNames() 24 | { 25 | return new string[] { }; 26 | } 27 | 28 | public bool Compare() 29 | { 30 | if (m_MemberResolver == null) 31 | m_MemberResolver = new MemberResolver(go, thisPropertyPath); 32 | m_ObjVal = m_MemberResolver.GetValue(UseCache); 33 | var result = Compare(m_ObjVal); 34 | return result; 35 | } 36 | 37 | protected abstract bool Compare(object objVal); 38 | 39 | virtual protected bool UseCache { get { return false; } } 40 | 41 | public virtual Type GetParameterType() { return typeof(object); } 42 | 43 | public virtual string GetConfigurationDescription() 44 | { 45 | string result = ""; 46 | #if !UNITY_METRO 47 | foreach (var prop in GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) 48 | .Where(info => info.FieldType.IsSerializable)) 49 | { 50 | var value = prop.GetValue(this); 51 | if (value is double) 52 | value = ((double)value).ToString("0.########"); 53 | if (value is float) 54 | value = ((float)value).ToString("0.########"); 55 | result += value + " "; 56 | } 57 | #endif // if !UNITY_METRO 58 | return result; 59 | } 60 | 61 | IEnumerable GetFields(Type type) 62 | { 63 | #if !UNITY_METRO 64 | return type.GetFields(BindingFlags.Public | BindingFlags.Instance); 65 | #else 66 | return null; 67 | #endif 68 | } 69 | 70 | public ActionBase CreateCopy(GameObject oldGameObject, GameObject newGameObject) 71 | { 72 | #if !UNITY_METRO 73 | var newObj = CreateInstance(GetType()) as ActionBase; 74 | #else 75 | var newObj = (ActionBase) this.MemberwiseClone(); 76 | #endif 77 | var fields = GetFields(GetType()); 78 | foreach (var field in fields) 79 | { 80 | var value = field.GetValue(this); 81 | if (value is GameObject) 82 | { 83 | if (value as GameObject == oldGameObject) 84 | value = newGameObject; 85 | } 86 | field.SetValue(newObj, value); 87 | } 88 | return newObj; 89 | } 90 | 91 | public virtual void Fail(AssertionComponent assertion) 92 | { 93 | Debug.LogException(new AssertionException(assertion), assertion.GetFailureReferenceObject()); 94 | } 95 | 96 | public virtual string GetFailureMessage() 97 | { 98 | return GetType().Name + " assertion failed.\n(" + go + ")." + thisPropertyPath + " failed. Value: " + m_ObjVal; 99 | } 100 | } 101 | 102 | public abstract class ActionBaseGeneric : ActionBase 103 | { 104 | protected override bool Compare(object objVal) 105 | { 106 | return Compare((T)objVal); 107 | } 108 | protected abstract bool Compare(T objVal); 109 | 110 | public override Type[] GetAccepatbleTypesForA() 111 | { 112 | return new[] { typeof(T) }; 113 | } 114 | 115 | public override Type GetParameterType() 116 | { 117 | return typeof(T); 118 | } 119 | protected override bool UseCache { get { return true; } } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ActionBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4995756bd539804e8143ff1e730f806 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/BoolComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class BoolComparer : ComparerBaseGeneric 8 | { 9 | protected override bool Compare(bool a, bool b) 10 | { 11 | return a == b; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/BoolComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2586c8e41f35d2f4fadde53020bf4207 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ColliderComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class ColliderComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | Intersects, 12 | DoesNotIntersect 13 | }; 14 | 15 | public CompareType compareType; 16 | 17 | protected override bool Compare(Bounds a, Bounds b) 18 | { 19 | switch (compareType) 20 | { 21 | case CompareType.Intersects: 22 | return a.Intersects(b); 23 | case CompareType.DoesNotIntersect: 24 | return !a.Intersects(b); 25 | } 26 | throw new Exception(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ColliderComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4eff45b2ac4067b469d7994298341db6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ComparerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Object = System.Object; 5 | 6 | namespace UnityTest 7 | { 8 | public abstract class ComparerBase : ActionBase 9 | { 10 | public enum CompareToType 11 | { 12 | CompareToObject, 13 | CompareToConstantValue, 14 | CompareToNull 15 | } 16 | 17 | public CompareToType compareToType = CompareToType.CompareToObject; 18 | 19 | public GameObject other; 20 | protected object m_ObjOtherVal; 21 | public string otherPropertyPath = ""; 22 | private MemberResolver m_MemberResolverB; 23 | 24 | protected abstract bool Compare(object a, object b); 25 | 26 | protected override bool Compare(object objValue) 27 | { 28 | if (compareToType == CompareToType.CompareToConstantValue) 29 | { 30 | m_ObjOtherVal = ConstValue; 31 | } 32 | else if (compareToType == CompareToType.CompareToNull) 33 | { 34 | m_ObjOtherVal = null; 35 | } 36 | else 37 | { 38 | if (other == null) 39 | m_ObjOtherVal = null; 40 | else 41 | { 42 | if (m_MemberResolverB == null) 43 | m_MemberResolverB = new MemberResolver(other, otherPropertyPath); 44 | m_ObjOtherVal = m_MemberResolverB.GetValue(UseCache); 45 | } 46 | } 47 | return Compare(objValue, m_ObjOtherVal); 48 | } 49 | 50 | public virtual Type[] GetAccepatbleTypesForB() 51 | { 52 | return null; 53 | } 54 | 55 | #region Const value 56 | 57 | public virtual object ConstValue { get; set; } 58 | public virtual object GetDefaultConstValue() 59 | { 60 | throw new NotImplementedException(); 61 | } 62 | 63 | #endregion 64 | 65 | public override string GetFailureMessage() 66 | { 67 | var message = GetType().Name + " assertion failed.\n" + go.name + "." + thisPropertyPath + " " + compareToType; 68 | switch (compareToType) 69 | { 70 | case CompareToType.CompareToObject: 71 | message += " (" + other + ")." + otherPropertyPath + " failed."; 72 | break; 73 | case CompareToType.CompareToConstantValue: 74 | message += " " + ConstValue + " failed."; 75 | break; 76 | case CompareToType.CompareToNull: 77 | message += " failed."; 78 | break; 79 | } 80 | message += " Expected: " + m_ObjOtherVal + " Actual: " + m_ObjVal; 81 | return message; 82 | } 83 | } 84 | 85 | [Serializable] 86 | public abstract class ComparerBaseGeneric : ComparerBaseGeneric 87 | { 88 | } 89 | 90 | [Serializable] 91 | public abstract class ComparerBaseGeneric : ComparerBase 92 | { 93 | public T2 constantValueGeneric = default(T2); 94 | 95 | public override Object ConstValue 96 | { 97 | get 98 | { 99 | return constantValueGeneric; 100 | } 101 | set 102 | { 103 | constantValueGeneric = (T2)value; 104 | } 105 | } 106 | 107 | public override Object GetDefaultConstValue() 108 | { 109 | return default(T2); 110 | } 111 | 112 | static bool IsValueType(Type type) 113 | { 114 | #if !UNITY_METRO 115 | return type.IsValueType; 116 | #else 117 | return false; 118 | #endif 119 | } 120 | 121 | protected override bool Compare(object a, object b) 122 | { 123 | var type = typeof(T2); 124 | if (b == null && IsValueType(type)) 125 | { 126 | throw new ArgumentException("Null was passed to a value-type argument"); 127 | } 128 | return Compare((T1)a, (T2)b); 129 | } 130 | 131 | protected abstract bool Compare(T1 a, T2 b); 132 | 133 | public override Type[] GetAccepatbleTypesForA() 134 | { 135 | return new[] { typeof(T1) }; 136 | } 137 | 138 | public override Type[] GetAccepatbleTypesForB() 139 | { 140 | return new[] {typeof(T2)}; 141 | } 142 | 143 | protected override bool UseCache { get { return true; } } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ComparerBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c86508f389d643b40b6e1d7dcc1d4df2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/FloatComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class FloatComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareTypes 10 | { 11 | Equal, 12 | NotEqual, 13 | Greater, 14 | Less 15 | } 16 | 17 | public CompareTypes compareTypes; 18 | public double floatingPointError = 0.0001f; 19 | 20 | protected override bool Compare(float a, float b) 21 | { 22 | switch (compareTypes) 23 | { 24 | case CompareTypes.Equal: 25 | return Math.Abs(a - b) < floatingPointError; 26 | case CompareTypes.NotEqual: 27 | return Math.Abs(a - b) > floatingPointError; 28 | case CompareTypes.Greater: 29 | return a > b; 30 | case CompareTypes.Less: 31 | return a < b; 32 | } 33 | throw new Exception(); 34 | } 35 | public override int GetDepthOfSearch() 36 | { 37 | return 3; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/FloatComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4928c6c2b973874c8d4e6c9a69bb5b4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/GeneralComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class GeneralComparer : ComparerBase 8 | { 9 | public enum CompareType { AEqualsB, ANotEqualsB } 10 | 11 | public CompareType compareType; 12 | 13 | protected override bool Compare(object a, object b) 14 | { 15 | if (compareType == CompareType.AEqualsB) 16 | return a.Equals(b); 17 | if (compareType == CompareType.ANotEqualsB) 18 | return !a.Equals(b); 19 | throw new Exception(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/GeneralComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 902961c69f102f4409c29b9e54258701 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IntComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class IntComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | Equal, 12 | NotEqual, 13 | Greater, 14 | GreaterOrEqual, 15 | Less, 16 | LessOrEqual 17 | }; 18 | 19 | public CompareType compareType; 20 | 21 | protected override bool Compare(int a, int b) 22 | { 23 | switch (compareType) 24 | { 25 | case CompareType.Equal: 26 | return a == b; 27 | case CompareType.NotEqual: 28 | return a != b; 29 | case CompareType.Greater: 30 | return a > b; 31 | case CompareType.GreaterOrEqual: 32 | return a >= b; 33 | case CompareType.Less: 34 | return a < b; 35 | case CompareType.LessOrEqual: 36 | return a <= b; 37 | } 38 | throw new Exception(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IntComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da4a3a521c5c1494aae123742ca5c8f5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IsRenderedByCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class IsRenderedByCamera : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | IsVisible, 12 | IsNotVisible, 13 | }; 14 | 15 | public CompareType compareType; 16 | 17 | protected override bool Compare(Renderer renderer, Camera camera) 18 | { 19 | var planes = GeometryUtility.CalculateFrustumPlanes(camera); 20 | var isVisible = GeometryUtility.TestPlanesAABB(planes, renderer.bounds); 21 | switch (compareType) 22 | { 23 | case CompareType.IsVisible: 24 | return isVisible; 25 | case CompareType.IsNotVisible: 26 | return !isVisible; 27 | } 28 | throw new Exception(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IsRenderedByCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d45a1674f5e2e04485eafef922fac41 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/StringComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class StringComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | Equal, 12 | NotEqual, 13 | Shorter, 14 | Longer 15 | } 16 | 17 | public CompareType compareType; 18 | public StringComparison comparisonType = StringComparison.Ordinal; 19 | public bool ignoreCase = false; 20 | 21 | protected override bool Compare(string a, string b) 22 | { 23 | if (ignoreCase) 24 | { 25 | a = a.ToLower(); 26 | b = b.ToLower(); 27 | } 28 | switch (compareType) 29 | { 30 | case CompareType.Equal: 31 | return String.Compare(a, b, comparisonType) == 0; 32 | case CompareType.NotEqual: 33 | return String.Compare(a, b, comparisonType) != 0; 34 | case CompareType.Longer: 35 | return String.Compare(a, b, comparisonType) > 0; 36 | case CompareType.Shorter: 37 | return String.Compare(a, b, comparisonType) < 0; 38 | } 39 | throw new Exception(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/StringComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58783f051e477fd4e93b42ec7a43bb64 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/TransformComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class TransformComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType { Equals, NotEquals } 10 | 11 | public CompareType compareType; 12 | 13 | protected override bool Compare(Transform a, Transform b) 14 | { 15 | if (compareType == CompareType.Equals) 16 | { 17 | return a.position == b.position; 18 | } 19 | if (compareType == CompareType.NotEquals) 20 | { 21 | return a.position != b.position; 22 | } 23 | throw new Exception(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/TransformComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 927f2d7e4f63632448b2a63d480e601a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ValueDoesNotChange.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class ValueDoesNotChange : ActionBase 8 | { 9 | private object m_Value; 10 | 11 | protected override bool Compare(object a) 12 | { 13 | if (m_Value == null) 14 | m_Value = a; 15 | if (!m_Value.Equals(a)) 16 | return false; 17 | return true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ValueDoesNotChange.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d6d16a58a17940419a1dcbff3c60ca5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector2Comparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class Vector2Comparer : VectorComparerBase 8 | { 9 | public enum CompareType 10 | { 11 | MagnitudeEquals, 12 | MagnitudeNotEquals 13 | } 14 | 15 | public CompareType compareType; 16 | public float floatingPointError = 0.0001f; 17 | 18 | protected override bool Compare(Vector2 a, Vector2 b) 19 | { 20 | switch (compareType) 21 | { 22 | case CompareType.MagnitudeEquals: 23 | return AreVectorMagnitudeEqual(a.magnitude, 24 | b.magnitude, floatingPointError); 25 | case CompareType.MagnitudeNotEquals: 26 | return !AreVectorMagnitudeEqual(a.magnitude, 27 | b.magnitude, floatingPointError); 28 | } 29 | throw new Exception(); 30 | } 31 | public override int GetDepthOfSearch() 32 | { 33 | return 3; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector2Comparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a713db190443e814f8254a5a59014ec4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector3Comparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class Vector3Comparer : VectorComparerBase 8 | { 9 | public enum CompareType 10 | { 11 | MagnitudeEquals, 12 | MagnitudeNotEquals 13 | } 14 | 15 | public CompareType compareType; 16 | public double floatingPointError = 0.0001f; 17 | 18 | protected override bool Compare(Vector3 a, Vector3 b) 19 | { 20 | switch (compareType) 21 | { 22 | case CompareType.MagnitudeEquals: 23 | return AreVectorMagnitudeEqual(a.magnitude, 24 | b.magnitude, floatingPointError); 25 | case CompareType.MagnitudeNotEquals: 26 | return !AreVectorMagnitudeEqual(a.magnitude, 27 | b.magnitude, floatingPointError); 28 | } 29 | throw new Exception(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector3Comparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6febd2d5046657040b3da98b7010ee29 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector4Comparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class Vector4Comparer : VectorComparerBase 8 | { 9 | public enum CompareType 10 | { 11 | MagnitudeEquals, 12 | MagnitudeNotEquals 13 | } 14 | 15 | public CompareType compareType; 16 | public double floatingPointError; 17 | 18 | protected override bool Compare(Vector4 a, Vector4 b) 19 | { 20 | switch (compareType) 21 | { 22 | case CompareType.MagnitudeEquals: 23 | return AreVectorMagnitudeEqual(a.magnitude, 24 | b.magnitude, 25 | floatingPointError); 26 | case CompareType.MagnitudeNotEquals: 27 | return !AreVectorMagnitudeEqual(a.magnitude, 28 | b.magnitude, 29 | floatingPointError); 30 | } 31 | throw new Exception(); 32 | } 33 | public override int GetDepthOfSearch() 34 | { 35 | return 3; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector4Comparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 383a85a79f164d04b8a56b0ff4e04cb7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/VectorComparerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public abstract class VectorComparerBase : ComparerBaseGeneric 8 | { 9 | protected bool AreVectorMagnitudeEqual(float a, float b, double floatingPointError) 10 | { 11 | if (Math.Abs(a) < floatingPointError && Math.Abs(b) < floatingPointError) 12 | return true; 13 | if (Math.Abs(a - b) < floatingPointError) 14 | return true; 15 | return false; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/VectorComparerBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b35a237804d5eb42bd8c4e67568ae24 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a28bb39b4fb20514990895d9cb4eaea9 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd1cabf2c45d0a8489635607a6048621 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a1e855053e7e2f46ace1dc93f2036f2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionListRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d83c02fb0f220344da42a8213ed36cb5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionStripper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor.Callbacks; 4 | using UnityEngine; 5 | using UnityTest; 6 | using Object = UnityEngine.Object; 7 | 8 | public class AssertionStripper 9 | { 10 | [PostProcessScene] 11 | public static void OnPostprocessScene() 12 | { 13 | if (Debug.isDebugBuild) return; 14 | RemoveAssertionsFromGameObjects(); 15 | } 16 | 17 | private static void RemoveAssertionsFromGameObjects() 18 | { 19 | var allAssertions = Resources.FindObjectsOfTypeAll(typeof(AssertionComponent)) as AssertionComponent[]; 20 | foreach (var assertion in allAssertions) 21 | { 22 | Object.DestroyImmediate(assertion); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionStripper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95c9cd9570a6fba4198b6e4f15e11e5e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/DropDownControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | [Serializable] 9 | internal class DropDownControl 10 | { 11 | private readonly GUILayoutOption[] m_ButtonLayoutOptions = { GUILayout.ExpandWidth(true) }; 12 | public Func convertForButtonLabel = s => s.ToString(); 13 | public Func convertForGUIContent = s => s.ToString(); 14 | public Func ignoreConvertForGUIContent = t => t.Length <= 40; 15 | public Action printContextMenu = null; 16 | public string tooltip = ""; 17 | 18 | private object m_SelectedValue; 19 | 20 | 21 | public void Draw(T selected, T[] options, Action onValueSelected) 22 | { 23 | Draw(null, 24 | selected, 25 | options, 26 | onValueSelected); 27 | } 28 | 29 | public void Draw(string label, T selected, T[] options, Action onValueSelected) 30 | { 31 | Draw(label, selected, () => options, onValueSelected); 32 | } 33 | 34 | public void Draw(string label, T selected, Func loadOptions, Action onValueSelected) 35 | { 36 | if (!string.IsNullOrEmpty(label)) 37 | EditorGUILayout.BeginHorizontal(); 38 | var guiContent = new GUIContent(label); 39 | var labelSize = EditorStyles.label.CalcSize(guiContent); 40 | 41 | if (!string.IsNullOrEmpty(label)) 42 | GUILayout.Label(label, EditorStyles.label, GUILayout.Width(labelSize.x)); 43 | 44 | if (GUILayout.Button(new GUIContent(convertForButtonLabel(selected), tooltip), 45 | EditorStyles.popup, m_ButtonLayoutOptions)) 46 | { 47 | if (Event.current.button == 0) 48 | { 49 | PrintMenu(loadOptions()); 50 | } 51 | else if (printContextMenu != null && Event.current.button == 1) 52 | printContextMenu(selected); 53 | } 54 | 55 | if (m_SelectedValue != null) 56 | { 57 | onValueSelected((T)m_SelectedValue); 58 | m_SelectedValue = null; 59 | } 60 | if (!string.IsNullOrEmpty(label)) 61 | EditorGUILayout.EndHorizontal(); 62 | } 63 | 64 | public void PrintMenu(T[] options) 65 | { 66 | var menu = new GenericMenu(); 67 | foreach (var s in options) 68 | { 69 | var localS = s; 70 | menu.AddItem(new GUIContent((ignoreConvertForGUIContent(options) ? localS.ToString() : convertForGUIContent(localS))), 71 | false, 72 | () => { m_SelectedValue = localS; } 73 | ); 74 | } 75 | menu.ShowAsContext(); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/DropDownControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83ec3ed09f8f2f34ea7483e055f6d76d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByComparerRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByComparerRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | return assertionComponents.GroupBy(c => c.Action.GetType()); 13 | } 14 | 15 | protected override string GetStringKey(Type key) 16 | { 17 | return key.Name; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByComparerRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efab536803bd0154a8a7dc78e8767ad9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByExecutionMethodRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByExecutionMethodRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | var enumVals = Enum.GetValues(typeof(CheckMethod)).Cast(); 13 | var pairs = new List(); 14 | 15 | foreach (var checkMethod in enumVals) 16 | { 17 | var components = assertionComponents.Where(c => (c.checkMethods & checkMethod) == checkMethod); 18 | var componentPairs = components.Select(a => new CheckFunctionAssertionPair {checkMethod = checkMethod, assertionComponent = a}); 19 | pairs.AddRange(componentPairs); 20 | } 21 | return pairs.GroupBy(pair => pair.checkMethod, 22 | pair => pair.assertionComponent); 23 | } 24 | 25 | private class CheckFunctionAssertionPair 26 | { 27 | public AssertionComponent assertionComponent; 28 | public CheckMethod checkMethod; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByExecutionMethodRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97340abf816b1424fa835a4f26bbdc78 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByGORenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | public class GroupByGoRenderer : AssertionListRenderer 10 | { 11 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 12 | { 13 | return assertionComponents.GroupBy(c => c.gameObject); 14 | } 15 | 16 | protected override bool PrintFoldout(bool isFolded, GameObject key) 17 | { 18 | isFolded = base.PrintFoldout(isFolded, 19 | key); 20 | 21 | EditorGUILayout.ObjectField(key, 22 | typeof(GameObject), 23 | true, 24 | GUILayout.ExpandWidth(false)); 25 | 26 | return isFolded; 27 | } 28 | 29 | protected override string GetFoldoutDisplayName(GameObject key) 30 | { 31 | return key.name; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByGORenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb824de9146b42343a985aaf63beffd1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByNothingRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByNothingRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | return assertionComponents.GroupBy(c => ""); 13 | } 14 | 15 | protected override string GetStringKey(string key) 16 | { 17 | return ""; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByNothingRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33bf96aa461ea1d478bb757c52f51c95 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByTestsRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByTestsRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | return assertionComponents.GroupBy(c => 13 | { 14 | var temp = c.transform; 15 | while (temp != null) 16 | { 17 | if (temp.GetComponent("TestComponent") != null) return c.gameObject; 18 | temp = temp.parent.transform; 19 | } 20 | return null; 21 | }); 22 | } 23 | 24 | protected override string GetFoldoutDisplayName(GameObject key) 25 | { 26 | return key.name; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByTestsRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e577f31e55208b4d8a1774b958e6ed5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/PropertyPathSelector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6619da1897737044080bdb8bc60eff87 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/PropertyResolver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbbd193a27920d9478c2a766a7291d72 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/InvalidPathException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class InvalidPathException : Exception 8 | { 9 | public InvalidPathException(string path) 10 | : base("Invalid path part " + path) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/InvalidPathException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b85786dfd1aef544bf8bb873d6a4ebb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/MemberResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Text.RegularExpressions; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | public class MemberResolver 10 | { 11 | private object m_CallingObjectRef; 12 | private MemberInfo[] m_Callstack; 13 | private readonly GameObject m_GameObject; 14 | private readonly string m_Path; 15 | 16 | public MemberResolver(GameObject gameObject, string path) 17 | { 18 | path = path.Trim(); 19 | ValidatePath(path); 20 | 21 | m_GameObject = gameObject; 22 | m_Path = path.Trim(); 23 | } 24 | 25 | public object GetValue(bool useCache) 26 | { 27 | if (useCache && m_CallingObjectRef != null) 28 | { 29 | object val = m_CallingObjectRef; 30 | for (int i = 0; i < m_Callstack.Length; i++) 31 | val = GetValueFromMember(val, m_Callstack[i]); 32 | return val; 33 | } 34 | 35 | object result = GetBaseObject(); 36 | var fullCallStack = GetCallstack(); 37 | 38 | m_CallingObjectRef = result; 39 | var tempCallstack = new List(); 40 | for (int i = 0; i < fullCallStack.Length; i++) 41 | { 42 | var member = fullCallStack[i]; 43 | result = GetValueFromMember(result, member); 44 | tempCallstack.Add(member); 45 | if (result == null) return null; 46 | var type = result.GetType(); 47 | 48 | //String is not a value type but we don't want to cache it 49 | if (!IsValueType(type) && type != typeof(System.String)) 50 | { 51 | tempCallstack.Clear(); 52 | m_CallingObjectRef = result; 53 | } 54 | } 55 | m_Callstack = tempCallstack.ToArray(); 56 | return result; 57 | } 58 | 59 | public Type GetMemberType() 60 | { 61 | var callstack = GetCallstack(); 62 | if (callstack.Length == 0) return GetBaseObject().GetType(); 63 | 64 | var member = callstack[callstack.Length - 1]; 65 | if (member is FieldInfo) 66 | return (member as FieldInfo).FieldType; 67 | if (member is MethodInfo) 68 | return (member as MethodInfo).ReturnType; 69 | return null; 70 | } 71 | 72 | #region Static wrappers 73 | public static bool TryGetMemberType(GameObject gameObject, string path, out Type value) 74 | { 75 | try 76 | { 77 | var mr = new MemberResolver(gameObject, path); 78 | value = mr.GetMemberType(); 79 | return true; 80 | } 81 | catch (InvalidPathException) 82 | { 83 | value = null; 84 | return false; 85 | } 86 | } 87 | 88 | public static bool TryGetValue(GameObject gameObject, string path, out object value) 89 | { 90 | try 91 | { 92 | var mr = new MemberResolver(gameObject, path); 93 | value = mr.GetValue(false); 94 | return true; 95 | } 96 | catch (InvalidPathException) 97 | { 98 | value = null; 99 | return false; 100 | } 101 | } 102 | #endregion 103 | 104 | private object GetValueFromMember(object obj, MemberInfo memberInfo) 105 | { 106 | if (memberInfo is FieldInfo) 107 | return (memberInfo as FieldInfo).GetValue(obj); 108 | if (memberInfo is MethodInfo) 109 | return (memberInfo as MethodInfo).Invoke(obj, null); 110 | throw new InvalidPathException(memberInfo.Name); 111 | } 112 | 113 | private object GetBaseObject() 114 | { 115 | if (string.IsNullOrEmpty(m_Path)) return m_GameObject; 116 | var firstElement = m_Path.Split('.')[0]; 117 | var comp = m_GameObject.GetComponent(firstElement); 118 | if (comp != null) 119 | return comp; 120 | return m_GameObject; 121 | } 122 | 123 | private MemberInfo[] GetCallstack() 124 | { 125 | if (m_Path == "") return new MemberInfo[0]; 126 | var propsQueue = new Queue(m_Path.Split('.')); 127 | 128 | Type type = GetBaseObject().GetType(); 129 | if (type != typeof(GameObject)) 130 | propsQueue.Dequeue(); 131 | 132 | PropertyInfo propertyTemp; 133 | FieldInfo fieldTemp; 134 | var list = new List(); 135 | while (propsQueue.Count != 0) 136 | { 137 | var nameToFind = propsQueue.Dequeue(); 138 | fieldTemp = GetField(type, nameToFind); 139 | if (fieldTemp != null) 140 | { 141 | type = fieldTemp.FieldType; 142 | list.Add(fieldTemp); 143 | continue; 144 | } 145 | propertyTemp = GetProperty(type, nameToFind); 146 | if (propertyTemp != null) 147 | { 148 | type = propertyTemp.PropertyType; 149 | var getMethod = GetGetMethod(propertyTemp); 150 | list.Add(getMethod); 151 | continue; 152 | } 153 | throw new InvalidPathException(nameToFind); 154 | } 155 | return list.ToArray(); 156 | } 157 | 158 | private void ValidatePath(string path) 159 | { 160 | bool invalid = false; 161 | if (path.StartsWith(".") || path.EndsWith(".")) 162 | invalid = true; 163 | if (path.IndexOf("..") >= 0) 164 | invalid = true; 165 | if (Regex.IsMatch(path, @"\s")) 166 | invalid = true; 167 | 168 | if (invalid) 169 | throw new InvalidPathException(path); 170 | } 171 | 172 | private static bool IsValueType(Type type) 173 | { 174 | #if !UNITY_METRO 175 | return type.IsValueType; 176 | #else 177 | return false; 178 | #endif 179 | } 180 | 181 | private static FieldInfo GetField(Type type, string fieldName) 182 | { 183 | #if !UNITY_METRO 184 | return type.GetField(fieldName); 185 | #else 186 | return null; 187 | #endif 188 | } 189 | 190 | private static PropertyInfo GetProperty(Type type, string propertyName) 191 | { 192 | #if !UNITY_METRO 193 | return type.GetProperty(propertyName); 194 | #else 195 | return null; 196 | #endif 197 | } 198 | 199 | private static MethodInfo GetGetMethod(PropertyInfo propertyInfo) 200 | { 201 | #if !UNITY_METRO 202 | return propertyInfo.GetGetMethod(); 203 | #else 204 | return null; 205 | #endif 206 | } 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/MemberResolver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80df8ef907961e34dbcc7c89b22729b9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2caba6436df568499c84c1c607ce766 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4ab061d0035ee545a936bdf8f3f8620 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Icons.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | namespace UnityTest 9 | { 10 | public static class Icons 11 | { 12 | const string k_IconsFolderName = "icons"; 13 | private static readonly string k_IconsFolderPath = String.Format("UnityTestTools{0}Common{0}Editor{0}{1}", Path.DirectorySeparatorChar, k_IconsFolderName); 14 | 15 | private static readonly string k_IconsAssetsPath = ""; 16 | 17 | public static readonly Texture2D FailImg; 18 | public static readonly Texture2D IgnoreImg; 19 | public static readonly Texture2D SuccessImg; 20 | public static readonly Texture2D UnknownImg; 21 | public static readonly Texture2D InconclusiveImg; 22 | public static readonly Texture2D StopwatchImg; 23 | 24 | public static readonly GUIContent GUIUnknownImg; 25 | public static readonly GUIContent GUIInconclusiveImg; 26 | public static readonly GUIContent GUIIgnoreImg; 27 | public static readonly GUIContent GUISuccessImg; 28 | public static readonly GUIContent GUIFailImg; 29 | 30 | static Icons() 31 | { 32 | var dirs = Directory.GetDirectories("Assets", k_IconsFolderName, SearchOption.AllDirectories).Where(s => s.EndsWith(k_IconsFolderPath)); 33 | if (dirs.Any()) 34 | k_IconsAssetsPath = dirs.First(); 35 | else 36 | Debug.LogWarning("The UnityTestTools asset folder path is incorrect. If you relocated the tools please change the path accordingly (Icons.cs)."); 37 | 38 | FailImg = LoadTexture("failed.png"); 39 | IgnoreImg = LoadTexture("ignored.png"); 40 | SuccessImg = LoadTexture("passed.png"); 41 | UnknownImg = LoadTexture("normal.png"); 42 | InconclusiveImg = LoadTexture("inconclusive.png"); 43 | StopwatchImg = LoadTexture("stopwatch.png"); 44 | 45 | GUIUnknownImg = new GUIContent(UnknownImg); 46 | GUIInconclusiveImg = new GUIContent(InconclusiveImg); 47 | GUIIgnoreImg = new GUIContent(IgnoreImg); 48 | GUISuccessImg = new GUIContent(SuccessImg); 49 | GUIFailImg = new GUIContent(FailImg); 50 | } 51 | 52 | private static Texture2D LoadTexture(string fileName) 53 | { 54 | return (Texture2D)AssetDatabase.LoadAssetAtPath(k_IconsAssetsPath + Path.DirectorySeparatorChar + fileName, typeof(Texture2D)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Icons.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8571844b0c115b84cbe8b3f67e8dec04 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | namespace UnityTest 9 | { 10 | public abstract class ProjectSettingsBase : ScriptableObject 11 | { 12 | private static readonly string k_SettingsPath = Path.Combine("UnityTestTools", "Common"); 13 | const string k_SettingsFolder = "Settings"; 14 | 15 | public virtual void Save() 16 | { 17 | EditorUtility.SetDirty(this); 18 | } 19 | 20 | public static T Load() where T : ProjectSettingsBase, new () 21 | { 22 | var pathsInProject = Directory.GetDirectories("Assets", "*", SearchOption.AllDirectories) 23 | .Where(s => s.Contains(k_SettingsPath)); 24 | 25 | if (pathsInProject.Count() == 0) Debug.LogError("Can't find settings path: " + k_SettingsPath); 26 | 27 | string pathInProject = Path.Combine(pathsInProject.First(), k_SettingsFolder); 28 | var assetPath = Path.Combine(pathInProject, typeof(T).Name) + ".asset"; 29 | var settings = AssetDatabase.LoadAssetAtPath(assetPath, typeof(T)) as T; 30 | 31 | if (settings != null) return settings; 32 | 33 | settings = CreateInstance(); 34 | Directory.CreateDirectory(pathInProject); 35 | AssetDatabase.CreateAsset(settings, assetPath); 36 | return settings; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ac961be07107124a88dcb81927143d4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ffbf5a07740aa5479651bd415f52ebb 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs: -------------------------------------------------------------------------------- 1 | // **************************************************************** 2 | // Based on nUnit 2.6.2 (http://www.nunit.org/) 3 | // **************************************************************** 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | namespace UnityTest 10 | { 11 | /// 12 | /// Summary description for ResultSummarizer. 13 | /// 14 | public class ResultSummarizer 15 | { 16 | private int m_ErrorCount; 17 | private int m_FailureCount; 18 | private int m_IgnoreCount; 19 | private int m_InconclusiveCount; 20 | private int m_NotRunnable; 21 | private int m_ResultCount; 22 | private int m_SkipCount; 23 | private int m_SuccessCount; 24 | private int m_TestsRun; 25 | 26 | private TimeSpan m_Duration; 27 | 28 | public ResultSummarizer(IEnumerable results) 29 | { 30 | foreach (var result in results) 31 | Summarize(result); 32 | } 33 | 34 | public bool Success 35 | { 36 | get { return m_FailureCount == 0; } 37 | } 38 | 39 | /// 40 | /// Returns the number of test cases for which results 41 | /// have been summarized. Any tests excluded by use of 42 | /// Category or Explicit attributes are not counted. 43 | /// 44 | public int ResultCount 45 | { 46 | get { return m_ResultCount; } 47 | } 48 | 49 | /// 50 | /// Returns the number of test cases actually run, which 51 | /// is the same as ResultCount, less any Skipped, Ignored 52 | /// or NonRunnable tests. 53 | /// 54 | public int TestsRun 55 | { 56 | get { return m_TestsRun; } 57 | } 58 | 59 | /// 60 | /// Returns the number of tests that passed 61 | /// 62 | public int Passed 63 | { 64 | get { return m_SuccessCount; } 65 | } 66 | 67 | /// 68 | /// Returns the number of test cases that had an error. 69 | /// 70 | public int Errors 71 | { 72 | get { return m_ErrorCount; } 73 | } 74 | 75 | /// 76 | /// Returns the number of test cases that failed. 77 | /// 78 | public int Failures 79 | { 80 | get { return m_FailureCount; } 81 | } 82 | 83 | /// 84 | /// Returns the number of test cases that failed. 85 | /// 86 | public int Inconclusive 87 | { 88 | get { return m_InconclusiveCount; } 89 | } 90 | 91 | /// 92 | /// Returns the number of test cases that were not runnable 93 | /// due to errors in the signature of the class or method. 94 | /// Such tests are also counted as Errors. 95 | /// 96 | public int NotRunnable 97 | { 98 | get { return m_NotRunnable; } 99 | } 100 | 101 | /// 102 | /// Returns the number of test cases that were skipped. 103 | /// 104 | public int Skipped 105 | { 106 | get { return m_SkipCount; } 107 | } 108 | 109 | public int Ignored 110 | { 111 | get { return m_IgnoreCount; } 112 | } 113 | 114 | public double Duration 115 | { 116 | get { return m_Duration.TotalSeconds; } 117 | } 118 | 119 | public int TestsNotRun 120 | { 121 | get { return m_SkipCount + m_IgnoreCount + m_NotRunnable; } 122 | } 123 | 124 | public void Summarize(ITestResult result) 125 | { 126 | m_Duration += TimeSpan.FromSeconds(result.Duration); 127 | m_ResultCount++; 128 | 129 | if(!result.Executed) 130 | { 131 | if(result.IsIgnored) 132 | { 133 | m_IgnoreCount++; 134 | return; 135 | } 136 | 137 | m_SkipCount++; 138 | return; 139 | } 140 | 141 | switch (result.ResultState) 142 | { 143 | case TestResultState.Success: 144 | m_SuccessCount++; 145 | m_TestsRun++; 146 | break; 147 | case TestResultState.Failure: 148 | m_FailureCount++; 149 | m_TestsRun++; 150 | break; 151 | case TestResultState.Error: 152 | case TestResultState.Cancelled: 153 | m_ErrorCount++; 154 | m_TestsRun++; 155 | break; 156 | case TestResultState.Inconclusive: 157 | m_InconclusiveCount++; 158 | m_TestsRun++; 159 | break; 160 | case TestResultState.NotRunnable: 161 | m_NotRunnable++; 162 | // errorCount++; 163 | break; 164 | case TestResultState.Ignored: 165 | m_IgnoreCount++; 166 | break; 167 | default: 168 | m_SkipCount++; 169 | break; 170 | } 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce89106be5bd4204388d58510e4e55da 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/StackTraceFilter.cs: -------------------------------------------------------------------------------- 1 | // **************************************************************** 2 | // Based on nUnit 2.6.2 (http://www.nunit.org/) 3 | // **************************************************************** 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using UnityEngine; 9 | 10 | namespace UnityTest 11 | { 12 | /// 13 | /// Summary description for StackTraceFilter. 14 | /// 15 | public class StackTraceFilter 16 | { 17 | public static string Filter(string stack) 18 | { 19 | if (stack == null) return null; 20 | var sw = new StringWriter(); 21 | var sr = new StringReader(stack); 22 | 23 | try 24 | { 25 | string line; 26 | while ((line = sr.ReadLine()) != null) 27 | { 28 | if (!FilterLine(line)) 29 | sw.WriteLine(line.Trim()); 30 | } 31 | } 32 | catch (Exception) 33 | { 34 | return stack; 35 | } 36 | return sw.ToString(); 37 | } 38 | 39 | static bool FilterLine(string line) 40 | { 41 | string[] patterns = 42 | { 43 | "NUnit.Core.TestCase", 44 | "NUnit.Core.ExpectedExceptionTestCase", 45 | "NUnit.Core.TemplateTestCase", 46 | "NUnit.Core.TestResult", 47 | "NUnit.Core.TestSuite", 48 | "NUnit.Framework.Assertion", 49 | "NUnit.Framework.Assert", 50 | "System.Reflection.MonoMethod" 51 | }; 52 | 53 | for (int i = 0; i < patterns.Length; i++) 54 | { 55 | if (line.IndexOf(patterns[i]) > 0) 56 | return true; 57 | } 58 | 59 | return false; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/StackTraceFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe6b4d68575d4ba44b1d5c5c3f0e96d3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/XmlResultWriter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9bba41ace7686d4ab0c400d1e7f55b7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Styles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public static class Styles 9 | { 10 | public static GUIStyle info; 11 | public static GUIStyle testList; 12 | 13 | public static GUIStyle selectedFoldout; 14 | public static GUIStyle foldout; 15 | public static GUIStyle toolbarLabel; 16 | 17 | public static GUIStyle testName; 18 | 19 | private static readonly Color k_SelectedColor = new Color(0.3f, 0.5f, 0.85f); 20 | 21 | static Styles() 22 | { 23 | info = new GUIStyle(EditorStyles.wordWrappedLabel); 24 | info.wordWrap = false; 25 | info.stretchHeight = true; 26 | info.margin.right = 15; 27 | 28 | testList = new GUIStyle("CN Box"); 29 | testList.margin.top = 0; 30 | testList.padding.left = 3; 31 | 32 | foldout = new GUIStyle(EditorStyles.foldout); 33 | selectedFoldout = new GUIStyle(EditorStyles.foldout); 34 | selectedFoldout.onFocused.textColor = selectedFoldout.focused.textColor = 35 | selectedFoldout.onActive.textColor = selectedFoldout.active.textColor = 36 | selectedFoldout.onNormal.textColor = selectedFoldout.normal.textColor = k_SelectedColor; 37 | 38 | toolbarLabel = new GUIStyle(EditorStyles.toolbarButton); 39 | toolbarLabel.normal.background = null; 40 | toolbarLabel.contentOffset = new Vector2(0, -2); 41 | 42 | testName = new GUIStyle(EditorStyles.label); 43 | testName.padding.left += 12; 44 | testName.focused.textColor = testName.onFocused.textColor = k_SelectedColor; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Styles.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8b92379e11501742b1badcbb08da812 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | using System.Linq; 6 | 7 | namespace UnityTest 8 | { 9 | public class TestFilterSettings 10 | { 11 | public bool ShowSucceeded; 12 | public bool ShowFailed; 13 | public bool ShowIgnored; 14 | public bool ShowNotRun; 15 | 16 | public string FilterByName; 17 | public int FilterByCategory; 18 | 19 | private GUIContent _succeededBtn; 20 | private GUIContent _failedBtn; 21 | private GUIContent _ignoredBtn; 22 | private GUIContent _notRunBtn; 23 | 24 | public string[] AvailableCategories; 25 | 26 | private readonly string _prefsKey; 27 | 28 | public TestFilterSettings(string prefsKey) 29 | { 30 | _prefsKey = prefsKey; 31 | Load(); 32 | UpdateCounters(Enumerable.Empty()); 33 | } 34 | 35 | public void Load() 36 | { 37 | ShowSucceeded = EditorPrefs.GetBool(_prefsKey + ".ShowSucceeded", true); 38 | ShowFailed = EditorPrefs.GetBool(_prefsKey + ".ShowFailed", true); 39 | ShowIgnored = EditorPrefs.GetBool(_prefsKey + ".ShowIgnored", true); 40 | ShowNotRun = EditorPrefs.GetBool(_prefsKey + ".ShowNotRun", true); 41 | FilterByName = EditorPrefs.GetString(_prefsKey + ".FilterByName", string.Empty); 42 | FilterByCategory = EditorPrefs.GetInt(_prefsKey + ".FilterByCategory", 0); 43 | } 44 | 45 | public void Save() 46 | { 47 | EditorPrefs.SetBool(_prefsKey + ".ShowSucceeded", ShowSucceeded); 48 | EditorPrefs.SetBool(_prefsKey + ".ShowFailed", ShowFailed); 49 | EditorPrefs.SetBool(_prefsKey + ".ShowIgnored", ShowIgnored); 50 | EditorPrefs.SetBool(_prefsKey + ".ShowNotRun", ShowNotRun); 51 | EditorPrefs.SetString(_prefsKey + ".FilterByName", FilterByName); 52 | EditorPrefs.SetInt(_prefsKey + ".FilterByCategory", FilterByCategory); 53 | } 54 | 55 | public void UpdateCounters(IEnumerable results) 56 | { 57 | var summary = new ResultSummarizer(results); 58 | 59 | _succeededBtn = new GUIContent(summary.Passed.ToString(), Icons.SuccessImg, "Show tests that succeeded"); 60 | _failedBtn = new GUIContent((summary.Errors + summary.Failures + summary.Inconclusive).ToString(), Icons.FailImg, "Show tests that failed"); 61 | _ignoredBtn = new GUIContent((summary.Ignored + summary.NotRunnable).ToString(), Icons.IgnoreImg, "Show tests that are ignored"); 62 | _notRunBtn = new GUIContent((summary.TestsNotRun - summary.Ignored - summary.NotRunnable).ToString(), Icons.UnknownImg, "Show tests that didn't run"); 63 | } 64 | 65 | public string[] GetSelectedCategories() 66 | { 67 | if(AvailableCategories == null) return new string[0]; 68 | 69 | return AvailableCategories.Where ((c, i) => (FilterByCategory & (1 << i)) != 0).ToArray(); 70 | } 71 | 72 | public void OnGUI() 73 | { 74 | EditorGUI.BeginChangeCheck(); 75 | 76 | FilterByName = GUILayout.TextField(FilterByName, "ToolbarSeachTextField", GUILayout.MinWidth(100), GUILayout.MaxWidth(250), GUILayout.ExpandWidth(true)); 77 | if(GUILayout.Button (GUIContent.none, string.IsNullOrEmpty(FilterByName) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton")) 78 | FilterByName = string.Empty; 79 | 80 | if (AvailableCategories != null && AvailableCategories.Length > 0) 81 | FilterByCategory = EditorGUILayout.MaskField(FilterByCategory, AvailableCategories, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(90)); 82 | 83 | ShowSucceeded = GUILayout.Toggle(ShowSucceeded, _succeededBtn, EditorStyles.toolbarButton); 84 | ShowFailed = GUILayout.Toggle(ShowFailed, _failedBtn, EditorStyles.toolbarButton); 85 | ShowIgnored = GUILayout.Toggle(ShowIgnored, _ignoredBtn, EditorStyles.toolbarButton); 86 | ShowNotRun = GUILayout.Toggle(ShowNotRun, _notRunBtn, EditorStyles.toolbarButton); 87 | 88 | if(EditorGUI.EndChangeCheck()) Save (); 89 | } 90 | 91 | public RenderingOptions BuildRenderingOptions() 92 | { 93 | var options = new RenderingOptions(); 94 | options.showSucceeded = ShowSucceeded; 95 | options.showFailed = ShowFailed; 96 | options.showIgnored = ShowIgnored; 97 | options.showNotRunned = ShowNotRun; 98 | options.nameFilter = FilterByName; 99 | options.categories = GetSelectedCategories(); 100 | return options; 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a2d025e58bff433e963d0a4cd7599ef 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8bb6eae11352f44da0d6d8a8959b69e 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/Common/Editor/icons/failed.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/failed.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41488feb372865440b7c01773f04c0cf 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 0 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: 1 28 | mipBias: -1 29 | wrapMode: 1 30 | nPOTScale: 0 31 | lightmap: 0 32 | compressionQuality: 50 33 | textureType: 2 34 | buildTargetSettings: [] 35 | userData: 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/ignored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/Common/Editor/icons/ignored.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/ignored.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0076bfa6073f17546b3535ac1b456b0b 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 0 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: 1 28 | mipBias: -1 29 | wrapMode: 1 30 | nPOTScale: 0 31 | lightmap: 0 32 | compressionQuality: 50 33 | textureType: 2 34 | buildTargetSettings: [] 35 | userData: 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/inconclusive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/Common/Editor/icons/inconclusive.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/inconclusive.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e28761099904678488cdddf7b6be2ceb 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 0 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: 1 28 | mipBias: -1 29 | wrapMode: 1 30 | nPOTScale: 0 31 | lightmap: 0 32 | compressionQuality: 50 33 | textureType: 2 34 | buildTargetSettings: [] 35 | userData: 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/Common/Editor/icons/normal.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9f3c491f4c2f9f43ac33a27c16913dd 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 0 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: 1 28 | mipBias: -1 29 | wrapMode: 1 30 | nPOTScale: 0 31 | lightmap: 0 32 | compressionQuality: 50 33 | textureType: 2 34 | buildTargetSettings: [] 35 | userData: 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/Common/Editor/icons/passed.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/passed.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31f7928179ee46d4690d274579efb037 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 0 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: 1 28 | mipBias: -1 29 | wrapMode: 1 30 | nPOTScale: 0 31 | lightmap: 0 32 | compressionQuality: 50 33 | textureType: 2 34 | buildTargetSettings: [] 35 | userData: 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/stopwatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/Common/Editor/icons/stopwatch.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/stopwatch.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f73f95ae19d51af47ad56044f2779aa1 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 0 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: 1 28 | mipBias: -1 29 | wrapMode: 1 30 | nPOTScale: 0 31 | lightmap: 0 32 | compressionQuality: 50 33 | textureType: 2 34 | buildTargetSettings: [] 35 | userData: 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/ITestResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityTest; 5 | 6 | public interface ITestResult 7 | { 8 | TestResultState ResultState { get; } 9 | 10 | string Message { get; } 11 | 12 | string Logs { get; } 13 | 14 | bool Executed { get; } 15 | 16 | string Name { get; } 17 | 18 | string FullName { get; } 19 | 20 | string Id { get; } 21 | 22 | bool IsSuccess { get; } 23 | 24 | double Duration { get; } 25 | 26 | string StackTrace { get; } 27 | 28 | bool IsIgnored { get; } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/ITestResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1e4e2c4d00b3f2469494fc0f67cdeae 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/TestResultState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public enum TestResultState : byte 8 | { 9 | Inconclusive = 0, 10 | 11 | /// 12 | /// The test was not runnable. 13 | /// 14 | NotRunnable = 1, 15 | 16 | /// 17 | /// The test has been skipped. 18 | /// 19 | Skipped = 2, 20 | 21 | /// 22 | /// The test has been ignored. 23 | /// 24 | Ignored = 3, 25 | 26 | /// 27 | /// The test succeeded 28 | /// 29 | Success = 4, 30 | 31 | /// 32 | /// The test failed 33 | /// 34 | Failure = 5, 35 | 36 | /// 37 | /// The test encountered an unexpected exception 38 | /// 39 | Error = 6, 40 | 41 | /// 42 | /// The test was cancelled by the user 43 | /// 44 | Cancelled = 7 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/TestResultState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da3ca54ee4cce064989d27165f3081fb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Documentation.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://bitbucket.org/Unity-Technologies/unitytesttools/wiki 3 | IconIndex=0 -------------------------------------------------------------------------------- /Assets/UnityTestTools/Documentation.url.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28f1b62e1364e5a4e88f7bb94dbcf183 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 241054a0fe63fbb4bb51609fce9b3112 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/Libs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e22ba039de7077c4aa95758ef723b803 3 | folderAsset: yes 4 | timeCreated: 1445282049 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 713231d47408a06408a45470c967bae8 3 | timeCreated: 1441797177 4 | licenseType: Store 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Any: 12 | enabled: 0 13 | settings: {} 14 | Editor: 15 | enabled: 1 16 | settings: 17 | DefaultValueInitialized: true 18 | userData: 19 | assetBundleName: 20 | assetBundleVariant: 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28fc22990733f8f4ea1137f15e363609 3 | timeCreated: 1441797177 4 | licenseType: Store 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Any: 12 | enabled: 0 13 | settings: {} 14 | Editor: 15 | enabled: 1 16 | settings: 17 | DefaultValueInitialized: true 18 | userData: 19 | assetBundleName: 20 | assetBundleVariant: 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da93545c3ab1aa043bcfb22281b1f66c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/DTOFormatter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.Serialization; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | 10 | public class DTOFormatter { 11 | 12 | private interface ITransferInterface 13 | { 14 | void Transfer(ref ResultDTO.MessageType val); 15 | void Transfer(ref TestResultState val); 16 | void Transfer(ref byte val); 17 | void Transfer(ref bool val); 18 | void Transfer(ref int val); 19 | void Transfer(ref float val); 20 | void Transfer(ref double val); 21 | void Transfer(ref string val); 22 | } 23 | 24 | private class Writer : ITransferInterface 25 | { 26 | private readonly Stream _stream; 27 | public Writer(Stream stream) { _stream = stream; } 28 | 29 | private void WriteConvertedNumber(byte[] bytes) 30 | { 31 | if(BitConverter.IsLittleEndian) 32 | Array.Reverse(bytes); 33 | _stream.Write(bytes, 0, bytes.Length); 34 | } 35 | 36 | public void Transfer(ref ResultDTO.MessageType val) { _stream.WriteByte((byte)val); } 37 | public void Transfer(ref TestResultState val) { _stream.WriteByte((byte)val); } 38 | public void Transfer(ref byte val) { _stream.WriteByte(val); } 39 | public void Transfer(ref bool val) { _stream.WriteByte((byte)(val ? 0x01 : 0x00)); } 40 | public void Transfer(ref int val) { WriteConvertedNumber(BitConverter.GetBytes(val)); } 41 | public void Transfer(ref float val) { WriteConvertedNumber(BitConverter.GetBytes(val)); } 42 | public void Transfer(ref double val) { WriteConvertedNumber(BitConverter.GetBytes(val)); } 43 | 44 | public void Transfer(ref string val) 45 | { 46 | var bytes = Encoding.BigEndianUnicode.GetBytes(val); 47 | int length = bytes.Length; 48 | Transfer(ref length); 49 | _stream.Write(bytes, 0, bytes.Length); 50 | } 51 | } 52 | 53 | private class Reader : ITransferInterface 54 | { 55 | private readonly Stream _stream; 56 | public Reader(Stream stream) { _stream = stream; } 57 | 58 | private byte[] ReadConvertedNumber(int size) 59 | { 60 | byte[] buffer = new byte[size]; 61 | _stream.Read (buffer, 0, buffer.Length); 62 | if(BitConverter.IsLittleEndian) 63 | Array.Reverse(buffer); 64 | return buffer; 65 | } 66 | 67 | public void Transfer(ref ResultDTO.MessageType val) { val = (ResultDTO.MessageType)_stream.ReadByte(); } 68 | public void Transfer(ref TestResultState val) { val = (TestResultState)_stream.ReadByte(); } 69 | public void Transfer(ref byte val) { val = (byte)_stream.ReadByte(); } 70 | public void Transfer(ref bool val) { val = (_stream.ReadByte() != 0); } 71 | public void Transfer(ref int val) { val = BitConverter.ToInt32(ReadConvertedNumber(4), 0); } 72 | public void Transfer(ref float val) { val = BitConverter.ToSingle(ReadConvertedNumber(4), 0); } 73 | public void Transfer(ref double val) { val = BitConverter.ToDouble(ReadConvertedNumber(8), 0); } 74 | 75 | public void Transfer(ref string val) 76 | { 77 | int length = 0; 78 | Transfer (ref length); 79 | var bytes = new byte[length]; 80 | int remain = length; 81 | int index = 0; 82 | do { 83 | int bytesRead = _stream.Read(bytes, index, remain); 84 | remain -= bytesRead; 85 | index += bytesRead; 86 | } while (remain > 0); 87 | #if !UNITY_WSA 88 | val = Encoding.BigEndianUnicode.GetString(bytes); 89 | #endif 90 | } 91 | } 92 | 93 | private void Transfer(ResultDTO dto, ITransferInterface transfer) 94 | { 95 | transfer.Transfer(ref dto.messageType); 96 | 97 | transfer.Transfer(ref dto.levelCount); 98 | transfer.Transfer(ref dto.loadedLevel); 99 | transfer.Transfer(ref dto.loadedLevelName); 100 | 101 | if(dto.messageType == ResultDTO.MessageType.Ping 102 | || dto.messageType == ResultDTO.MessageType.RunStarted 103 | || dto.messageType == ResultDTO.MessageType.RunFinished 104 | || dto.messageType == ResultDTO.MessageType.RunInterrupted 105 | || dto.messageType == ResultDTO.MessageType.AllScenesFinished) 106 | return; 107 | 108 | transfer.Transfer(ref dto.testName); 109 | transfer.Transfer(ref dto.testTimeout); 110 | 111 | if(dto.messageType == ResultDTO.MessageType.TestStarted) 112 | return; 113 | 114 | if(transfer is Reader) 115 | dto.testResult = new SerializableTestResult(); 116 | SerializableTestResult str = (SerializableTestResult)dto.testResult; 117 | 118 | transfer.Transfer(ref str.resultState); 119 | transfer.Transfer(ref str.message); 120 | transfer.Transfer(ref str.executed); 121 | transfer.Transfer(ref str.name); 122 | transfer.Transfer(ref str.fullName); 123 | transfer.Transfer(ref str.id); 124 | transfer.Transfer(ref str.isSuccess); 125 | transfer.Transfer(ref str.duration); 126 | transfer.Transfer(ref str.stackTrace); 127 | } 128 | 129 | public void Serialize (Stream stream, ResultDTO dto) 130 | { 131 | Transfer(dto, new Writer(stream)); 132 | } 133 | 134 | public object Deserialize (Stream stream) 135 | { 136 | #if !UNITY_WSA 137 | var result = (ResultDTO)FormatterServices.GetSafeUninitializedObject(typeof(ResultDTO)); 138 | Transfer (result, new Reader(stream)); 139 | return result; 140 | #else 141 | return null; 142 | #endif 143 | } 144 | } 145 | 146 | } -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/DTOFormatter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ae2470508a854b1c9df5375d03f8f58 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: caee08596a5965747b8edfde19e2f873 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29d4fb050362c5b43aea52342045543a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/EditorReferencesUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEngine; 7 | using Object = UnityEngine.Object; 8 | 9 | namespace UnityTest 10 | { 11 | public static class EditorReferencesUtil 12 | { 13 | 14 | public static List FindScenesWhichContainAsset(string file) 15 | { 16 | string assetPath = GetAssetPathFromFileNameAndExtension (file); 17 | Object cur = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)); 18 | return AllScenes.Where(a => ADependsOnB(a, cur)).ToList(); 19 | } 20 | 21 | private static string CleanPathSeparators(string s) 22 | { 23 | const string forwardSlash = "/"; 24 | const string backSlash = "\\"; 25 | return s.Replace(backSlash, forwardSlash); 26 | } 27 | 28 | private static string GetRelativeAssetPathFromFullPath(string fullPath) 29 | { 30 | fullPath = CleanPathSeparators(fullPath); 31 | if (fullPath.Contains(Application.dataPath)) 32 | { 33 | return fullPath.Replace(Application.dataPath, "Assets"); 34 | } 35 | Debug.LogWarning("Path does not point to a location within Assets: " + fullPath); 36 | return null; 37 | } 38 | 39 | private static string GetAssetPathFromFileNameAndExtension(string assetName) 40 | { 41 | string[] assets = AssetDatabase.FindAssets (Path.GetFileNameWithoutExtension (assetName)); 42 | string assetPath = null; 43 | 44 | foreach (string guid in assets) { 45 | string relativePath = AssetDatabase.GUIDToAssetPath (guid); 46 | 47 | if (Path.GetFileName (relativePath) == Path.GetFileName (assetName)) 48 | assetPath = relativePath; 49 | } 50 | 51 | return assetPath; 52 | } 53 | 54 | private static List DirSearch(DirectoryInfo d, string searchFor) 55 | { 56 | List founditems = d.GetFiles(searchFor).ToList(); 57 | 58 | // Add (by recursing) subdirectory items. 59 | DirectoryInfo[] dis = d.GetDirectories(); 60 | foreach (DirectoryInfo di in dis) 61 | founditems.AddRange(DirSearch(di, searchFor)); 62 | 63 | return (founditems); 64 | } 65 | 66 | private static List AllScenes 67 | { 68 | get 69 | { 70 | // get every single one of the files in the Assets folder. 71 | List files = DirSearch(new DirectoryInfo(Application.dataPath), "*.unity"); 72 | 73 | // now make them all into Asset references. 74 | List assetRefs = new List(); 75 | 76 | foreach (FileInfo fi in files) 77 | { 78 | if (fi.Name.StartsWith(".")) 79 | continue; // Unity ignores dotfiles. 80 | assetRefs.Add(AssetDatabase.LoadMainAssetAtPath(GetRelativeAssetPathFromFullPath(fi.FullName))); 81 | } 82 | return assetRefs; 83 | } 84 | } 85 | 86 | private static bool ADependsOnB(Object obj, Object selectedObj) 87 | { 88 | if (selectedObj == null) return false; 89 | 90 | //optionally, exclude self. 91 | if (selectedObj == obj) return false; 92 | 93 | Object[] dependencies = EditorUtility.CollectDependencies(new Object[1] { obj }); 94 | if (dependencies.Length < 2) return false; // if there's only one, it's us. 95 | 96 | foreach (Object dep in dependencies) 97 | if (dep == selectedObj) 98 | return true; 99 | return false; 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/EditorReferencesUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aad501c968b324cf3a8d1c52eb09ca04 3 | timeCreated: 1437322927 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/GuiHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text.RegularExpressions; 6 | using Mono.Cecil; 7 | using Mono.Cecil.Cil; 8 | using Mono.Cecil.Mdb; 9 | using Mono.Collections.Generic; 10 | using UnityEditor; 11 | using UnityEditorInternal; 12 | using UnityEngine; 13 | 14 | namespace UnityTest 15 | { 16 | public static class GuiHelper 17 | { 18 | public static bool GetConsoleErrorPause() 19 | { 20 | Assembly assembly = Assembly.GetAssembly(typeof(SceneView)); 21 | Type type = assembly.GetType("UnityEditorInternal.LogEntries"); 22 | PropertyInfo method = type.GetProperty("consoleFlags"); 23 | var result = (int)method.GetValue(new object(), new object[] { }); 24 | return (result & (1 << 2)) != 0; 25 | } 26 | 27 | public static void SetConsoleErrorPause(bool b) 28 | { 29 | Assembly assembly = Assembly.GetAssembly(typeof(SceneView)); 30 | Type type = assembly.GetType("UnityEditorInternal.LogEntries"); 31 | MethodInfo method = type.GetMethod("SetConsoleFlag"); 32 | method.Invoke(new object(), new object[] { 1 << 2, b }); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/GuiHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b95014154ef554485afc9c0316556d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsHierarchyAnnotation.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEditor; 4 | 5 | namespace UnityTest 6 | { 7 | 8 | [InitializeOnLoad] 9 | public class IntegrationTestsHierarchyAnnotation { 10 | 11 | static IntegrationTestsHierarchyAnnotation() 12 | { 13 | EditorApplication.hierarchyWindowItemOnGUI += DoAnnotationGUI; 14 | } 15 | 16 | public static void DoAnnotationGUI(int id, Rect rect) 17 | { 18 | var obj = EditorUtility.InstanceIDToObject(id) as GameObject; 19 | if(!obj) return; 20 | 21 | var tc = obj.GetComponent(); 22 | if(!tc) return; 23 | 24 | if (!EditorApplication.isPlayingOrWillChangePlaymode 25 | && rect.Contains(Event.current.mousePosition) 26 | && Event.current.type == EventType.MouseDown 27 | && Event.current.button == 1) 28 | { 29 | IntegrationTestRendererBase.DrawContextMenu(tc); 30 | Event.current.Use (); 31 | } 32 | 33 | EditorGUIUtility.SetIconSize(new Vector2(15, 15)); 34 | var result = IntegrationTestsRunnerWindow.GetResultForTest(tc); 35 | if (result != null) 36 | { 37 | var icon = result.Executed ? IntegrationTestRendererBase.GetIconForResult(result.resultType) : Icons.UnknownImg; 38 | EditorGUI.LabelField(new Rect(rect.xMax - 18, rect.yMin - 2, rect.width, rect.height), new GUIContent(icon)); 39 | } 40 | EditorGUIUtility.SetIconSize(Vector2.zero); 41 | } 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsHierarchyAnnotation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 219cdb080b08741948fc5deb8c7d47f0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace UnityTest 7 | { 8 | public class IntegrationTestsRunnerSettings : ProjectSettingsBase 9 | { 10 | public bool blockUIWhenRunning = true; 11 | public bool pauseOnTestFailure; 12 | 13 | public void ToggleBlockUIWhenRunning () 14 | { 15 | blockUIWhenRunning = !blockUIWhenRunning; 16 | Save (); 17 | } 18 | 19 | public void TogglePauseOnTestFailure() 20 | { 21 | pauseOnTestFailure = !pauseOnTestFailure; 22 | Save (); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d01dc4c8f278da489d7d54c83f19cb9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c898357efb599944818326bb43ba879 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c44e9167d633ee94bb6e078238178308 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ade4197221f35dc44adb7649f99af2e7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Net.Sockets; 5 | using UnityEditor; 6 | using UnityEditorInternal; 7 | using UnityEngine; 8 | using System.Linq; 9 | 10 | namespace UnityTest.IntegrationTests 11 | { 12 | public class PlatformRunner 13 | { 14 | public static BuildTarget defaultBuildTarget 15 | { 16 | get 17 | { 18 | var target = EditorPrefs.GetString("ITR-platformRunnerBuildTarget"); 19 | BuildTarget buildTarget; 20 | try 21 | { 22 | buildTarget = (BuildTarget)Enum.Parse(typeof(BuildTarget), target); 23 | } 24 | catch 25 | { 26 | return GetDefaultBuildTarget(); 27 | } 28 | return buildTarget; 29 | } 30 | set { EditorPrefs.SetString("ITR-platformRunnerBuildTarget", value.ToString()); } 31 | } 32 | 33 | [MenuItem("Unity Test Tools/Platform Runner/Run current scene %#&r")] 34 | public static void BuildAndRunCurrentScene() 35 | { 36 | Debug.Log("Building and running current test for " + defaultBuildTarget); 37 | BuildAndRunInPlayer(new PlatformRunnerConfiguration(defaultBuildTarget)); 38 | } 39 | 40 | [MenuItem("Unity Test Tools/Platform Runner/Run on platform %#r")] 41 | public static void RunInPlayer() 42 | { 43 | var w = EditorWindow.GetWindow(typeof(PlatformRunnerSettingsWindow)); 44 | w.Show(); 45 | } 46 | 47 | public static void BuildAndRunInPlayer(PlatformRunnerConfiguration configuration) 48 | { 49 | NetworkResultsReceiver.StopReceiver(); 50 | 51 | var settings = new PlayerSettingConfigurator(false); 52 | 53 | if (configuration.sendResultsOverNetwork) 54 | { 55 | try 56 | { 57 | var l = new TcpListener(IPAddress.Any, configuration.port); 58 | l.Start(); 59 | configuration.port = ((IPEndPoint)l.Server.LocalEndPoint).Port; 60 | l.Stop(); 61 | } 62 | catch (SocketException e) 63 | { 64 | Debug.LogException(e); 65 | if (InternalEditorUtility.inBatchMode) 66 | EditorApplication.Exit(Batch.returnCodeRunError); 67 | } 68 | } 69 | 70 | if (InternalEditorUtility.inBatchMode) 71 | settings.AddConfigurationFile(TestRunnerConfigurator.batchRunFileMarker, ""); 72 | 73 | if (configuration.sendResultsOverNetwork) 74 | settings.AddConfigurationFile(TestRunnerConfigurator.integrationTestsNetwork, 75 | string.Join("\n", configuration.GetConnectionIPs())); 76 | 77 | settings.AddConfigurationFile (TestRunnerConfigurator.testScenesToRun, string.Join ("\n", configuration.testScenes.ToArray())); 78 | 79 | settings.ChangeSettingsForIntegrationTests(); 80 | 81 | AssetDatabase.Refresh(); 82 | 83 | var result = BuildPipeline.BuildPlayer(configuration.testScenes.Concat(configuration.buildScenes).ToArray(), 84 | configuration.GetTempPath(), 85 | configuration.buildTarget, 86 | BuildOptions.AutoRunPlayer | BuildOptions.Development); 87 | 88 | settings.RevertSettingsChanges(); 89 | settings.RemoveAllConfigurationFiles(); 90 | 91 | AssetDatabase.Refresh(); 92 | 93 | if (!string.IsNullOrEmpty(result)) 94 | { 95 | if (InternalEditorUtility.inBatchMode) 96 | EditorApplication.Exit(Batch.returnCodeRunError); 97 | return; 98 | } 99 | 100 | if (configuration.sendResultsOverNetwork) 101 | NetworkResultsReceiver.StartReceiver(configuration); 102 | else if (InternalEditorUtility.inBatchMode) 103 | EditorApplication.Exit(Batch.returnCodeTestsOk); 104 | } 105 | 106 | private static BuildTarget GetDefaultBuildTarget() 107 | { 108 | switch (EditorUserBuildSettings.selectedBuildTargetGroup) 109 | { 110 | case BuildTargetGroup.Android: 111 | return BuildTarget.Android; 112 | default: 113 | { 114 | switch (Application.platform) 115 | { 116 | case RuntimePlatform.WindowsPlayer: 117 | return BuildTarget.StandaloneWindows; 118 | case RuntimePlatform.OSXPlayer: 119 | return BuildTarget.StandaloneOSXIntel; 120 | case RuntimePlatform.LinuxPlayer: 121 | return BuildTarget.StandaloneLinux; 122 | } 123 | return BuildTarget.WebGL; 124 | } 125 | } 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3581fa3f207a8a4c9988b9f59a510d3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Net.Sockets; 7 | using UnityEditor; 8 | using UnityEngine; 9 | using UnityEngine.SceneManagement; 10 | 11 | [Serializable] 12 | public class PlatformRunnerConfiguration 13 | { 14 | public List buildScenes; 15 | public List testScenes; 16 | public BuildTarget buildTarget; 17 | public bool runInEditor; 18 | public string projectName = SceneManager.GetActiveScene().path; 19 | 20 | public string resultsDir = null; 21 | public bool sendResultsOverNetwork; 22 | public List ipList; 23 | public int port; 24 | 25 | public PlatformRunnerConfiguration(BuildTarget buildTarget) 26 | { 27 | this.buildTarget = buildTarget; 28 | projectName = SceneManager.GetActiveScene().path; 29 | } 30 | 31 | public PlatformRunnerConfiguration() 32 | : this(BuildTarget.StandaloneWindows) 33 | { 34 | } 35 | 36 | public string GetTempPath() 37 | { 38 | if (string.IsNullOrEmpty(projectName)) 39 | projectName = Path.GetTempFileName(); 40 | 41 | var path = Path.Combine("Temp", projectName); 42 | switch (buildTarget) 43 | { 44 | case BuildTarget.StandaloneWindows: 45 | case BuildTarget.StandaloneWindows64: 46 | return path + ".exe"; 47 | case BuildTarget.StandaloneOSXIntel: 48 | case BuildTarget.StandaloneOSXIntel64: 49 | case BuildTarget.StandaloneLinuxUniversal: 50 | return path + ".app"; 51 | case BuildTarget.Android: 52 | return path + ".apk"; 53 | default: 54 | return path; 55 | } 56 | } 57 | 58 | public string[] GetConnectionIPs() 59 | { 60 | return ipList.Select(ip => ip + ":" + port).ToArray(); 61 | } 62 | 63 | public static int TryToGetFreePort() 64 | { 65 | var port = -1; 66 | try 67 | { 68 | var l = new TcpListener(IPAddress.Any, 0); 69 | l.Start(); 70 | port = ((IPEndPoint)l.Server.LocalEndPoint).Port; 71 | l.Stop(); 72 | } 73 | catch (SocketException e) 74 | { 75 | Debug.LogException(e); 76 | } 77 | return port; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b98fe8c3761da2d4b8cfd8bd6df7050f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityTest 5 | { 6 | public class PlatformRunnerSettings : ProjectSettingsBase 7 | { 8 | public string resultsPath; 9 | public bool sendResultsOverNetwork = true; 10 | public int port = 0; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 964f5f0db2c95bb41aa3dc3beba1f06b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3819282b0887bc742911b89745080acb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlayerSettingConfigurator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | class PlayerSettingConfigurator 10 | { 11 | private string resourcesPath { 12 | get { return m_Temp ? k_TempPath : m_ProjectResourcesPath; } 13 | } 14 | 15 | private readonly string m_ProjectResourcesPath = Path.Combine("Assets", "Resources"); 16 | const string k_TempPath = "Temp"; 17 | private readonly bool m_Temp; 18 | 19 | private ResolutionDialogSetting m_DisplayResolutionDialog; 20 | private bool m_RunInBackground; 21 | private bool m_FullScreen; 22 | private bool m_ResizableWindow; 23 | private readonly List m_TempFileList = new List(); 24 | 25 | public PlayerSettingConfigurator(bool saveInTempFolder) 26 | { 27 | m_Temp = saveInTempFolder; 28 | } 29 | 30 | public void ChangeSettingsForIntegrationTests() 31 | { 32 | m_DisplayResolutionDialog = PlayerSettings.displayResolutionDialog; 33 | PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; 34 | 35 | m_RunInBackground = PlayerSettings.runInBackground; 36 | PlayerSettings.runInBackground = true; 37 | 38 | m_FullScreen = PlayerSettings.defaultIsFullScreen; 39 | PlayerSettings.defaultIsFullScreen = false; 40 | 41 | m_ResizableWindow = PlayerSettings.resizableWindow; 42 | PlayerSettings.resizableWindow = true; 43 | } 44 | 45 | public void RevertSettingsChanges() 46 | { 47 | PlayerSettings.defaultIsFullScreen = m_FullScreen; 48 | PlayerSettings.runInBackground = m_RunInBackground; 49 | PlayerSettings.displayResolutionDialog = m_DisplayResolutionDialog; 50 | PlayerSettings.resizableWindow = m_ResizableWindow; 51 | } 52 | 53 | public void AddConfigurationFile(string fileName, string content) 54 | { 55 | var resourcesPathExists = Directory.Exists(resourcesPath); 56 | if (!resourcesPathExists) AssetDatabase.CreateFolder("Assets", "Resources"); 57 | 58 | var filePath = Path.Combine(resourcesPath, fileName); 59 | File.WriteAllText(filePath, content); 60 | 61 | m_TempFileList.Add(filePath); 62 | } 63 | 64 | public void RemoveAllConfigurationFiles() 65 | { 66 | foreach (var filePath in m_TempFileList) 67 | AssetDatabase.DeleteAsset(filePath); 68 | if (Directory.Exists(resourcesPath) 69 | && Directory.GetFiles(resourcesPath).Length == 0) 70 | AssetDatabase.DeleteAsset(resourcesPath); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlayerSettingConfigurator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7adbe43058d54047b6109b2e66894fd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5944b82e46f1682439d20b4c3a4f029c 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestGroupLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | class IntegrationTestGroupLine : IntegrationTestRendererBase 10 | { 11 | public static List FoldMarkers; 12 | private IntegrationTestRendererBase[] m_Children; 13 | 14 | public IntegrationTestGroupLine(GameObject gameObject) : base(gameObject) 15 | { 16 | } 17 | 18 | protected internal override void DrawLine(Rect rect, GUIContent label, bool isSelected, RenderingOptions options) 19 | { 20 | EditorGUI.BeginChangeCheck(); 21 | var isClassFolded = !EditorGUI.Foldout(rect, !Folded, label, isSelected ? Styles.selectedFoldout : Styles.foldout); 22 | if (EditorGUI.EndChangeCheck()) Folded = isClassFolded; 23 | } 24 | 25 | private bool Folded 26 | { 27 | get { return FoldMarkers.Contains(m_GameObject); } 28 | 29 | set 30 | { 31 | if (value) FoldMarkers.Add(m_GameObject); 32 | else FoldMarkers.RemoveAll(s => s == m_GameObject); 33 | } 34 | } 35 | 36 | protected internal override void Render(int indend, RenderingOptions options) 37 | { 38 | base.Render(indend, options); 39 | if (!Folded) 40 | foreach (var child in m_Children) 41 | child.Render(indend + 1, options); 42 | } 43 | 44 | protected internal override TestResult.ResultType GetResult() 45 | { 46 | bool ignored = false; 47 | bool success = false; 48 | foreach (var child in m_Children) 49 | { 50 | var result = child.GetResult(); 51 | 52 | if (result == TestResult.ResultType.Failed || result == TestResult.ResultType.FailedException || result == TestResult.ResultType.Timeout) 53 | return TestResult.ResultType.Failed; 54 | if (result == TestResult.ResultType.Success) 55 | success = true; 56 | else if (result == TestResult.ResultType.Ignored) 57 | ignored = true; 58 | else 59 | ignored = false; 60 | } 61 | if (success) return TestResult.ResultType.Success; 62 | if (ignored) return TestResult.ResultType.Ignored; 63 | return TestResult.ResultType.NotRun; 64 | } 65 | 66 | protected internal override bool IsVisible(RenderingOptions options) 67 | { 68 | return m_Children.Any(c => c.IsVisible(options)); 69 | } 70 | 71 | public override bool SetCurrentTest(TestComponent tc) 72 | { 73 | m_IsRunning = false; 74 | foreach (var child in m_Children) 75 | m_IsRunning |= child.SetCurrentTest(tc); 76 | return m_IsRunning; 77 | } 78 | 79 | public void AddChildren(IntegrationTestRendererBase[] parseTestList) 80 | { 81 | m_Children = parseTestList; 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestGroupLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6dc74195aa98ef4da8901199cda4a63 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | class IntegrationTestLine : IntegrationTestRendererBase 9 | { 10 | public static List Results; 11 | protected TestResult m_Result; 12 | 13 | public IntegrationTestLine(GameObject gameObject, TestResult testResult) : base(gameObject) 14 | { 15 | m_Result = testResult; 16 | } 17 | 18 | protected internal override void DrawLine(Rect rect, GUIContent label, bool isSelected, RenderingOptions options) 19 | { 20 | if(Event.current.type != EventType.repaint) 21 | return; 22 | 23 | Styles.testName.Draw (rect, label, false, false, false, isSelected); 24 | 25 | if (m_Result.IsTimeout) 26 | { 27 | float min, max; 28 | Styles.testName.CalcMinMaxWidth(label, out min, out max); 29 | var timeoutRect = new Rect(rect); 30 | timeoutRect.x += min - 12; 31 | Styles.testName.Draw(timeoutRect, s_GUITimeoutIcon, false, false, false, isSelected); 32 | } 33 | } 34 | 35 | protected internal override TestResult.ResultType GetResult() 36 | { 37 | if (!m_Result.Executed && test.ignored) return TestResult.ResultType.Ignored; 38 | return m_Result.resultType; 39 | } 40 | 41 | protected internal override bool IsVisible(RenderingOptions options) 42 | { 43 | if (!string.IsNullOrEmpty(options.nameFilter) && !m_GameObject.name.ToLower().Contains(options.nameFilter.ToLower())) return false; 44 | if (!options.showSucceeded && m_Result.IsSuccess) return false; 45 | if (!options.showFailed && m_Result.IsFailure) return false; 46 | if (!options.showNotRunned && !m_Result.Executed) return false; 47 | if (!options.showIgnored && test.ignored) return false; 48 | return true; 49 | } 50 | 51 | public override bool SetCurrentTest(TestComponent tc) 52 | { 53 | m_IsRunning = test == tc; 54 | return m_IsRunning; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 212be02e4a7da194688b08ab0c946fbd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestRendererBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | using Object = UnityEngine.Object; 7 | 8 | namespace UnityTest 9 | { 10 | public abstract class IntegrationTestRendererBase : IComparable 11 | { 12 | public static Action> RunTest; 13 | 14 | protected static bool s_Refresh; 15 | 16 | private static readonly GUIContent k_GUIRunSelected = new GUIContent("Run Selected"); 17 | private static readonly GUIContent k_GUIRun = new GUIContent("Run"); 18 | private static readonly GUIContent k_GUIDelete = new GUIContent("Delete"); 19 | private static readonly GUIContent k_GUIDeleteSelected = new GUIContent("Delete selected"); 20 | 21 | protected static GUIContent s_GUITimeoutIcon = new GUIContent(Icons.StopwatchImg, "Timeout"); 22 | 23 | protected GameObject m_GameObject; 24 | public TestComponent test; 25 | private readonly string m_Name; 26 | 27 | protected IntegrationTestRendererBase(GameObject gameObject) 28 | { 29 | test = gameObject.GetComponent(typeof(TestComponent)) as TestComponent; 30 | if (test == null) throw new ArgumentException("Provided GameObject is not a test object"); 31 | m_GameObject = gameObject; 32 | m_Name = test.Name; 33 | } 34 | 35 | public int CompareTo(IntegrationTestRendererBase other) 36 | { 37 | return test.CompareTo(other.test); 38 | } 39 | 40 | public bool Render(RenderingOptions options) 41 | { 42 | s_Refresh = false; 43 | EditorGUIUtility.SetIconSize(new Vector2(15, 15)); 44 | Render(0, options); 45 | EditorGUIUtility.SetIconSize(Vector2.zero); 46 | return s_Refresh; 47 | } 48 | 49 | protected internal virtual void Render(int indend, RenderingOptions options) 50 | { 51 | if (!IsVisible(options)) return; 52 | EditorGUILayout.BeginHorizontal(); 53 | GUILayout.Space(indend * 10); 54 | 55 | var tempColor = GUI.color; 56 | if (m_IsRunning) 57 | { 58 | var frame = Mathf.Abs(Mathf.Cos(Time.realtimeSinceStartup * 4)) * 0.6f + 0.4f; 59 | GUI.color = new Color(1, 1, 1, frame); 60 | } 61 | 62 | var isSelected = Selection.gameObjects.Contains(m_GameObject); 63 | 64 | var value = GetResult(); 65 | var icon = GetIconForResult(value); 66 | 67 | var label = new GUIContent(m_Name, icon); 68 | var labelRect = GUILayoutUtility.GetRect(label, EditorStyles.label, GUILayout.ExpandWidth(true), GUILayout.Height(18)); 69 | 70 | OnLeftMouseButtonClick(labelRect); 71 | OnContextClick(labelRect); 72 | DrawLine(labelRect, label, isSelected, options); 73 | 74 | if (m_IsRunning) GUI.color = tempColor; 75 | EditorGUILayout.EndHorizontal(); 76 | } 77 | 78 | protected void OnSelect() 79 | { 80 | if (!Event.current.control && !Event.current.command) 81 | { 82 | Selection.objects = new Object[0]; 83 | GUIUtility.keyboardControl = 0; 84 | } 85 | 86 | if ((Event.current.control || Event.current.command) && Selection.gameObjects.Contains(test.gameObject)) 87 | Selection.objects = Selection.gameObjects.Where(o => o != test.gameObject).ToArray(); 88 | else 89 | Selection.objects = Selection.gameObjects.Concat(new[] { test.gameObject }).ToArray(); 90 | } 91 | 92 | protected void OnLeftMouseButtonClick(Rect rect) 93 | { 94 | if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.mouseDown && Event.current.button == 0) 95 | { 96 | rect.width = 20; 97 | if (rect.Contains(Event.current.mousePosition)) return; 98 | Event.current.Use(); 99 | OnSelect(); 100 | } 101 | } 102 | 103 | protected void OnContextClick(Rect rect) 104 | { 105 | if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.ContextClick) 106 | { 107 | DrawContextMenu(test); 108 | } 109 | } 110 | 111 | public static void DrawContextMenu(TestComponent testComponent) 112 | { 113 | if (EditorApplication.isPlayingOrWillChangePlaymode) return; 114 | 115 | var selectedTests = Selection.gameObjects.Where(go => go.GetComponent(typeof(TestComponent))); 116 | var manySelected = selectedTests.Count() > 1; 117 | 118 | var m = new GenericMenu(); 119 | if (manySelected) 120 | { 121 | // var testsToRun 122 | m.AddItem(k_GUIRunSelected, false, data => RunTest(selectedTests.Select(o => o.GetComponent(typeof(TestComponent))).Cast().ToList()), null); 123 | } 124 | m.AddItem(k_GUIRun, false, data => RunTest(new[] { testComponent }), null); 125 | m.AddSeparator(""); 126 | m.AddItem(manySelected ? k_GUIDeleteSelected : k_GUIDelete, false, data => RemoveTests(selectedTests.ToArray()), null); 127 | m.ShowAsContext(); 128 | } 129 | 130 | private static void RemoveTests(GameObject[] testsToDelete) 131 | { 132 | foreach (var t in testsToDelete) 133 | { 134 | Undo.DestroyObjectImmediate(t); 135 | } 136 | } 137 | 138 | public static Texture GetIconForResult(TestResult.ResultType resultState) 139 | { 140 | switch (resultState) 141 | { 142 | case TestResult.ResultType.Success: 143 | return Icons.SuccessImg; 144 | case TestResult.ResultType.Timeout: 145 | case TestResult.ResultType.Failed: 146 | case TestResult.ResultType.FailedException: 147 | return Icons.FailImg; 148 | case TestResult.ResultType.Ignored: 149 | return Icons.IgnoreImg; 150 | default: 151 | return Icons.UnknownImg; 152 | } 153 | } 154 | 155 | protected internal bool m_IsRunning; 156 | protected internal abstract void DrawLine(Rect rect, GUIContent label, bool isSelected, RenderingOptions options); 157 | protected internal abstract TestResult.ResultType GetResult(); 158 | protected internal abstract bool IsVisible(RenderingOptions options); 159 | public abstract bool SetCurrentTest(TestComponent tc); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestRendererBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 604645a3b57179a4d873906b625ef8ec 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/RenderingOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class RenderingOptions 8 | { 9 | public string nameFilter; 10 | public bool showSucceeded; 11 | public bool showFailed; 12 | public bool showIgnored; 13 | public bool showNotRunned; 14 | public string[] categories; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/RenderingOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c0aec4b4a6d1b047a98e8cc213e1a36 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | using Object = UnityEngine.Object; 7 | using UnityEditor.SceneManagement; 8 | 9 | namespace UnityTest 10 | { 11 | [CanEditMultipleObjects] 12 | [CustomEditor(typeof(TestComponent))] 13 | public class TestComponentEditor : Editor 14 | { 15 | private SerializedProperty m_ExpectException; 16 | private SerializedProperty m_ExpectedExceptionList; 17 | private SerializedProperty m_Ignored; 18 | private SerializedProperty m_SucceedAssertions; 19 | private SerializedProperty m_SucceedWhenExceptionIsThrown; 20 | private SerializedProperty m_Timeout; 21 | 22 | #region GUI Contens 23 | 24 | private readonly GUIContent m_GUIExpectException = new GUIContent("Expect exception", "Should the test expect an exception"); 25 | private readonly GUIContent m_GUIExpectExceptionList = new GUIContent("Expected exception list", "A comma separated list of exception types which will not fail the test when thrown"); 26 | private readonly GUIContent m_GUIIgnore = new GUIContent("Ignore", "Ignore the tests in runs"); 27 | private readonly GUIContent m_GUIIncludePlatforms = new GUIContent("Included platforms", "Platform on which the test should run"); 28 | private readonly GUIContent m_GUISuccedOnAssertions = new GUIContent("Succeed on assertions", "Succeed after all assertions are executed"); 29 | private readonly GUIContent m_GUISucceedWhenExceptionIsThrown = new GUIContent("Succeed when exception is thrown", "Should the test succeed when an expected exception is thrown"); 30 | private readonly GUIContent m_GUITestName = new GUIContent("Test name", "Name of the test (is equal to the GameObject name)"); 31 | private readonly GUIContent m_GUITimeout = new GUIContent("Timeout", "Number of seconds after which the test will timeout"); 32 | 33 | #endregion 34 | 35 | public void OnEnable() 36 | { 37 | m_Timeout = serializedObject.FindProperty("timeout"); 38 | m_Ignored = serializedObject.FindProperty("ignored"); 39 | m_SucceedAssertions = serializedObject.FindProperty("succeedAfterAllAssertionsAreExecuted"); 40 | m_ExpectException = serializedObject.FindProperty("expectException"); 41 | m_ExpectedExceptionList = serializedObject.FindProperty("expectedExceptionList"); 42 | m_SucceedWhenExceptionIsThrown = serializedObject.FindProperty("succeedWhenExceptionIsThrown"); 43 | } 44 | 45 | public override void OnInspectorGUI() 46 | { 47 | var component = (TestComponent)target; 48 | 49 | if (component.dynamic) 50 | { 51 | if(GUILayout.Button("Reload dynamic tests")) 52 | { 53 | TestComponent.DestroyAllDynamicTests(); 54 | Selection.objects = new Object[0]; 55 | IntegrationTestsRunnerWindow.selectedInHierarchy = false; 56 | GUIUtility.ExitGUI(); 57 | return; 58 | } 59 | EditorGUILayout.HelpBox("This is a test generated from code. No changes in the component will be persisted.", MessageType.Info); 60 | } 61 | 62 | if (component.IsTestGroup()) 63 | { 64 | EditorGUI.BeginChangeCheck(); 65 | var newGroupName = EditorGUILayout.TextField(m_GUITestName, component.name); 66 | if (EditorGUI.EndChangeCheck()) component.name = newGroupName; 67 | 68 | serializedObject.ApplyModifiedProperties(); 69 | return; 70 | } 71 | 72 | serializedObject.Update(); 73 | 74 | EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects); 75 | 76 | EditorGUI.BeginChangeCheck(); 77 | var newName = EditorGUILayout.TextField(m_GUITestName, component.name); 78 | if (EditorGUI.EndChangeCheck()) component.name = newName; 79 | 80 | if (component.platformsToIgnore == null) 81 | { 82 | component.platformsToIgnore = GetListOfIgnoredPlatforms(Enum.GetNames(typeof(TestComponent.IncludedPlatforms)), (int)component.includedPlatforms); 83 | } 84 | 85 | var enumList = Enum.GetNames(typeof(RuntimePlatform)); 86 | var flags = GetFlagList(enumList, component.platformsToIgnore); 87 | flags = EditorGUILayout.MaskField(m_GUIIncludePlatforms, flags, enumList, EditorStyles.popup); 88 | var newList = GetListOfIgnoredPlatforms(enumList, flags); 89 | if (!component.dynamic) 90 | component.platformsToIgnore = newList; 91 | EditorGUI.EndDisabledGroup(); 92 | 93 | EditorGUILayout.PropertyField(m_Timeout, m_GUITimeout); 94 | EditorGUILayout.PropertyField(m_Ignored, m_GUIIgnore); 95 | EditorGUILayout.PropertyField(m_SucceedAssertions, m_GUISuccedOnAssertions); 96 | EditorGUILayout.PropertyField(m_ExpectException, m_GUIExpectException); 97 | 98 | EditorGUI.BeginDisabledGroup(!m_ExpectException.boolValue); 99 | EditorGUILayout.PropertyField(m_ExpectedExceptionList, m_GUIExpectExceptionList); 100 | EditorGUILayout.PropertyField(m_SucceedWhenExceptionIsThrown, m_GUISucceedWhenExceptionIsThrown); 101 | EditorGUI.EndDisabledGroup(); 102 | 103 | if (!component.dynamic) 104 | serializedObject.ApplyModifiedProperties(); 105 | if (GUI.changed) 106 | EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); 107 | } 108 | 109 | private string[] GetListOfIgnoredPlatforms(string[] enumList, int flags) 110 | { 111 | var notSelectedPlatforms = new List(); 112 | for (int i = 0; i < enumList.Length; i++) 113 | { 114 | var sel = (flags & (1 << i)) != 0; 115 | if (!sel) notSelectedPlatforms.Add(enumList[i]); 116 | } 117 | return notSelectedPlatforms.ToArray(); 118 | } 119 | 120 | private int GetFlagList(string[] enumList, string[] platformsToIgnore) 121 | { 122 | int flags = ~0; 123 | for (int i = 0; i < enumList.Length; i++) 124 | if (platformsToIgnore != null && platformsToIgnore.Any(s => s == enumList[i])) 125 | flags &= ~(1 << i); 126 | return flags; 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 160889f21f4d5944b9f6fcaf9c33f684 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ITestRunnerCallback.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest.IntegrationTestRunner 6 | { 7 | public interface ITestRunnerCallback 8 | { 9 | void RunStarted(string platform, List testsToRun); 10 | void RunFinished(List testResults); 11 | void AllScenesFinished(); 12 | void TestStarted(TestResult test); 13 | void TestFinished(TestResult test); 14 | void TestRunInterrupted(List testsNotRun); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ITestRunnerCallback.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35af7d395e501a348ae1a0aa3c91dee4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEngine; 6 | 7 | public static class IntegrationTest 8 | { 9 | public const string passMessage = "IntegrationTest Pass"; 10 | public const string failMessage = "IntegrationTest Fail"; 11 | 12 | public static void Pass() 13 | { 14 | LogResult(passMessage); 15 | } 16 | 17 | public static void Pass(GameObject go) 18 | { 19 | LogResult(go, passMessage); 20 | } 21 | 22 | public static void Fail(string reason) 23 | { 24 | Fail(); 25 | if (!string.IsNullOrEmpty(reason)) Debug.Log(reason); 26 | } 27 | 28 | public static void Fail(GameObject go, string reason) 29 | { 30 | Fail(go); 31 | if (!string.IsNullOrEmpty(reason)) Debug.Log(reason); 32 | } 33 | 34 | public static void Fail() 35 | { 36 | LogResult(failMessage); 37 | } 38 | 39 | public static void Fail(GameObject go) 40 | { 41 | LogResult(go, failMessage); 42 | } 43 | 44 | public static void Assert(bool condition) 45 | { 46 | Assert(condition, ""); 47 | } 48 | 49 | public static void Assert(GameObject go, bool condition) 50 | { 51 | Assert(go, condition, ""); 52 | } 53 | 54 | public static void Assert(bool condition, string message) 55 | { 56 | if (!condition) 57 | Fail(message); 58 | } 59 | 60 | public static void Assert(GameObject go, bool condition, string message) 61 | { 62 | if (!condition) 63 | Fail(go, message); 64 | } 65 | 66 | private static void LogResult(string message) 67 | { 68 | Debug.Log(message); 69 | } 70 | 71 | private static void LogResult(GameObject go, string message) 72 | { 73 | Debug.Log(message + " (" + FindTestObject(go).name + ")", go); 74 | } 75 | 76 | private static GameObject FindTestObject(GameObject go) 77 | { 78 | var temp = go; 79 | while (temp.transform.parent != null) 80 | { 81 | if (temp.GetComponent("TestComponent") != null) 82 | return temp; 83 | temp = temp.transform.parent.gameObject; 84 | } 85 | return go; 86 | } 87 | 88 | #region Dynamic test attributes 89 | 90 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 91 | public class ExcludePlatformAttribute : Attribute 92 | { 93 | public string[] platformsToExclude; 94 | 95 | public ExcludePlatformAttribute(params RuntimePlatform[] platformsToExclude) 96 | { 97 | this.platformsToExclude = platformsToExclude.Select(platform => platform.ToString()).ToArray(); 98 | } 99 | } 100 | 101 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 102 | public class ExpectExceptions : Attribute 103 | { 104 | public string[] exceptionTypeNames; 105 | public bool succeedOnException; 106 | 107 | public ExpectExceptions() : this(false) 108 | { 109 | } 110 | 111 | public ExpectExceptions(bool succeedOnException) : this(succeedOnException, new string[0]) 112 | { 113 | } 114 | 115 | public ExpectExceptions(bool succeedOnException, params string[] exceptionTypeNames) 116 | { 117 | this.succeedOnException = succeedOnException; 118 | this.exceptionTypeNames = exceptionTypeNames; 119 | } 120 | 121 | public ExpectExceptions(bool succeedOnException, params Type[] exceptionTypes) 122 | : this(succeedOnException, exceptionTypes.Select(type => type.FullName).ToArray()) 123 | { 124 | } 125 | 126 | public ExpectExceptions(params string[] exceptionTypeNames) : this(false, exceptionTypeNames) 127 | { 128 | } 129 | 130 | public ExpectExceptions(params Type[] exceptionTypes) : this(false, exceptionTypes) 131 | { 132 | } 133 | } 134 | 135 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 136 | public class IgnoreAttribute : Attribute 137 | { 138 | } 139 | 140 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 141 | public class DynamicTestAttribute : Attribute 142 | { 143 | private readonly string m_SceneName; 144 | 145 | public DynamicTestAttribute(string sceneName) 146 | { 147 | if (sceneName.EndsWith(".unity")) 148 | sceneName = sceneName.Substring(0, sceneName.Length - ".unity".Length); 149 | m_SceneName = sceneName; 150 | } 151 | 152 | public bool IncludeOnScene(string sceneName) 153 | { 154 | var fileName = Path.GetFileNameWithoutExtension(sceneName); 155 | return fileName == m_SceneName; 156 | } 157 | } 158 | 159 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 160 | public class SucceedWithAssertions : Attribute 161 | { 162 | } 163 | 164 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 165 | public class TimeoutAttribute : Attribute 166 | { 167 | public float timeout; 168 | 169 | public TimeoutAttribute(float seconds) 170 | { 171 | timeout = seconds; 172 | } 173 | } 174 | 175 | #endregion 176 | } 177 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb367bbc76e489443a4ebc8b0a8642f4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTestAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using UnityEngine; 5 | 6 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 7 | public class IntegrationTestAttribute : Attribute 8 | { 9 | private readonly string m_Path; 10 | 11 | public IntegrationTestAttribute(string path) 12 | { 13 | if (path.EndsWith(".unity")) 14 | path = path.Substring(0, path.Length - ".unity".Length); 15 | m_Path = path; 16 | } 17 | 18 | public bool IncludeOnScene(string scenePath) 19 | { 20 | if (scenePath == m_Path) return true; 21 | var fileName = Path.GetFileNameWithoutExtension(scenePath); 22 | return fileName == m_Path; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTestAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1a5c61a06ed66e41a6ee1b5f88b5afd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTestsProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest.IntegrationTestRunner 7 | { 8 | class IntegrationTestsProvider 9 | { 10 | internal Dictionary> testCollection = new Dictionary>(); 11 | internal ITestComponent currentTestGroup; 12 | internal IEnumerable testToRun; 13 | 14 | public IntegrationTestsProvider(IEnumerable tests) 15 | { 16 | testToRun = tests; 17 | foreach (var test in tests.OrderBy(component => component)) 18 | { 19 | if (test.IsTestGroup()) 20 | { 21 | throw new Exception(test.Name + " is test a group"); 22 | } 23 | AddTestToList(test); 24 | } 25 | if (currentTestGroup == null) 26 | { 27 | currentTestGroup = FindInnerTestGroup(TestComponent.NullTestComponent); 28 | } 29 | } 30 | 31 | private void AddTestToList(ITestComponent test) 32 | { 33 | var group = test.GetTestGroup(); 34 | if (!testCollection.ContainsKey(group)) 35 | testCollection.Add(group, new HashSet()); 36 | testCollection[group].Add(test); 37 | if (group == TestComponent.NullTestComponent) return; 38 | AddTestToList(group); 39 | } 40 | 41 | public ITestComponent GetNextTest() 42 | { 43 | var test = testCollection[currentTestGroup].First(); 44 | testCollection[currentTestGroup].Remove(test); 45 | test.EnableTest(true); 46 | return test; 47 | } 48 | 49 | public void FinishTest(ITestComponent test) 50 | { 51 | try 52 | { 53 | test.EnableTest(false); 54 | currentTestGroup = FindNextTestGroup(currentTestGroup); 55 | } 56 | catch (MissingReferenceException e) 57 | { 58 | Debug.LogException(e); 59 | } 60 | } 61 | 62 | private ITestComponent FindNextTestGroup(ITestComponent testGroup) 63 | { 64 | if (testGroup == null) 65 | throw new Exception ("No test left"); 66 | 67 | if (testCollection[testGroup].Any()) 68 | { 69 | testGroup.EnableTest(true); 70 | return FindInnerTestGroup(testGroup); 71 | } 72 | testCollection.Remove(testGroup); 73 | testGroup.EnableTest(false); 74 | 75 | var parentTestGroup = testGroup.GetTestGroup(); 76 | if (parentTestGroup == null) return null; 77 | 78 | testCollection[parentTestGroup].Remove(testGroup); 79 | return FindNextTestGroup(parentTestGroup); 80 | } 81 | 82 | private ITestComponent FindInnerTestGroup(ITestComponent group) 83 | { 84 | var innerGroups = testCollection[group]; 85 | foreach (var innerGroup in innerGroups) 86 | { 87 | if (!innerGroup.IsTestGroup()) continue; 88 | innerGroup.EnableTest(true); 89 | return FindInnerTestGroup(innerGroup); 90 | } 91 | return group; 92 | } 93 | 94 | public bool AnyTestsLeft() 95 | { 96 | return testCollection.Count != 0; 97 | } 98 | 99 | public List GetRemainingTests() 100 | { 101 | var remainingTests = new List(); 102 | foreach (var test in testCollection) 103 | { 104 | remainingTests.AddRange(test.Value); 105 | } 106 | return remainingTests; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTestsProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21d32637b19ee51489062a66ad922193 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/NetworkResultSender.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_METRO && (UNITY_PRO_LICENSE || !(UNITY_ANDROID || UNITY_IPHONE)) 2 | #define UTT_SOCKETS_SUPPORTED 3 | #endif 4 | using System; 5 | using System.Collections.Generic; 6 | using UnityEngine; 7 | using UnityTest.IntegrationTestRunner; 8 | 9 | #if UTT_SOCKETS_SUPPORTED 10 | using System.Net.Sockets; 11 | using System.Runtime.Serialization.Formatters.Binary; 12 | #endif 13 | 14 | namespace UnityTest 15 | { 16 | public class NetworkResultSender : ITestRunnerCallback 17 | { 18 | #if UTT_SOCKETS_SUPPORTED 19 | private readonly TimeSpan m_ConnectionTimeout = TimeSpan.FromSeconds(5); 20 | 21 | private readonly string m_Ip; 22 | private readonly int m_Port; 23 | #endif 24 | private bool m_LostConnection; 25 | 26 | public NetworkResultSender(string ip, int port) 27 | { 28 | #if UTT_SOCKETS_SUPPORTED 29 | m_Ip = ip; 30 | m_Port = port; 31 | #endif 32 | } 33 | 34 | private bool SendDTO(ResultDTO dto) 35 | { 36 | if (m_LostConnection) return false; 37 | #if UTT_SOCKETS_SUPPORTED 38 | try 39 | { 40 | using (var tcpClient = new TcpClient()) 41 | { 42 | var result = tcpClient.BeginConnect(m_Ip, m_Port, null, null); 43 | var success = result.AsyncWaitHandle.WaitOne(m_ConnectionTimeout); 44 | if (!success) 45 | { 46 | return false; 47 | } 48 | try 49 | { 50 | tcpClient.EndConnect(result); 51 | } 52 | catch (SocketException) 53 | { 54 | m_LostConnection = true; 55 | return false; 56 | } 57 | 58 | var bf = new DTOFormatter(); 59 | bf.Serialize(tcpClient.GetStream(), dto); 60 | tcpClient.GetStream().Close(); 61 | tcpClient.Close(); 62 | Debug.Log("Sent " + dto.messageType); 63 | } 64 | } 65 | catch (SocketException e) 66 | { 67 | Debug.LogException(e); 68 | m_LostConnection = true; 69 | return false; 70 | } 71 | #endif // if UTT_SOCKETS_SUPPORTED 72 | return true; 73 | } 74 | 75 | public bool Ping() 76 | { 77 | var result = SendDTO(ResultDTO.CreatePing()); 78 | m_LostConnection = false; 79 | return result; 80 | } 81 | 82 | public void RunStarted(string platform, List testsToRun) 83 | { 84 | SendDTO(ResultDTO.CreateRunStarted()); 85 | } 86 | 87 | public void RunFinished(List testResults) 88 | { 89 | SendDTO(ResultDTO.CreateRunFinished(testResults)); 90 | } 91 | 92 | public void TestStarted(TestResult test) 93 | { 94 | SendDTO(ResultDTO.CreateTestStarted(test)); 95 | } 96 | 97 | public void TestFinished(TestResult test) 98 | { 99 | SendDTO(ResultDTO.CreateTestFinished(test)); 100 | } 101 | 102 | public void AllScenesFinished() 103 | { 104 | SendDTO (ResultDTO.CreateAllScenesFinished ()); 105 | } 106 | 107 | public void TestRunInterrupted(List testsNotRun) 108 | { 109 | RunFinished(new List()); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/NetworkResultSender.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80b91644bbbc487479429368d4e8d596 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.SceneManagement; 5 | 6 | namespace UnityTest 7 | { 8 | [Serializable] 9 | public class ResultDTO 10 | { 11 | public MessageType messageType; 12 | public int levelCount; 13 | public int loadedLevel; 14 | public string loadedLevelName; 15 | public string testName; 16 | public float testTimeout; 17 | public ITestResult testResult; 18 | 19 | private ResultDTO(MessageType messageType) 20 | { 21 | this.messageType = messageType; 22 | levelCount = UnityEngine.SceneManagement.SceneManager.sceneCount; 23 | loadedLevel = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex; 24 | loadedLevelName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; 25 | } 26 | 27 | public enum MessageType : byte 28 | { 29 | Ping, 30 | RunStarted, 31 | RunFinished, 32 | TestStarted, 33 | TestFinished, 34 | RunInterrupted, 35 | AllScenesFinished 36 | } 37 | 38 | public static ResultDTO CreatePing() 39 | { 40 | var dto = new ResultDTO(MessageType.Ping); 41 | return dto; 42 | } 43 | 44 | public static ResultDTO CreateRunStarted() 45 | { 46 | var dto = new ResultDTO(MessageType.RunStarted); 47 | return dto; 48 | } 49 | 50 | public static ResultDTO CreateRunFinished(List testResults) 51 | { 52 | var dto = new ResultDTO(MessageType.RunFinished); 53 | return dto; 54 | } 55 | 56 | public static ResultDTO CreateTestStarted(TestResult test) 57 | { 58 | var dto = new ResultDTO(MessageType.TestStarted); 59 | dto.testName = test.FullName; 60 | dto.testTimeout = test.TestComponent.timeout; 61 | return dto; 62 | } 63 | 64 | public static ResultDTO CreateTestFinished(TestResult test) 65 | { 66 | var dto = new ResultDTO(MessageType.TestFinished); 67 | dto.testName = test.FullName; 68 | dto.testResult = GetSerializableTestResult(test); 69 | return dto; 70 | } 71 | 72 | public static ResultDTO CreateAllScenesFinished() 73 | { 74 | var dto = new ResultDTO(MessageType.AllScenesFinished); 75 | return dto; 76 | } 77 | 78 | private static ITestResult GetSerializableTestResult(TestResult test) 79 | { 80 | var str = new SerializableTestResult(); 81 | 82 | str.resultState = test.ResultState; 83 | str.message = test.messages; 84 | str.executed = test.Executed; 85 | str.name = test.Name; 86 | str.fullName = test.FullName; 87 | str.id = test.id; 88 | str.isSuccess = test.IsSuccess; 89 | str.duration = test.duration; 90 | str.stackTrace = test.stacktrace; 91 | str.isIgnored = test.IsIgnored; 92 | 93 | return str; 94 | } 95 | } 96 | 97 | #region SerializableTestResult 98 | [Serializable] 99 | internal class SerializableTestResult : ITestResult 100 | { 101 | public TestResultState resultState; 102 | public string message; 103 | public bool executed; 104 | public string name; 105 | public string fullName; 106 | public string id; 107 | public bool isSuccess; 108 | public double duration; 109 | public string stackTrace; 110 | public bool isIgnored; 111 | 112 | public TestResultState ResultState 113 | { 114 | get { return resultState; } 115 | } 116 | 117 | public string Message 118 | { 119 | get { return message; } 120 | } 121 | 122 | public string Logs 123 | { 124 | get { return null; } 125 | } 126 | 127 | public bool Executed 128 | { 129 | get { return executed; } 130 | } 131 | 132 | public string Name 133 | { 134 | get { return name; } 135 | } 136 | 137 | public string FullName 138 | { 139 | get { return fullName; } 140 | } 141 | 142 | public string Id 143 | { 144 | get { return id; } 145 | } 146 | 147 | public bool IsSuccess 148 | { 149 | get { return isSuccess; } 150 | } 151 | 152 | public double Duration 153 | { 154 | get { return duration; } 155 | } 156 | 157 | public string StackTrace 158 | { 159 | get { return stackTrace; } 160 | } 161 | 162 | public bool IsIgnored 163 | { 164 | get { return isIgnored; } 165 | } 166 | } 167 | #endregion 168 | } 169 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37c772b6d1ba4274aa96c83710cb27e8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1dba0b27b0864740a8720e920aa88c0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | [Serializable] 8 | public class TestResult : ITestResult, IComparable 9 | { 10 | private readonly GameObject m_Go; 11 | private string m_Name; 12 | public ResultType resultType = ResultType.NotRun; 13 | public double duration; 14 | public string messages; 15 | public string stacktrace; 16 | public string id; 17 | public bool dynamicTest; 18 | 19 | public TestComponent TestComponent; 20 | 21 | public GameObject GameObject 22 | { 23 | get { return m_Go; } 24 | } 25 | 26 | public TestResult(TestComponent testComponent) 27 | { 28 | TestComponent = testComponent; 29 | m_Go = testComponent.gameObject; 30 | id = testComponent.gameObject.GetInstanceID().ToString(); 31 | dynamicTest = testComponent.dynamic; 32 | 33 | if (m_Go != null) m_Name = m_Go.name; 34 | 35 | if (dynamicTest) 36 | id = testComponent.dynamicTypeName; 37 | } 38 | 39 | public void Update(TestResult oldResult) 40 | { 41 | resultType = oldResult.resultType; 42 | duration = oldResult.duration; 43 | messages = oldResult.messages; 44 | stacktrace = oldResult.stacktrace; 45 | } 46 | 47 | public enum ResultType 48 | { 49 | Success, 50 | Failed, 51 | Timeout, 52 | NotRun, 53 | FailedException, 54 | Ignored 55 | } 56 | 57 | public void Reset() 58 | { 59 | resultType = ResultType.NotRun; 60 | duration = 0f; 61 | messages = ""; 62 | stacktrace = ""; 63 | } 64 | 65 | #region ITestResult implementation 66 | public TestResultState ResultState { 67 | get 68 | { 69 | switch (resultType) 70 | { 71 | case ResultType.Success: return TestResultState.Success; 72 | case ResultType.Failed: return TestResultState.Failure; 73 | case ResultType.FailedException: return TestResultState.Error; 74 | case ResultType.Ignored: return TestResultState.Ignored; 75 | case ResultType.NotRun: return TestResultState.Skipped; 76 | case ResultType.Timeout: return TestResultState.Cancelled; 77 | default: throw new Exception(); 78 | } 79 | } 80 | } 81 | public string Message { get { return messages; } } 82 | public string Logs { get { return null; } } 83 | public bool Executed { get { return resultType != ResultType.NotRun; } } 84 | public string Name { get { if (m_Go != null) m_Name = m_Go.name; return m_Name; } } 85 | public string Id { get { return id; } } 86 | public bool IsSuccess { get { return resultType == ResultType.Success; } } 87 | public bool IsTimeout { get { return resultType == ResultType.Timeout; } } 88 | public double Duration { get { return duration; } } 89 | public string StackTrace { get { return stacktrace; } } 90 | public string FullName { 91 | get 92 | { 93 | var fullName = Name; 94 | if (m_Go != null) 95 | { 96 | var tempGo = m_Go.transform.parent; 97 | while (tempGo != null) 98 | { 99 | fullName = tempGo.name + "." + fullName; 100 | tempGo = tempGo.transform.parent; 101 | } 102 | } 103 | return fullName; 104 | } 105 | } 106 | 107 | public bool IsIgnored { get { return resultType == ResultType.Ignored; } } 108 | public bool IsFailure 109 | { 110 | get 111 | { 112 | return resultType == ResultType.Failed 113 | || resultType == ResultType.FailedException 114 | || resultType == ResultType.Timeout; 115 | } 116 | } 117 | #endregion 118 | 119 | #region IComparable, GetHashCode and Equals implementation 120 | public override int GetHashCode() 121 | { 122 | return id.GetHashCode(); 123 | } 124 | 125 | public int CompareTo(TestResult other) 126 | { 127 | var result = Name.CompareTo(other.Name); 128 | if (result == 0) 129 | result = m_Go.GetInstanceID().CompareTo(other.m_Go.GetInstanceID()); 130 | return result; 131 | } 132 | 133 | public override bool Equals(object obj) 134 | { 135 | if (obj is TestResult) 136 | return GetHashCode() == obj.GetHashCode(); 137 | return base.Equals(obj); 138 | } 139 | #endregion 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68740a702763aaa4594e8319a05ae0d3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestResultRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | public class TestResultRenderer 7 | { 8 | private static class Styles 9 | { 10 | public static readonly GUIStyle SucceedLabelStyle; 11 | public static readonly GUIStyle FailedLabelStyle; 12 | public static readonly GUIStyle FailedMessagesStyle; 13 | 14 | static Styles() 15 | { 16 | SucceedLabelStyle = new GUIStyle("label"); 17 | SucceedLabelStyle.normal.textColor = Color.green; 18 | SucceedLabelStyle.fontSize = 48; 19 | 20 | FailedLabelStyle = new GUIStyle("label"); 21 | FailedLabelStyle.normal.textColor = Color.red; 22 | FailedLabelStyle.fontSize = 32; 23 | 24 | FailedMessagesStyle = new GUIStyle("label"); 25 | FailedMessagesStyle.wordWrap = false; 26 | FailedMessagesStyle.richText = true; 27 | } 28 | } 29 | private readonly Dictionary> m_TestCollection = new Dictionary>(); 30 | 31 | private bool m_ShowResults; 32 | Vector2 m_ScrollPosition; 33 | private int m_FailureCount; 34 | 35 | public void ShowResults() 36 | { 37 | m_ShowResults = true; 38 | Cursor.visible = true; 39 | } 40 | 41 | public void AddResults(string sceneName, ITestResult result) 42 | { 43 | if (!m_TestCollection.ContainsKey(sceneName)) 44 | m_TestCollection.Add(sceneName, new List()); 45 | m_TestCollection[sceneName].Add(result); 46 | if (result.Executed && !result.IsSuccess) 47 | m_FailureCount++; 48 | } 49 | 50 | public void Draw() 51 | { 52 | if (!m_ShowResults) return; 53 | if (m_TestCollection.Count == 0) 54 | { 55 | GUILayout.Label("All test succeeded", Styles.SucceedLabelStyle, GUILayout.Width(600)); 56 | } 57 | else 58 | { 59 | int count = m_TestCollection.Sum (testGroup => testGroup.Value.Count); 60 | GUILayout.Label(count + " tests failed!", Styles.FailedLabelStyle); 61 | 62 | m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition, GUILayout.ExpandWidth(true)); 63 | var text = ""; 64 | foreach (var testGroup in m_TestCollection) 65 | { 66 | text += "" + testGroup.Key + "\n"; 67 | text += string.Join("\n", testGroup.Value 68 | .Where(result => !result.IsSuccess) 69 | .Select(result => result.Name + " " + result.ResultState + "\n" + result.Message) 70 | .ToArray()); 71 | } 72 | GUILayout.TextArea(text, Styles.FailedMessagesStyle); 73 | GUILayout.EndScrollView(); 74 | } 75 | if (GUILayout.Button("Close")) 76 | Application.Quit(); 77 | } 78 | 79 | public int FailureCount() 80 | { 81 | return m_FailureCount; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestResultRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ae9d3b4b57cae343b7ff360f9deb628 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c3afc1c624179749bcdecf7b0224902 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerCallbackList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest.IntegrationTestRunner 6 | { 7 | public class TestRunnerCallbackList : ITestRunnerCallback 8 | { 9 | private readonly List m_CallbackList = new List(); 10 | 11 | public void Add(ITestRunnerCallback callback) 12 | { 13 | m_CallbackList.Add(callback); 14 | } 15 | 16 | public void Remove(ITestRunnerCallback callback) 17 | { 18 | m_CallbackList.Remove(callback); 19 | } 20 | 21 | public void RunStarted(string platform, List testsToRun) 22 | { 23 | foreach (var unitTestRunnerCallback in m_CallbackList) 24 | { 25 | unitTestRunnerCallback.RunStarted(platform, testsToRun); 26 | } 27 | } 28 | 29 | public void RunFinished(List testResults) 30 | { 31 | foreach (var unitTestRunnerCallback in m_CallbackList) 32 | { 33 | unitTestRunnerCallback.RunFinished(testResults); 34 | } 35 | } 36 | 37 | public void AllScenesFinished() 38 | { 39 | foreach (var unitTestRunnerCallback in m_CallbackList) 40 | { 41 | unitTestRunnerCallback.AllScenesFinished(); 42 | } 43 | } 44 | 45 | public void TestStarted(TestResult test) 46 | { 47 | foreach (var unitTestRunnerCallback in m_CallbackList) 48 | { 49 | unitTestRunnerCallback.TestStarted(test); 50 | } 51 | } 52 | 53 | public void TestFinished(TestResult test) 54 | { 55 | foreach (var unitTestRunnerCallback in m_CallbackList) 56 | { 57 | unitTestRunnerCallback.TestFinished(test); 58 | } 59 | } 60 | 61 | public void TestRunInterrupted(List testsNotRun) 62 | { 63 | foreach (var unitTestRunnerCallback in m_CallbackList) 64 | { 65 | unitTestRunnerCallback.TestRunInterrupted(testsNotRun); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerCallbackList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7729da83f7c08d244b5788c870a93780 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerConfigurator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05aae864572254e478ed2f0489cdd335 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d1ccbd729921544dbd71f7e80c405b6 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CallTesting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class CallTesting : MonoBehaviour 8 | { 9 | public enum Functions 10 | { 11 | CallAfterSeconds, 12 | CallAfterFrames, 13 | Start, 14 | Update, 15 | FixedUpdate, 16 | LateUpdate, 17 | OnDestroy, 18 | OnEnable, 19 | OnDisable, 20 | OnControllerColliderHit, 21 | OnParticleCollision, 22 | OnJointBreak, 23 | OnBecameInvisible, 24 | OnBecameVisible, 25 | OnTriggerEnter, 26 | OnTriggerExit, 27 | OnTriggerStay, 28 | OnCollisionEnter, 29 | OnCollisionExit, 30 | OnCollisionStay, 31 | OnTriggerEnter2D, 32 | OnTriggerExit2D, 33 | OnTriggerStay2D, 34 | OnCollisionEnter2D, 35 | OnCollisionExit2D, 36 | OnCollisionStay2D, 37 | } 38 | 39 | public enum Method 40 | { 41 | Pass, 42 | Fail 43 | } 44 | 45 | public int afterFrames = 0; 46 | public float afterSeconds = 0.0f; 47 | public Functions callOnMethod = Functions.Start; 48 | 49 | public Method methodToCall; 50 | private int m_StartFrame; 51 | private float m_StartTime; 52 | 53 | private void TryToCallTesting(Functions invokingMethod) 54 | { 55 | if (invokingMethod == callOnMethod) 56 | { 57 | if (methodToCall == Method.Pass) 58 | IntegrationTest.Pass(gameObject); 59 | else 60 | IntegrationTest.Fail(gameObject); 61 | 62 | afterFrames = 0; 63 | afterSeconds = 0.0f; 64 | m_StartTime = float.PositiveInfinity; 65 | m_StartFrame = int.MinValue; 66 | } 67 | } 68 | 69 | public void Start() 70 | { 71 | m_StartTime = Time.time; 72 | m_StartFrame = afterFrames; 73 | TryToCallTesting(Functions.Start); 74 | } 75 | 76 | public void Update() 77 | { 78 | TryToCallTesting(Functions.Update); 79 | CallAfterSeconds(); 80 | CallAfterFrames(); 81 | } 82 | 83 | private void CallAfterFrames() 84 | { 85 | if (afterFrames > 0 && (m_StartFrame + afterFrames) <= Time.frameCount) 86 | TryToCallTesting(Functions.CallAfterFrames); 87 | } 88 | 89 | private void CallAfterSeconds() 90 | { 91 | if ((m_StartTime + afterSeconds) <= Time.time) 92 | TryToCallTesting(Functions.CallAfterSeconds); 93 | } 94 | 95 | public void OnDisable() 96 | { 97 | TryToCallTesting(Functions.OnDisable); 98 | } 99 | 100 | public void OnEnable() 101 | { 102 | TryToCallTesting(Functions.OnEnable); 103 | } 104 | 105 | public void OnDestroy() 106 | { 107 | TryToCallTesting(Functions.OnDestroy); 108 | } 109 | 110 | public void FixedUpdate() 111 | { 112 | TryToCallTesting(Functions.FixedUpdate); 113 | } 114 | 115 | public void LateUpdate() 116 | { 117 | TryToCallTesting(Functions.LateUpdate); 118 | } 119 | 120 | public void OnControllerColliderHit() 121 | { 122 | TryToCallTesting(Functions.OnControllerColliderHit); 123 | } 124 | 125 | public void OnParticleCollision() 126 | { 127 | TryToCallTesting(Functions.OnParticleCollision); 128 | } 129 | 130 | public void OnJointBreak() 131 | { 132 | TryToCallTesting(Functions.OnJointBreak); 133 | } 134 | 135 | public void OnBecameInvisible() 136 | { 137 | TryToCallTesting(Functions.OnBecameInvisible); 138 | } 139 | 140 | public void OnBecameVisible() 141 | { 142 | TryToCallTesting(Functions.OnBecameVisible); 143 | } 144 | 145 | public void OnTriggerEnter() 146 | { 147 | TryToCallTesting(Functions.OnTriggerEnter); 148 | } 149 | 150 | public void OnTriggerExit() 151 | { 152 | TryToCallTesting(Functions.OnTriggerExit); 153 | } 154 | 155 | public void OnTriggerStay() 156 | { 157 | TryToCallTesting(Functions.OnTriggerStay); 158 | } 159 | public void OnCollisionEnter() 160 | { 161 | TryToCallTesting(Functions.OnCollisionEnter); 162 | } 163 | 164 | public void OnCollisionExit() 165 | { 166 | TryToCallTesting(Functions.OnCollisionExit); 167 | } 168 | 169 | public void OnCollisionStay() 170 | { 171 | TryToCallTesting(Functions.OnCollisionStay); 172 | } 173 | 174 | public void OnTriggerEnter2D() 175 | { 176 | TryToCallTesting(Functions.OnTriggerEnter2D); 177 | } 178 | 179 | public void OnTriggerExit2D() 180 | { 181 | TryToCallTesting(Functions.OnTriggerExit2D); 182 | } 183 | 184 | public void OnTriggerStay2D() 185 | { 186 | TryToCallTesting(Functions.OnTriggerStay2D); 187 | } 188 | 189 | public void OnCollisionEnter2D() 190 | { 191 | TryToCallTesting(Functions.OnCollisionEnter2D); 192 | } 193 | 194 | public void OnCollisionExit2D() 195 | { 196 | TryToCallTesting(Functions.OnCollisionExit2D); 197 | } 198 | 199 | public void OnCollisionStay2D() 200 | { 201 | TryToCallTesting(Functions.OnCollisionStay2D); 202 | } 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CallTesting.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d545b1288d5fc74d8e6c961fb67ab18 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5fc3c3488db1e74689f1fc67c33944a 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionSuccess.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionSuccess.prefab -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionSuccess.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1228dff762eab21488cfefd42792c37b 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 616ddafe39e02da4081e56f7f763af3c 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerSuccess.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerSuccess.prefab -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerSuccess.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d940e636fd44be84e9b7e8da46f700ef 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d55f43641ba3c14eaa1156abc0edabd 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials/green.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials/green.mat -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials/green.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43da3275cd08d41429f56675d70c58df 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials/red.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials/red.mat -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/Materials/red.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03f3b4747259a364b800508ac27e1c17 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/green.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/green.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 928be703400f4eb48af2f94d55bf3f74 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 1 8 | linearTexture: 0 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: -1 28 | mipBias: -1 29 | wrapMode: -1 30 | nPOTScale: 1 31 | lightmap: 0 32 | compressionQuality: 50 33 | spriteMode: 0 34 | autoDetectMinSpriteSize: 4 35 | gridPadding: 0 36 | gridOffsetX: 0 37 | gridOffsetY: 0 38 | gridSizeX: 64 39 | gridSizeY: 64 40 | spriteExtrude: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteAtlasHint: 0 44 | spritePixelsToUnits: 100 45 | generateSpritePolygon: 0 46 | spritePolygonAlphaCutoff: 254 47 | spritePolygonDetail: .5 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | spriteFrames: [] 53 | userData: 54 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/red.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/red.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 591632297e74ba34fa4c65d1265d370a 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 1 8 | linearTexture: 0 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: -1 28 | mipBias: -1 29 | wrapMode: -1 30 | nPOTScale: 1 31 | lightmap: 0 32 | compressionQuality: 50 33 | spriteMode: 0 34 | autoDetectMinSpriteSize: 4 35 | gridPadding: 0 36 | gridOffsetX: 0 37 | gridOffsetY: 0 38 | gridSizeX: 64 39 | gridSizeY: 64 40 | spriteExtrude: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteAtlasHint: 0 44 | spritePixelsToUnits: 100 45 | generateSpritePolygon: 0 46 | spritePolygonAlphaCutoff: 254 47 | spritePolygonDetail: .5 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | spriteFrames: [] 53 | userData: 54 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/LICENSE.txt -------------------------------------------------------------------------------- /Assets/UnityTestTools/LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d5b4501bf773f349ad95ec34491dc61 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a87f1db904f1e948a2385ab9961e3aa 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59b47eb3fc62eb44cb73a329a1e6b6cb 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NSubstitute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92b38897656771f409e9235955975754 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NSubstitute/NSubstitute.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/Assets/UnityTestTools/UnitTesting/Editor/NSubstitute/NSubstitute.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NSubstitute/NSubstitute.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c5e1afc6e0d68849ae6639aff58cfc7 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/changelog.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29b770d9107643740b69cb98b00430aa 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.4.1f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacksondunstan/mv-c_example/ab0f985188b725a6bf6a6d33fabaad207c7d41bd/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MV-C Example Unity3D Project 2 | --- 3 | 4 | MV-C is an MVC-like pattern for Unity3D. It has two parts. First is a model-view that handles input, output, and data representation. Second is a controller that uses the model-view to perform logic. 5 | 6 | This example project is explained in depth in the [introductory article](http://jacksondunstan.com/articles/3611) by Jackson Dunstan. It consists of a single scene with a single "enemy" that can be damaged and eventually killed by mouse clicks. Its sole purpose is to introduce the MV-C design pattern. --------------------------------------------------------------------------------