11/*
22 JustMock Lite
3- Copyright © 2022 Progress Software Corporation
3+ Copyright © 2022,2025 Progress Software Corporation
44
55 Licensed under the Apache License, Version 2.0 (the "License");
66 you may not use this file except in compliance with the License.
@@ -24,15 +24,43 @@ namespace Telerik.JustMock
2424{
2525#if ! PORTABLE
2626 /// <summary>
27- /// Defines helper methods used for easily building expressions.
27+ /// Provides utility methods for simplifying the creation of expression trees used in mocking scenarios.
28+ /// This class offers a fluent API for building property access expressions that can be used to configure
29+ /// mock behavior for property getters and setters.
2830 /// </summary>
2931 public static class Expr
3032 {
3133 /// <summary>
32- /// Creates a <see cref="IPropertyExpressionBuilder<T>"/> from an expression.
33- /// Commonly used to easily build an expression for a property set.
34+ /// Creates an <see cref="IPropertyExpressionBuilder{T}"/> for the specified property access expression.
35+ /// This method analyzes a lambda expression that accesses a property and builds a property expression
36+ /// that can be used to configure mock behavior for property getters or setters.
3437 /// </summary>
35- /// <typeparam name="T">The type of the property.</typeparam>
38+ /// <typeparam name="T">The type of the property being accessed.</typeparam>
39+ /// <param name="expression">
40+ /// A lambda expression representing the property access, such as <c>() => obj.Property</c> for
41+ /// instance properties or <c>() => Class.StaticProperty</c> for static properties.
42+ /// </param>
43+ /// <returns>
44+ /// An <see cref="IPropertyExpressionBuilder{T}"/> that provides fluent methods for configuring
45+ /// property getter and setter behavior in mock objects.
46+ /// </returns>
47+ /// <exception cref="ArgumentException">
48+ /// Thrown when the provided expression is not a property access expression. The expression must
49+ /// be in the form of accessing a property, such as <c>obj.Property</c> or <c>Class.StaticProperty</c>.
50+ /// </exception>
51+ /// <exception cref="MockException">
52+ /// Thrown when attempting to mock a field instead of a property. JustMock only supports mocking
53+ /// properties, not fields.
54+ /// </exception>
55+ /// <example>
56+ /// <code>
57+ /// // Setting up a mock for a property getter
58+ /// Mock.Arrange(Expr.Property(() => mock.SomeProperty)).Returns(expectedValue);
59+ ///
60+ /// // Setting up a mock for a property setter
61+ /// Mock.Arrange(Expr.Property(() => mock.SomeProperty).Set(Arg.IsAny<string>).DoNothing();
62+ /// </code>
63+ /// </example>
3664 public static IPropertyExpressionBuilder < T > Property < T > ( Expression < Func < T > > expression )
3765 {
3866 return ProfilerInterceptor . GuardInternal ( ( ) =>
@@ -41,8 +69,7 @@ public static IPropertyExpressionBuilder<T> Property<T>(Expression<Func<T>> expr
4169
4270 if ( memberExpression . NodeType != ExpressionType . MemberAccess )
4371 {
44- throw new MockException ( "Wrong expression used, property access expression looks like obj.Property or Class.StaticProperty" ) ;
45-
72+ throw new ArgumentException ( "Wrong expression used, property access expression looks like obj.Property or Class.StaticProperty" , nameof ( expression ) ) ;
4673 }
4774
4875 MemberExpression outerMemberExpression = ( MemberExpression ) memberExpression ;
0 commit comments