protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (_partition != null && _study == null)
            {
                StudyNotFoundException exception = new StudyNotFoundException(_studyInstanceUid);
                ExceptionHandler.ThrowException(exception);
            }
            if (_partition == null)
            {
                PartitionNotFoundException exception = new PartitionNotFoundException(_serverae);
                ExceptionHandler.ThrowException(exception);
            }

            if (_study == null)
            {
                StudyNotFoundException exception = new StudyNotFoundException(_studyInstanceUid);
                ExceptionHandler.ThrowException(exception);
            }
            else
            {
                SetPageTitle(String.Format("{0}:{1}", NameFormatter.Format(_study.PatientsName), _study.PatientId), false);
            }
        }
Example #2
0
        /// <summary>
        /// Returns step name format which bases on name of scenario step method and method parameters.<br/>
        /// If method is parameterized, the step name would contain format parameters {n} that would be replaced with argument values (where {0} refers to first argument) during step execution.<br/>
        /// Please note that rules for placing parameter values in step name are as follows, where first matching rule would be used:
        /// <list type="bullet">
        /// <item><description>it will replace first occurrence of variable name written in capital letters (<c>void Price_is_AMOUNT_dollars(int amount)</c> => <c>Price is "27" dollars</c>)</description></item>
        /// <item><description>it will placed after first occurrence of variable name (<c>void Product_is_in_stock(string product)</c> => <c>Product "desk" is in stock</c>)</description></item>
        /// <item><description>it will placed at the end of step name (<c>void Product_is_in_stock(string productId)</c> => <c>Product is in stock [productId: "ABC123"]</c>)</description></item>
        /// </list>
        /// </summary>
        /// <param name="stepMethod">Step method.</param>
        /// <returns>Step name.</returns>
        public string GetStepNameFormat(MethodInfo stepMethod)
        {
            var name = NameFormatter.Format(stepMethod.Name);
            var sb   = new StringBuilder();

            var replacements = stepMethod
                               .GetParameters()
                               .Select((param, index) => ToArgumentReplacement(name, param, index))
                               .OrderBy(r => r.Position)
                               .ToArray();
            int lastPos = 0;

            foreach (var replacement in replacements)
            {
                if (lastPos < replacement.Position)
                {
                    sb.Append(name.Substring(lastPos, replacement.Position - lastPos));
                }
                sb.Append(replacement.Value);
                lastPos = replacement.Position + replacement.CharactersToReplace;
            }

            sb.Append(name.Substring(lastPos));
            return(sb.ToString());
        }
Example #3
0
        public void Format_WithDoubleEscapedEndFormatBraceWhichTerminatesString_ThrowsFormatException()
        {
            //arrange
            var o = new { foo = 123.45 };

            //act, assert
            NameFormatter.Format("{foo}}}}", o);
        }
Example #4
0
        public void Format_WithDoubleEscapedEndFormatBrace_ThrowsFormatException()
        {
            //arrange
            var o = new { foo = 123.45 };

            //act, assert
            NameFormatter.Format("{foo}}}}bar", o);
        }
Example #5
0
        public void Example()
        {
            var    o      = new { First = "John", Last = "Doe" };
            string result = NameFormatter.Format("Full Name: {First} {Last}", o);

            //assert
            Assert.AreEqual("Full Name: John Doe", result);
        }
Example #6
0
        public void Format_WithFormatNameNotInObject_ThrowsFormatException()
        {
            //arrange
            var o = new { foo = 123.45 };

            //act, assert
            NameFormatter.Format("{bar}", o);
        }
        /// <summary>
        /// Applies a format to the item
        /// </summary>
        /// <param name="item">Item to format</param>
        /// <param name="format">Format string</param>
        /// <returns>Formatted string</returns>
        public static string FormatNameAs(this object item, string format)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            return(NameFormatter.Format(format, item));
        }
        /// <summary>
        /// Uses the string as a format.
        /// </summary>
        /// <param name="format">A String reference</param>
        /// <param name="source">Object that should be formatted</param>
        /// <returns>Formatted string</returns>
        public static string FormatName(this string format, object source)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            return(NameFormatter.Format(format, source));
        }
Example #9
0
        public void Format_WithEndBraceFollowedByDoubleEscapedEndFormatBrace_FormatsCorrectly()
        {
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("{foo}}}}}bar", o);

            //assert
            Assert.AreEqual("123.45}}bar", result);
        }
Example #10
0
        public void Format_WithSubProperty_ReturnsValueOfSubProperty()
        {
            var o = new { foo = new { bar = 123.45 } };

            //act
            string result = NameFormatter.Format("{foo.bar:#.#}ms", o);

            //assert
            Assert.AreEqual("123.5ms", result);
        }
Example #11
0
        public void Format_WithFormatType_ReturnsFormattedExpression()
        {
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("{foo:#.#}", o);

            //assert
            Assert.AreEqual("123.5", result);
        }
Example #12
0
        public void Format_WithEndBraceFollowedByEscapedEndFormatBraceWhichTerminatesString_FormatsCorrectly()
        {
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("{foo}}}", o);

            //assert
            Assert.AreEqual("123.45}", result);
        }
Example #13
0
        public void Format_WithNoFormats_ReturnsFormatStringAsIs()
        {
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("a b c", o);

            //assert
            Assert.AreEqual("a b c", result);
        }
