public void TestClassWithParameterizedCacheAttributeComplexCacheAttributePassesParametersEnum() { // Arrange dynamic cache = WeaverHelper.CreateInstance <DictionaryCache>(Assembly); dynamic testClass1 = WeaverHelper.CreateInstance <TestClassWithParameterizedCacheAttribute>(Assembly, cache); // Act testClass1.ComplexCacheParameterMethodEnum(); // Assert Assert.IsTrue(cache.NumStoreParameterCalls == 1); Assert.IsTrue(cache.ParametersPassedToLastStoreCall.Count == 1); dynamic type = WeaverHelper.CreateType <EnumType>(Assembly); Assert.IsInstanceOfType(type, cache.ParametersPassedToLastStoreCall["ParameterEnum"]); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterEnum"] == (Enum.GetValues(type)[0] | Enum.GetValues(type)[2])); }
public void TestClassWithParameterizedCacheAttributeComplexCacheAttributePassesParametersObjectArray() { // Arrange dynamic cache = WeaverHelper.CreateInstance <DictionaryCache>(Assembly); dynamic testClass1 = WeaverHelper.CreateInstance <TestClassWithParameterizedCacheAttribute>(Assembly, cache); // Act testClass1.ComplexCacheParameterMethodObjectArray(); // Assert dynamic type = WeaverHelper.CreateType <EnumType>(Assembly); Assert.IsTrue(cache.NumStoreParameterCalls == 1); Assert.IsTrue(cache.ParametersPassedToLastStoreCall.Count == 1); Assert.IsInstanceOfType(typeof(object[]), cache.ParametersPassedToLastStoreCall["ParameterObjectArray"]); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"].Length == 5); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"][0] == 1); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"][1] == "2"); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"][2] == Enum.GetValues(type)[2]); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"][3] == typeof(List <int>)); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"][4][0] == 1); Assert.IsTrue(cache.ParametersPassedToLastStoreCall["ParameterObjectArray"][4][1] == "2"); }