Пример #1
0
        public void OnFail(string message, AssertionHandlingMethod method)
        {
            switch (method)
            {
            case AssertionHandlingMethod.Console:
            {
                Console.WriteLine(message);
                return;
            }

            case AssertionHandlingMethod.Log:
            {
                XLog.LogError(new DebugLogMessage()
                    {
                        Message = new Message()
                        {
                            Value = message
                        }
                    });

                return;
            }

            case AssertionHandlingMethod.Throw:
            {
                throw XExceptions.Exception(message);
            }

            default:
            {
                Console.WriteLine(method);
                return;
            }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the value of the text source.
        /// </summary>
        /// <param name="segment"></param>
        /// <returns></returns>
        public string GetValue(TextSegment_I segment)
        {
            var source = segment.Source;

            string result;

            switch (source.Type)
            {
            case TextSourceType.File:
            {
                result = XTextual.TextSources.Files.GetValue(segment, (TextSourceFile)source);
                break;
            }

            case TextSourceType.Stream:
            {
                result = XTextual.TextSources.Streams.GetValue(segment, (TextSourceStream)source);
                break;
            }

            case TextSourceType.String:
            {
                result = XTextual.TextSources.Strings.GetValue(segment, (TextSourceString)source);
                break;
            }

            default:
            {
                throw XExceptions.Exception("TextSourceType is not supported.");
            }
            }

            if (segment.SupportsCachedValue)
            {
                segment.CachedValue = result;
            }

            return(result);
        }