Exemplo n.º 1
0
        public void write()
        {
            var context = new MockedFubuRequestContext();

            ClassUnderTest.Write(MimeType.Text.Value, context, "some text");
            context.Writer.AssertWasCalled(x => x.Write(MimeType.Text.Value, "some text"));
        }
Exemplo n.º 2
0
        public void writing_should_write_the_to_string_of_the_target()
        {
            var context = new MockedFubuRequestContext(Services.Container);

            ClassUnderTest.Write(MimeType.Html.Value, context, theTag);

            context.Writer.AssertWasCalled(x => x.Write(MimeType.Html.Value, theTag.ToString()));
        }
Exemplo n.º 3
0
        public void delegates_to_its_formatter_when_it_writes()
        {
            var address = new Address();

            var context = new MockedFubuRequestContext();

            ClassUnderTest.Write("something", context, address);

            MockFor <IFormatter>().AssertWasCalled(x => x.Write(context, address, "something"));
        }
Exemplo n.º 4
0
        protected override void beforeEach()
        {
            theContext = new MockedFubuRequestContext(Services.Container);
            Services.Inject <IFubuRequestContext>(theContext);

            theTarget   = new OutputTarget();
            theMimeType = new CurrentMimeType("text/plain", "text/plain");

            MockFor <IMediaCollection <OutputTarget> >().Stub(x => x.SelectMedia(theMimeType, theContext)).Return(null);

            ClassUnderTest.WriteResource(theMimeType, theTarget);
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            theRequest = OwinHttpRequest.ForTesting();
            writer     = new InMemoryOutputWriter();

            var container = new Container(x => {
                x.For <IHttpRequest>().Use(theRequest);
                x.For <IOutputWriter>().Use(writer);
                x.For <IFubuRequest>().Use(new InMemoryFubuRequest());
            });

            context = new MockedFubuRequestContext(container);

            theFormatter = new XmlFormatter();
        }
Exemplo n.º 6
0
        public void SetUp()
        {
            theRequest = OwinHttpRequest.ForTesting();
            writer = new InMemoryOutputWriter();

            var container = new Container(x => {
                x.For<IHttpRequest>().Use(theRequest);
                x.For<IOutputWriter>().Use(writer);
                x.For<IFubuRequest>().Use(new InMemoryFubuRequest());
            });

            context = new MockedFubuRequestContext(container);

            theFormatter = new XmlFormatter();
        }
Exemplo n.º 7
0
        public void read_just_forces_ifuburequest_to_read()
        {
            var address = new Address();

            var context = new MockedFubuRequestContext(Services.Container);

            Services.Inject <IFubuRequestContext>(context);


            MockFor <IFubuRequest>().Stub(x => x.Get <Address>())
            .Return(address);

            ClassUnderTest.Read("anything", context).ShouldBeTheSameAs(address);

            MockFor <IFubuRequest>().Clear(typeof(Address));
        }
        public void delegates_by_bool_func()
        {
            var policy = new AuthorizationByService<AuthCheckingService>(x => x.IsOk);

            var context = new MockedFubuRequestContext();
            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = true
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Allow);

            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = false
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Deny);
        }
Exemplo n.º 9
0
        public void delegates_by_bool_func()
        {
            var policy = new AuthorizationByService <AuthCheckingService>(x => x.IsOk);

            var context = new MockedFubuRequestContext();

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = true
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Allow);

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = false
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Deny);
        }
Exemplo n.º 10
0
        public void delegates_by_auth_rights_func()
        {
            var policy = new AuthorizationByService <AuthCheckingService>(x => x.Rights);

            var context = new MockedFubuRequestContext();

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Allow
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Allow);

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Deny
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Deny);
        }
Exemplo n.º 11
0
        public void delegates_by_auth_rights_func()
        {
            var policy = new AuthorizationByService<AuthCheckingService>(x => x.Rights);

            var context = new MockedFubuRequestContext();
            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Allow
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Allow);

            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Deny
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Deny);

        }
Exemplo n.º 12
0
 protected override void beforeEach()
 {
     theContext = new MockedFubuRequestContext(Services.Container);
     Services.Inject <IFubuRequestContext>(theContext);
 }