If you have a variable that requires a context, simply Mock it like this!
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
[TestClass]
class SomeUnitTests
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |
Shader "Unlit/FlashingMaker" | |
{ | |
Properties | |
{ | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_Color ("Color (RGBA)", Color) = (1, 1, 1, 1) // add _Color property | |
} |
RegexDictionary = new Dictionary<string, Regex> | |
{ | |
{"tests", new Regex("@tests\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"fixed", new Regex("@fixed\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"review", new Regex("@review\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"tested", new Regex("@tested\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"submitassistant", new Regex("@submitassistant\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"releasenotes", new Regex("@releasenotes\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"change", new Regex("@change\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, | |
{"waswarned", new Regex("@waswarned\\((.*?)\\)(.*?)@.*?\\(.*?\\)", option)}, |
Note that this is not a regular use case. Reflexion should be avoided, and your code structure should always be adapted for tests. Perhaps if you don't have the choice, private properties can still be tested!
let's see an example here with a selfish encapsulated class
public class SelfishClass
{
private string[] Goodies {get; set;}
isAscii("é") //false | |
function isAscii(str) { | |
for (var i = 0, strLen = str.length; i < strLen; ++i) { | |
if (str.charCodeAt(i) > 125) return false; | |
} | |
return true; | |
} |
I hereby claim:
To claim this, I am signing this object: