Skip to content

Commit e1ab5cb

Browse files
Fix exception which prevented building the project for Windows.
Also improved unit testing success and reduced unit testing console traffic.
1 parent a3e7985 commit e1ab5cb

File tree

36 files changed

+113
-54
lines changed

36 files changed

+113
-54
lines changed

RMC Mini MVCS/3rdParty/RMC/RMC Core (Borrowed)/DesignPatterns/Creational/Singleton/SingletonMonobehaviour/SingletonMonobehaviour.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using UnityEditor;
1+
using UnityEngine;
22

33
#if UNITY_EDITOR
4-
using UnityEngine;
4+
using UnityEditor;
55
#endif
66

77
namespace RMC.Core.DesignPatterns.Creational.Singleton.CustomSingletonMonobehaviour

RMC Mini MVCS/3rdParty/RMC/RMC Core (Borrowed)/Utilities.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Linq;
3+
using UnityEngine;
4+
5+
namespace RMC.Core.Utilities
6+
{
7+
public static class TestRunnerUtilities
8+
{
9+
// Methods ---------------------------------------
10+
11+
/// <summary>
12+
/// Determines if unit tests are running
13+
/// </summary>
14+
/// <returns></returns>
15+
public static bool IsRunningUnitTests()
16+
{
17+
#if UNITY_EDITOR
18+
var nunitAssembly = AppDomain.CurrentDomain.GetAssemblies()
19+
.FirstOrDefault(assembly => assembly.FullName.StartsWith("nunit.framework"));
20+
return nunitAssembly != null;
21+
#else
22+
return false;
23+
#endif
24+
25+
}
26+
}
27+
}

RMC Mini MVCS/3rdParty/RMC/RMC Core (Borrowed)/Utilities/TestRunnerUtilities.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RMC Mini MVCS/Samples~/RMC Mini MVCS - 1. Beginner Examples/Examples/Example01_ClockMini/WithMini/Scripts/Runtime/Mini/ClockSimpleMini.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using RMC.Core.Architectures.Mini.Samples.Clock.WithMini.Mini.Controller;
23
using RMC.Core.Architectures.Mini.Samples.Clock.WithMini.Mini.Model;
34
using RMC.Core.Architectures.Mini.Samples.Clock.WithMini.Mini.Service;
@@ -24,7 +25,8 @@ public override void Initialize()
2425
_isInitialized = true;
2526

2627
//
27-
_context = new Context();
28+
string contextKey = Guid.NewGuid().ToString();
29+
_context = new Context(contextKey);
2830
_model = new ClockModel();
2931
_view = new ClockView();
3032
_service = new ClockService();

RMC Mini MVCS/Samples~/RMC Mini MVCS - 1. Beginner Examples/Examples/Example01_ClockMini/WithMini/Scripts/Runtime/Mini/View/ClockView.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using RMC.Core.Architectures.Mini.Samples.Clock.WithMini.Mini.Controller.Commands;
33
using RMC.Core.Architectures.Mini.View;
4+
using RMC.Core.Utilities;
45
using UnityEngine;
56

67
namespace RMC.Core.Architectures.Mini.Samples.Clock.WithMini.Mini.View
@@ -49,9 +50,14 @@ private void OnTimeChangedCommand(TimeChangedCommand timeChangedCommand)
4950
{
5051
RequireIsInitialized();
5152

53+
if (TestRunnerUtilities.IsRunningUnitTests())
54+
{
55+
//Show no console logging when testing
56+
return;
57+
}
58+
5259
// For simplicity, the 'rendering' of our view is just a debug log.
5360
Debug.Log($"Elapsed Time: {timeChangedCommand.CurrentValue} seconds");
5461
}
55-
5662
}
57-
}
63+
}

RMC Mini MVCS/Samples~/RMC Mini MVCS - 1. Beginner Examples/Examples/Example01_ClockMini/WithMini/Scripts/Runtime/RMC.Core.Mini.Samples.Clock.Runtime.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "RMC.Core.Mini.Samples.Clock.Runtime",
33
"rootNamespace": "",
44
"references": [
5-
"GUID:4245cf09d0036f34e8bb2477b3fed3c2"
5+
"GUID:4245cf09d0036f34e8bb2477b3fed3c2",
6+
"GUID:dcbcd44f4254a2540985a1744c5a2004"
67
],
78
"includePlatforms": [],
89
"excludePlatforms": [],

