public XmlFormatterExtensionsFixtures() { this.rootPathProvider = A.Fake<IRootPathProvider>(); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.responseFormatter.AsXml(model); }
public DefaultNancyModuleBuilderFixture() { this.module = new FakeNancyModule(); this.rootPathProvider = A.Fake <IRootPathProvider>(); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider); this.viewFactory = A.Fake <IViewFactory>(); this.builder = new DefaultNancyModuleBuilder(this.viewFactory, this.responseFormatter); }
public DefaultNancyModuleBuilderFixture() { this.module = new FakeNancyModule(); this.rootPathProvider = A.Fake<IRootPathProvider>(); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider); this.viewFactory = A.Fake<IViewFactory>(); this.builder = new DefaultNancyModuleBuilder(this.viewFactory, this.responseFormatter); }
public XmlFormatterExtensionsFixtures() { this.rootPathProvider = A.Fake <IRootPathProvider>(); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.responseFormatter.AsXml(model); }
public XmlFormatterExtensionsFixtures() { this.rootPathProvider = A.Fake<IRootPathProvider>(); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider, new NancyContext(), new ISerializer[] { new DefaultXmlSerializer() }); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.responseFormatter.AsXml(model); }
public void Should_return_context_that_was_used_when_creating_instance() { // Given var context = new NancyContext(); // When var formatter = new DefaultResponseFormatter(null, context, new ISerializer[] { }); // Then formatter.Context.ShouldBeSameAs(context); }
public void Should_return_context_that_was_used_when_creating_instance() { // Given var context = new NancyContext(); // When var formatter = new DefaultResponseFormatter(null, context, new DefaultSerializerFactory(null), A.Fake <INancyEnvironment>()); // Then formatter.Context.ShouldBeSameAs(context); }
public void Should_return_context_that_was_used_when_creating_instance() { // Given var context = new NancyContext(); // When var formatter = new DefaultResponseFormatter(null, context, new DefaultSerializerFactory(null), A.Fake<INancyEnvironment>()); // Then formatter.Context.ShouldBeSameAs(context); }
public XmlFormatterExtensionsFixtures() { this.rootPathProvider = A.Fake <IRootPathProvider>(); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider, new NancyContext(), new ISerializer[] { new DefaultXmlSerializer() }); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.responseFormatter.AsXml(model); }
public void Should_return_path_provided_by_root_path_provider() { // Given var rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => rootPathProvider.GetRootPath()).Returns("foo"); var formatter = new DefaultResponseFormatter(rootPathProvider, null, new ISerializer[] { }); // When var result = formatter.RootPath; // Then result.ShouldEqual("foo"); }
public void Should_return_path_provided_by_root_path_provider() { // Given var rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => rootPathProvider.GetRootPath()).Returns("foo"); var formatter = new DefaultResponseFormatter(rootPathProvider, null, new DefaultSerializerFactory(null), A.Fake <INancyEnvironment>()); // When var result = formatter.RootPath; // Then result.ShouldEqual("foo"); }
public void Should_return_path_provided_by_root_path_provider() { // Given var rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => rootPathProvider.GetRootPath()).Returns("foo"); var formatter = new DefaultResponseFormatter(rootPathProvider); // When var result = formatter.RootPath; // Then result.ShouldEqual("foo"); }
public XmlFormatterExtensionsFixtures() { this.rootPathProvider = A.Fake<IRootPathProvider>(); var environment = new DefaultNancyEnvironment(); environment.AddValue(XmlConfiguration.Default); var serializerFactory = new DefaultSerializerFactory(new ISerializer[] { new DefaultXmlSerializer(environment) }); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider, new NancyContext(), serializerFactory, environment); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.responseFormatter.AsXml(model); }
public XmlFormatterExtensionsFixtures() { this.rootPathProvider = A.Fake <IRootPathProvider>(); var environment = new DefaultNancyEnvironment(); environment.AddValue(XmlConfiguration.Default); var serializerFactory = new DefaultSerializerFactory(new ISerializer[] { new DefaultXmlSerializer(environment) }); this.responseFormatter = new DefaultResponseFormatter(this.rootPathProvider, new NancyContext(), serializerFactory, environment); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.responseFormatter.AsXml(model); }
public void Should_return_valid_NancyResponse_containing_the_message_and_code_corresponding_to_the_requested_error() { // Given var errorService = new ErrorService(); var formatter = new DefaultResponseFormatter(A.Dummy <IRootPathProvider>(), A.Dummy <NancyContext>(), A.Dummy <IEnumerable <ISerializer> >()); var error = ErrorCode.UserNameTaken; // When var response = errorService.Generate(formatter, error); // Then response.ShouldNotBe(null); response.StatusCode.ShouldBe(HttpStatusCode.BadRequest); var contents = response.GetContents(); ((object)contents).ShouldNotBe(null); ((int)contents.ErrorCode).ShouldBe((int)error); ((string)contents.ErrorMessage).ShouldBe("The UserName has already been taken"); }