コード例 #1
0
        public static void LambdaAccessor_executes_null_lambda()
        {
            // Arrange
            var accessor = new LambdaAccessor <string>(() => null);

            // Act
            var actual = accessor.CorrelationId;

            // Assert
            Assert.Null(actual);
        }
コード例 #2
0
        public static void LambdaAccessor_returns_string_input(string expected)
        {
            // Arrange
            var accessor = new LambdaAccessor <string>(() => expected);

            // Act
            var actual = accessor.CorrelationId;

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #3
0
        public static void LambdaAccessor_executes_dynamic_lambda()
        {
            // Arrange
            var accessor = new LambdaAccessor <string>(MyLambda);

            // Act
            var actual = accessor.CorrelationId;

            // Assert
            Assert.True(Guid.TryParse(actual, out _));

            string MyLambda()
            {
                return(Guid.NewGuid().ToString("D", CultureInfo.InvariantCulture));
            }
        }
コード例 #4
0
        public static void LambdaAccessor_executes_static_lambda()
        {
            // Arrange
            var accessor = new LambdaAccessor <string>(MyLambda);

            // Act
            var actual = accessor.CorrelationId;

            // Assert
            Assert.Equal("123", actual);

            string MyLambda()
            {
                return("123");
            }
        }