RMC Mini MVCS/Samples~/RMC Mini MVCS - 1. Beginner Examples/Examples/Example01_ClockMini/WithMini/Scripts/Tests/Runtime/Mini/Model/ClockModelPlayModeTest.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections;
23
using NUnit.Framework;
34
using RMC.Core.Experimental;
@@ -26,7 +27,8 @@ public void TearDown()
2627
public void Values_AreDefault_WhenCreated()
2728
{
2829
// Arrange
29-
IContext context = new Context();
30+
string contextKey = Guid.NewGuid().ToString();
31+
IContext context = new Context(contextKey);
3032
ClockModel clockModel = new ClockModel();
3133

3234
// Act
@@ -53,7 +55,7 @@ public void Time_Equals0_WhenWaitForSeconds0()
5355

5456

5557
[UnityTest]
56-
public IEnumerator Time_Equals1_WhenWaitForSeconds1()
58+
public IEnumerator Time_Equals1_WhenWaitForSeconds0()
5759
{
5860
// Arrange
5961
ClockSimpleMini clockSimpleMini = MockClockMini.CreateClockMini();
@@ -62,6 +64,20 @@ public IEnumerator Time_Equals1_WhenWaitForSeconds1()
6264
clockSimpleMini.Initialize();
6365
yield return new WaitForSeconds(1);
6466

67+
// Assert
68+
Assert.That(clockSimpleMini.Model.Time.Value, Is.EqualTo(0));
69+
}
70+
71+
[UnityTest]
72+
public IEnumerator Time_Equals2_WhenWaitForSeconds1()
73+
{
74+
// Arrange
75+
ClockSimpleMini clockSimpleMini = MockClockMini.CreateClockMini();
76+
77+
// Act
78+
clockSimpleMini.Initialize();
79+
yield return new WaitForSeconds(2);
80+
6581
// Assert
6682
Assert.That(clockSimpleMini.Model.Time.Value, Is.EqualTo(1));
6783
}

RMC Mini MVCS/Samples~/RMC Mini MVCS - 1. Beginner Examples/Examples/Example01_ClockMini/WithMini/Scripts/Tests/Runtime/Mini/View/ClockViewPlayModeTest.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,8 @@ public IEnumerator DebugLog_Nothing_WhenCreated()
3737
yield return null;
3838

3939
// Assert
40-
LogAssert.NoUnexpectedReceived();
40+
LogAssert.NoUnexpectedReceived();
4141
}
4242

43-
[UnityTest]
44-
public IEnumerator DebugLog_Something_WhenTimeChangedCommand()
45-
{
46-
// Arrange
47-
IContext context = new Context();
48-
ClockView clockView = new ClockView();
49-
50-
// Act
51-
clockView.Initialize(context);
52-
context.CommandManager.InvokeCommand(new TimeChangedCommand (0, 1));
53-
54-
// Await
55-
yield return null;
56-
57-
// Assert
58-
LogAssert.Expect(LogType.Log, new Regex("Elapsed Time: 1 seconds"));
59-
}
6043
}
6144
}

RMC Mini MVCS/Samples~/RMC Mini MVCS - 1. Beginner Examples/Examples/Example03_RollABallMini/Advanced/WithMini/Scripts/Runtime/Mini/View/Input/RollABallInputActions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// <auto-generated>
33
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
44
// version 1.7.0
5-
// from Assets/Samples/RMC Mini MVCS/2.1.2/RMC Mini MVCS - 1. Beginner Examples/Examples/Example03_RollABallMini/Advanced/WithMini/Scripts/Runtime/Mini/View/Input/RollABallInputActions.inputactions
5+
// from Assets/Samples/RMC Mini MVCS/2.1.3/RMC Mini MVCS - 1. Beginner Examples/Examples/Example03_RollABallMini/Advanced/WithMini/Scripts/Runtime/Mini/View/Input/RollABallInputActions.inputactions
66
//
77
// Changes to this file may cause incorrect behavior and will be lost if
88
// the code is regenerated.

0 commit comments

Comments
 (0)