-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
# Added - Added unit tests. # Changes - UniRx Integration runtime code moved to "Runtime" folder. - ReactiveModifiableProperty<T>/ReactiveModifierList<T>.ObserveChanged now observe ReactiveModifierList<T>.ObserveMove.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"version": "1.0", | ||
"components": [ | ||
"Microsoft.VisualStudio.Workload.ManagedGame" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "MackySoft.Modiferty.UniRx.Editor.Tests", | ||
"references": [ | ||
"GUID:e695879245fa2de4a81d0b0f517b15c3", | ||
"GUID:fede8c6c4e4bddd44b1db8410752c53f", | ||
"GUID:27619889b8ba8c24980f49ee34dbb44a", | ||
"GUID:0acc523941302664db1f4e527237feb3", | ||
"GUID:560b04d1a97f54a4e82edc0cbbb69285" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"nunit.framework.dll" | ||
], | ||
"autoReferenced": false, | ||
"defineConstraints": [ | ||
"MODIFERTY_UNIRX", | ||
"UNITY_INCLUDE_TESTS" | ||
], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using UniRx; | ||
using NUnit.Framework; | ||
|
||
namespace MackySoft.Modiferty.Tests { | ||
|
||
public class ReactiveModifiableIntTests { | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_BaseValue () { | ||
ReactiveModifiableInt property = new ReactiveModifiableInt(0); | ||
var subscription = property.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
property.BaseValue = 1; | ||
|
||
yield return subscription; | ||
|
||
Assert.AreEqual(property.BaseValue,1); | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using UniRx; | ||
using NUnit.Framework; | ||
|
||
namespace MackySoft.Modiferty.Tests { | ||
public class ReactiveModifierListTests { | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_Add () { | ||
var modifiers = new ReactiveModifierList<int>(); | ||
|
||
var subscription = modifiers.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
modifiers.Add(new AdditiveModifierInt(1)); | ||
|
||
yield return subscription; | ||
|
||
Assert.AreEqual(modifiers.Count,1); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_Remove () { | ||
var modifiers = new ReactiveModifierList<int>(); | ||
var modifier = new AdditiveModifierInt(1); | ||
modifiers.Add(modifier); | ||
|
||
var subscription = modifiers.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
modifiers.Remove(modifier); | ||
|
||
yield return subscription; | ||
|
||
Assert.AreEqual(modifiers.Count,0); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_Insert () { | ||
var modifiers = new ReactiveModifierList<int>(); | ||
modifiers.Add(new AdditiveModifierInt(1)); | ||
|
||
var subscription = modifiers.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
modifiers.Insert(0,new SubtractiveModifierInt(1)); | ||
|
||
yield return subscription; | ||
|
||
Assert.AreEqual(modifiers.Count,2); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_Move () { | ||
var modifiers = new ReactiveModifierList<int>(); | ||
modifiers.Add(new AdditiveModifierInt(1)); | ||
|
||
var targetModifier = new SubtractiveModifierInt(1); | ||
modifiers.Add(targetModifier); | ||
|
||
var subscription = modifiers.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
modifiers.Move(1,0); | ||
|
||
yield return subscription; | ||
|
||
Assert.AreEqual(modifiers.IndexOf(targetModifier),0); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_Replace () { | ||
var modifiers = new ReactiveModifierList<int>(); | ||
modifiers.Add(new AdditiveModifierInt(1)); | ||
|
||
var subscription = modifiers.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
var targetModifier = new SubtractiveModifierInt(1); | ||
modifiers[0] = targetModifier; | ||
|
||
yield return subscription; | ||
|
||
Assert.AreSame(modifiers[0],targetModifier); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator ObserveChanged_Clear () { | ||
var modifiers = new ReactiveModifierList<int>(); | ||
modifiers.Add(new AdditiveModifierInt(1)); | ||
|
||
var subscription = modifiers.ObserveChanged().First().ToYieldInstruction(); | ||
|
||
modifiers.Clear(); | ||
|
||
yield return subscription; | ||
|
||
Assert.AreEqual(modifiers.Count,0); | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "MackySoft.Modiferty.Editor.Tests", | ||
"references": [ | ||
"GUID:e695879245fa2de4a81d0b0f517b15c3", | ||
"GUID:40928bc94bf6c9d4ab69789b56aaff51", | ||
"GUID:27619889b8ba8c24980f49ee34dbb44a", | ||
"GUID:0acc523941302664db1f4e527237feb3" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"nunit.framework.dll" | ||
], | ||
"autoReferenced": false, | ||
"defineConstraints": [ | ||
"UNITY_INCLUDE_TESTS" | ||
], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using UnityEngine; | ||
using NUnit.Framework; | ||
|
||
namespace MackySoft.Modiferty.Tests { | ||
|
||
public class ModifiableIntTests { | ||
|
||
[Test] | ||
public void Solo ([Random(-99999,99999,10)] int baseValue) { | ||
var property = new ModifiableInt(baseValue); | ||
Assert.AreEqual(baseValue,property.Evaluate()); | ||
} | ||
|
||
[Test] | ||
public void Additive ( | ||
[Random(-99999,99999,10)] int baseValue, | ||
[Random(-99999,99999,10)] int add | ||
) { | ||
var property = new ModifiableInt(baseValue); | ||
property.AddModifier(new AdditiveModifierInt(add)); | ||
Assert.AreEqual(baseValue + add,property.Evaluate()); | ||
} | ||
|
||
[Test] | ||
public void Subtractive ( | ||
[Random(-99999,99999,10)] int baseValue, | ||
[Random(-99999,99999,10)] int subtract | ||
) { | ||
var property = new ModifiableInt(baseValue); | ||
property.AddModifier(new SubtractiveModifierInt(subtract)); | ||
Assert.AreEqual(baseValue - subtract,property.Evaluate()); | ||
} | ||
|
||
[Test] | ||
public void Multiply ( | ||
[Random(-99999,99999,10)] int baseValue, | ||
[Random(-10f,10f,10)] float multiplier, | ||
[Values] RoundingMethod method | ||
) { | ||
var property = new ModifiableInt(baseValue); | ||
property.AddModifier(new MultiplyModifierInt(multiplier,method)); | ||
Assert.AreEqual(RoundUtility.RoundToInt(baseValue * multiplier,method),property.Evaluate()); | ||
} | ||
|
||
[Test] | ||
public void Division ( | ||
[Random(-99999,99999,10)] int baseValue, | ||
[Random(-10f,10f,10)] float division, | ||
[Values] RoundingMethod method | ||
) { | ||
var property = new ModifiableInt(baseValue); | ||
property.AddModifier(new DivisionModifierInt(division,method)); | ||
Assert.AreEqual(RoundUtility.RoundToInt(baseValue / division,method),property.Evaluate()); | ||
} | ||
|
||
[Test] | ||
public void AddModifierAsDisposable () { | ||
var property = new ModifiableInt(0); | ||
|
||
IDisposable disposable = property.AddModifierAsDisposable(new AdditiveModifierInt(1)); | ||
int beforeDisposedValue = property.Evaluate(); | ||
|
||
disposable.Dispose(); | ||
|
||
int afterDisposedValue = property.Evaluate(); | ||
Assert.AreNotEqual(beforeDisposedValue,afterDisposedValue); | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.