public void ItShouldReturnAnExpressionGotTheImplementationType()
        {
            // Arrange
            string expected = $"implementationType: typeof({GetType()})";

            // Act
            IEnumerable <string> expressions =
                _initialValue.GetUpdateParameterExpressions(implementationType: GetType());

            // Assert
            expressions.ToList().Should().OnlyContain(e => e == expected);
        }
예제 #2
0
        /// <inheritdoc />
        public override string GetInstanceExpression(IGenerationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            string factoryFieldName = GetComposeMethodName(context);

            IEnumerable <string> expressions = context.GetUpdateParameterExpressions(implementationType: Type);
            string updateParameters          = string.Join(", ", expressions);

            string instanceExpression =
                RequiresConstructionContext()
                    ? factoryFieldName + $"(context.Update({updateParameters}))"
                    : factoryFieldName + "()";

            return(instanceExpression);
        }