This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ResourceExplorer | |
| { | |
| public static void Inspect(Assembly assembly, IEnumerable<string> supportedExtensions) | |
| { | |
| var resourceNames = | |
| from resourceStreamName in assembly.GetManifestResourceNames() | |
| from extension in supportedExtensions | |
| where resourceStreamName.EndsWith(extension) | |
| select resourceStreamName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BrowserFixture | |
| { | |
| private readonly Browser browser; | |
| public BrowserFixture() | |
| { | |
| var bootstrapper = | |
| new FakeDefaultNancyBootstrapper(); | |
| this.browser = new Browser(bootstrapper); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Fact] | |
| public void Should_add_multipart_formdata_encoded_files_to_request_filestream() | |
| { | |
| // Given | |
| var stream = | |
| CreateFakeFileStream("This is the contents of a file"); | |
| var multipart = new BrowserContextMultipartFormData(x => { | |
| x.AddFile("foo", "foo.txt", "text/plain", stream); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class test | |
| { | |
| public test() | |
| { | |
| var bootstrapper = new FakeNancyBootstrapper(with => { | |
| with.Engine<NancyEngine>(); | |
| with.ContextFactory<DefaultNancyContextFactory>(); | |
| with.RoutePatternMatcher<DefaultRoutePatternMatcher>(); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FakeNancyBootstrapper : INancyBootstrapper, IApplicationPipelines, INancyModuleCatalog | |
| { | |
| private TinyIoCContainer container; | |
| private const string ContextKey = "DefaultNancyBootStrapperChildContainer"; | |
| private Dictionary<Type, object> configuredDefaults; | |
| private Dictionary<Type, IEnumerable<Tuple<Type, string>>> configuredEnumerableDefaults; | |
| public FakeNancyBootstrapper() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected override void RegisterDefaults(TinyIoCContainer existingContainer, IEnumerable<TypeRegistration> typeRegistrations) | |
| { | |
| existingContainer.Register<INancyModuleCatalog>(this); | |
| foreach (var typeRegistration in typeRegistrations) | |
| { | |
| this.Register(typeRegistration.RegistrationType, typeRegistration.ImplementationType); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // -- BEFORE -- | |
| Post["/create"] = x => | |
| { | |
| var be = new BeerEvent() | |
| { | |
| Name = Request.Form.Name, | |
| Location = Request.Form.Location, | |
| EventDate = Request.Form.EventDate | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MainModule : NancyModule | |
| { | |
| public MainModule() | |
| { | |
| Get["/"] = parameters => { | |
| return "Hello World"; | |
| }; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyBootstrapper : DefaultNancyBootstrapper | |
| { | |
| protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container) | |
| { | |
| base.InitialiseInternal(container); | |
| this.AfterRequest += ctx => { | |
| if (ctx.Response.StatusCode.Equals(HttpStatusCode.NotFound)) | |
| { | |
| ctx.Response = "This is a custom error page"; ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return new List<Func<string, dynamic, string, string>> | |
| { | |
| (viewName, model, modulePath) => { | |
| return string.Concat("/views/", viewName); | |
| }, | |
| (viewName, model, modulePath) => { | |
| return string.Concat("/views", modulePath, "/", viewName); | |
| } | |
| }; |