Example #1
0
 public string ToDisplay(Widget widget)
 {
     return "A {0} widget".ToFormat(widget.Color);
 }
Example #2
0
        public void stringifier_can_use_a_service_to_get_at_a_display()
        {
            locator.Services[typeof (IWidgetDisplayer)] = new WidgetDisplayer();

            configure(x =>
            {
                x.IfCanBeCastToType<Widget>().ConvertBy((r, w) => r.Get<IWidgetDisplayer>().ToDisplay(w));
            });

            var widget = new Widget
            {
                Color = "Red"
            };

            var request = new GetStringRequest(null, widget, locator);

            stringifier.GetString(request).ShouldEqual("A Red widget");
        }