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")); }
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())); }
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")); }
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); }
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(); }
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(); }
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); }
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); }
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); }
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); }
protected override void beforeEach() { theContext = new MockedFubuRequestContext(Services.Container); Services.Inject <IFubuRequestContext>(theContext); }