예제 #1
0
        public void add_writer_happy_path_with_open_type_and_explicit_condition()
        {
            var node = new OutputNode(typeof(Address));

            node.Add(typeof(FooWriter <>));

            node.Explicits.Single().ShouldBeOfType <FooWriter <Address> >();
        }
예제 #2
0
        public void add_writer_with_explicit_condition()
        {
            var node         = new OutputNode(typeof(Address));
            var theFormatter = new NewtonsoftJsonFormatter();

            node.Add(theFormatter);

            node.Explicits.Single().ShouldBeOfType <FormatterWriter <Address> >();
        }
예제 #3
0
        public void add_a_closed_writer_with_conditional()
        {
            var writer = new SpecialWriter();
            var node   = new OutputNode(typeof(Address));

            node.Add(writer);

            node.Explicits.Single().ShouldBeTheSameAs(writer);
        }
예제 #4
0
        public void add_a_closed_writer_happy_path()
        {
            var writer = new SpecialWriter();
            var node   = new OutputNode(typeof(Address));

            node.Add(writer);

            var media = node.Explicits.Single().ShouldBeTheSameAs(writer);
        }
예제 #5
0
        public void add_a_closed_writer_happy_path()
        {
            var writer = new SpecialWriter();
            var node   = new OutputNode(typeof(Address));

            node.Add(writer);

            var media = node.Explicits.Single().ShouldBeOfType <Media <Address> >();

            media.Writer.ShouldBeTheSameAs(writer);
            media.Condition.ShouldBeTheSameAs(Always.Flyweight);
        }
예제 #6
0
        public void add_writer_happy_path_with_open_type_and_explicit_condition()
        {
            var condition = new IsAjaxRequest();
            var node      = new OutputNode(typeof(Address));

            node.Add(typeof(FooWriter <>), condition);

            var media = node.Explicits.Single().ShouldBeOfType <Media <Address> >();

            media.Writer.ShouldBeOfType <FooWriter <Address> >();
            media.Condition.ShouldBeTheSameAs(condition);
        }
예제 #7
0
        public void SetUp()
        {
            var node = new OutputNode(typeof(Address));

            node.Add(new NewtonsoftJsonFormatter());
            node.Add(new XmlFormatter());
            node.Add(new FakeAddressWriter());

            using (var runtime = FubuRuntime.Basic())
            {
                var container = runtime.Get <IContainer>();

                container.Configure(x =>
                {
                    // Need a stand in value
                    x.For <IHttpRequest>().Use(MockRepository.GenerateMock <IHttpRequest>());
                });

                theInputBehavior =
                    container.GetInstance <OutputBehavior <Address> >(node.As <IContainerModel>().ToInstance());
            }
        }
예제 #8
0
        public static BehaviorChain AddChainForWriter <T>(this BehaviorGraph graph, object writer)
        {
            var chain = new BehaviorChain();
            var node  = new OutputNode(typeof(T));

            node.Add(writer);

            chain.AddToEnd(node);

            graph.AddChain(chain);

            return(chain);
        }
예제 #9
0
        public void add_a_closed_writer_with_conditional()
        {
            var condition = new IsAjaxRequest();
            var writer    = new SpecialWriter();
            var node      = new OutputNode(typeof(Address));

            node.Add(writer, condition);

            var media = node.Explicits.Single().ShouldBeOfType <Media <Address> >();

            media.Writer.ShouldBeTheSameAs(writer);
            media.Condition.ShouldBeTheSameAs(condition);
        }
예제 #10
0
        public void add_writer_by_formatter_happy_path_no_condition()
        {
            var node         = new OutputNode(typeof(Address));
            var theFormatter = new JsonSerializer();

            node.Add(theFormatter);

            var media = node.Explicits.Single().ShouldBeOfType <Media <Address> >();

            media.Writer.ShouldBeOfType <FormatterWriter <Address> >()
            .Formatter.ShouldBeTheSameAs(theFormatter);

            media.Condition.ShouldBeTheSameAs(Always.Flyweight);
        }
예제 #11
0
        public void add_writer_with_explicit_condition()
        {
            var node         = new OutputNode(typeof(Address));
            var theFormatter = new JsonSerializer();
            var condition    = new IsAjaxRequest();

            node.Add(theFormatter, condition);

            var media = node.Explicits.Single().ShouldBeOfType <Media <Address> >();

            media.Writer.ShouldBeOfType <FormatterWriter <Address> >()
            .Formatter.ShouldBeTheSameAs(theFormatter);

            media.Condition.ShouldBeTheSameAs(condition);
        }