public JsonFormatterExtensionsFixtures() { this.formatter = A.Fake<IResponseFormatter>(); A.CallTo(() => this.formatter.Serializers).Returns(new[] { new DefaultJsonSerializer() }); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.formatter.AsJson(model); }
public JsonFormatterExtensionsFixtures() { this.formatter = A.Fake<IResponseFormatter>(); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; DefaultSerializersStartup.JsonSerializer = new DefaultJsonSerializer(); this.response = this.formatter.AsJson(model); }
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 JsonFormatterExtensionsFixtures() { var environment = GetTestingEnvironment(); var serializerFactory = new DefaultSerializerFactory(new ISerializer[] { new DefaultJsonSerializer(environment) }); this.formatter = A.Fake<IResponseFormatter>(); A.CallTo(() => this.formatter.Environment).Returns(environment); A.CallTo(() => this.formatter.SerializerFactory).Returns(serializerFactory); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.formatter.AsJson(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 JsonFormatterExtensionsFixtures() { this.formatter = A.Fake<IResponseFormatter>(); this.model = new Person { FirstName = "Andy", LastName = "Pike" }; this.response = this.formatter.AsJson(model); }
public void Should_invoke_response_negotiator() { // Given var model = new Person { FirstName = "First", LastName = "Last" }; var route = new FakeRoute(model); var parameters = new DynamicDictionary(); var context = new NancyContext { Trace = new DefaultRequestTrace() }; // When var result = this.invoker.Invoke(route, new CancellationToken(), parameters, context).Result; // Then A.CallTo(() => this.responseNegotiator.NegotiateResponse(model, context)).MustHaveHappened(); }