Example #14
0
        public void Format_WithEmptyString_ReturnsEmptyString()
        {
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format(string.Empty, o);

            //assert
            Assert.AreEqual(string.Empty, result);
        }
Example #15
0
        public void Format_WithEscapeSequence_EscapesInnerCurlyBraces()
        {
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("{{{foo}}}", o);

            //assert
            Assert.AreEqual("{123.45}", result);
        }
Example #16
0
        public void StringFormat_WithMultipleExpressions_FormatsThemAll()
        {
            //arrange
            var o = new { foo = 123.45, bar = 42, baz = "hello" };

            //act
            string result = NameFormatter.Format("{foo} {foo} {bar}{baz}", o);

            //assert
            Assert.AreEqual("123.45 123.45 42hello", result);
        }
Example #17
0
        public void StringFormat_WithDoubleEscapedCurlyBraces_DoesNotFormatString()
        {
            //arrange
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("{{{{foo}}}}", o);

            //assert
            Assert.AreEqual("{{foo}}", result);
        }
Example #18
0
        public void StringFormat_WithFormatSurroundedByDoubleEscapedBraces_FormatsString()
        {
            //arrange
            var o = new { foo = 123.45 };

            //act
            string result = NameFormatter.Format("{{{{{foo}}}}}", o);

            //assert
            Assert.AreEqual("{{123.45}}", result);
        }
Example #19
0
        public static Plan CreatePlan(Type type, DateTime startDate, NameFormatter nameFormatter, FormatterArgs args)
        {
            Plan plan      = (Plan)Activator.CreateInstance(type, startDate);
            var  itemNames = nameFormatter.Format(args);

            foreach (string itemName in itemNames)
            {
                plan.GenerateItem(itemName);
            }

            return(plan);
        }
Example #20
0
 /// <summary>
 /// Generates all storage fields
 /// </summary>
 /// <param name="schema"></param>
 protected virtual void GenerateStorageAndMemberFields(Database schema)
 {
     GenerateStorageAndMemberFields(schema, delegate(string name)
     {
         //jgm 2008June: pre-pended underscore to have same storage format as MS
         // TODO: add an option for this behavior
         var storage = "_" + NameFormatter.Format(name, Case.camelCase);
         if (storage == name)
         {
             storage = "_" + storage;
         }
         return(storage);
     });
 }
Example #21
0
        protected override void  OnPreRender(EventArgs e)
        {
            if (_series == null)
            {
                Response.Write("<Br>NO  SUCH SERIES FOUND<Br>");

                SeriesDetailsPanel1.Visible = false;
            }
            else
            {
                SetPageTitle(String.Format("{0}:{1} (Series: {2})", NameFormatter.Format(_study.PatientsName), _study.PatientId, _series.SeriesNumber), false);
            }

            base.OnPreRender(e);
        }
Example #22
0
        protected virtual string GetRenderedPatientName()
        {
            string name = PersonName;

            switch (PersonNameType)
            {
            case NameType.Normal:
                return(name);

            case NameType.Dicom:
                PersonName pn = new PersonName(name);
                return(NameFormatter.Format(name, UISettings.Default.NameFormat));

            default:
                return(name);    // no formatting
            }
        }
 public void Should_format_text(string input, string expectedOutput)
 {
     Assert.That(NameFormatter.Format(input), Is.EqualTo(expectedOutput));
 }
Example #24
0
 /// <summary>
 /// Retrieves scenario name which bases on name of scenario method.
 /// </summary>
 /// <returns>Scenario name.</returns>
 public string GetScenarioName(MethodBase scenarioMethod)
 {
     return(NameFormatter.Format(scenarioMethod.Name));
 }
Example #25
0
 /// <summary>
 /// Retrieves feature name which bases on name of feature test class.
 /// </summary>
 /// <returns>Feature name.</returns>
 public string GetFeatureName(Type featureTestClass)
 {
     return(NameFormatter.Format(featureTestClass.Name));
 }
Example #26
0
 /// <summary>
 /// Returns formatted and capitalized step type name or string.Empty if step is meaningless.
 /// </summary>
 public string GetStepTypeName(string stepType)
 {
     return(string.IsNullOrWhiteSpace(stepType) ? string.Empty : NameFormatter.Format(stepType).ToUpperInvariant().Trim());
 }
Example #27
0
 /// <summary>
 /// Returns step name which bases on name of scenario step method.
 /// </summary>
 /// <returns>Step name.</returns>
 public string GetStepName(MethodBase stepMethod)
 {
     return(NameFormatter.Format(stepMethod.Name));
 }
Example #28
0
 /// <summary>
 /// Uses the string as a format.
 /// </summary>
 /// <param name="format">A String reference</param>
 /// <param name="source">Object that should be formatted</param>
 /// <returns>Formatted string</returns>
 public static string FormatName(this string format, object source)
 {
     format.Require <string>("format").NotNullOrEmpty();
     return(NameFormatter.Format(format, source));
 }
Example #29
0
 /// <summary>
 /// Applies a format to the item
 /// </summary>
 /// <param name="item">Item to format</param>
 /// <param name="format">Format string</param>
 /// <returns>Formatted string</returns>
 public static string FormatNameAs(this object item, string format)
 {
     format.Require <string>("format").NotNullOrEmpty();
     return(NameFormatter.Format(format, item));
 }
Example #30
0
 public void Format_WithNullFormatString_ThrowsArgumentNullException()
 {
     //arrange, act, assert
     NameFormatter.Format(null, 123);
 }