public void ResourceNaming_ArgumentChecks() { #pragma warning disable IDE0004 // Remove Unnecessary Cast. (Makes the intent clear.) Assert.ThrowsException <ArgumentNullException>(() => ResourceNaming.GetThisReferenceExpression((object)null)); Assert.ThrowsException <ArgumentNullException>(() => ResourceNaming.GetThisReferenceExpression((Type)null)); Assert.ThrowsException <ArgumentNullException>(() => ResourceNaming.IsThisReferenceExpression(typeof(int), null)); #pragma warning restore IDE0004 }
protected ReliableReactiveServiceContext(IReactiveExpressionServices expressionServices, ReliableReactiveClient client) { if (expressionServices == null) { throw new ArgumentNullException(nameof(expressionServices)); } Client = client ?? throw new ArgumentNullException(nameof(client)); var thisParameter = ResourceNaming.GetThisReferenceExpression(this); expressionServices.RegisterObject(this, thisParameter); }
public void ResourceNaming_Simple() { var x = new object(); var p = ResourceNaming.GetThisReferenceExpression(x) as ParameterExpression; Assert.IsNotNull(p); Assert.AreEqual(typeof(object), p.Type); Assert.AreEqual(Constants.CurrentInstanceUri, p.Name); var p2 = ResourceNaming.GetThisReferenceExpression(typeof(string)) as ParameterExpression; Assert.AreEqual(typeof(string), p2.Type); Assert.AreEqual(Constants.CurrentInstanceUri, p.Name); var p3 = Expression.Parameter(typeof(object), Constants.IdentityFunctionUri); Assert.IsFalse(ResourceNaming.IsThisReferenceExpression(typeof(object), p3)); Assert.IsFalse(ResourceNaming.IsThisReferenceExpression(typeof(string), p3)); var p4 = Expression.Parameter(typeof(string), Constants.CurrentInstanceUri); Assert.IsFalse(ResourceNaming.IsThisReferenceExpression(typeof(object), p4)); Assert.IsTrue(ResourceNaming.IsThisReferenceExpression(typeof(string), p4)); }