public void PArrayDefaultBehavior_can_apply_default_behavior_to_return_default_value_against_one_type() { // Arrange PArray. ExcludeGeneric(). IncludeExistsOfTTArrayPredicateOfT <int>(). DefaultBehavior = IndirectionBehaviors.DefaultValue; // Act var get_now = PDateTime.NowGet().Body; var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body; // Assert Assert.IsNull(get_now); Assert.IsFalse(exists(null, null)); }
public void PArrayDefaultBehavior_can_apply_default_behavior_to_throw_NotImplementedException_against_one_type() { // Arrange PArray. ExcludeGeneric(). IncludeExistsOfTTArrayPredicateOfT <int>(). DefaultBehavior = IndirectionBehaviors.NotImplemented; // Act var get_now = PDateTime.NowGet().Body; var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body; // Assert Assert.IsNull(get_now); Assert.Throws <NotImplementedException>(() => exists(null, null)); }
public void IndirectionsContextDefaultBehavior_can_apply_default_behavior_to_throw_FallthroughException_globally() { // Arrange IndirectionsContext. ExcludeGeneric(). Include(PList <int> .AddT()). Include(PArray.ExistsOfTTArrayPredicateOfT <int>()). DefaultBehavior = IndirectionBehaviors.Fallthrough; // Act var get_now = PDateTime.NowGet().Body; var add = PList <int> .AddT().Body; var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body; // Assert Assert.Throws <FallthroughException>(() => get_now()); Assert.Throws <FallthroughException>(() => add(null, 0)); Assert.Throws <FallthroughException>(() => exists(null, null)); }
public void IndirectionsContextDefaultBehavior_can_apply_default_behavior_to_return_default_value_globally() { // Arrange IndirectionsContext. ExcludeGeneric(). Include(PList <int> .AddT()). Include(PArray.ExistsOfTTArrayPredicateOfT <int>()). DefaultBehavior = IndirectionBehaviors.DefaultValue; // Act var get_now = PDateTime.NowGet().Body; var add = PList <int> .AddT().Body; var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body; // Assert Assert.AreEqual(default(DateTime), get_now()); Assert.DoesNotThrow(() => add(null, 10)); Assert.IsFalse(exists(null, null)); }
public void IndirectionHolder_can_transport_delegates_to_different_AppDomain() { // Arrange PDateTime.NowGet().Body = () => new DateTime(2014, 1, 1); PList <int> .AddT().Body = (@this, item) => { @this.Add(item); @this.Add(item); }; PArray.ExistsOfTTArrayPredicateOfT <int>().Body = (array, match) => match(array[0]); AppDomain.CurrentDomain.RunAtIsolatedDomain(() => { // Act var get_now = PDateTime.NowGet().Body; var add = PList <int> .AddT().Body; var addResults = new List <int>(); add(addResults, 10); var exists = PArray.ExistsOfTTArrayPredicateOfT <int>().Body; // Assert Assert.AreEqual(new DateTime(2014, 1, 1), get_now()); CollectionAssert.AreEqual(new int[] { 10, 10 }, addResults); Assert.IsFalse(exists(new int[] { 10, 42 }, _ => _ == 42)); }); }