protected override void beforeEach() { theEtag = "12345"; theFiles = new[] { new AssetFile("a"), new AssetFile("b") }; theAssetPath = new AssetPath("scripts/something") { ResourceHash = Guid.NewGuid().ToString() }; theHeaders = new Header[] { new Header("a", "1"), new Header("b", "2"), new Header("c", "3"), }; MockFor <IAssetCacheHeaders>().Stub(x => x.HeadersFor(theFiles)).Return(theHeaders); MockFor <IContentWriter>().Expect(x => x.Write(theAssetPath)) .Return(theFiles); MockFor <IETagGenerator <IEnumerable <AssetFile> > >() .Stub(x => x.Create(theFiles)) .Return(theEtag); FubuMode.Mode(FubuMode.Development); FubuMode.InDevelopment().ShouldBeTrue(); ClassUnderTest.Write(theAssetPath); }
private void writeScripts(HtmlTag foot) { // Do this regardless foot.Append(_assets.For("FubuDiagnostics.js").ToScriptTag(_request)); var routeData = _routeWriter.WriteJavascriptRoutes("FubuDiagnostics.routes", _routes); foot.Append(routeData); var extensionFiles = _assets.JavascriptFiles().Where(x => x.AssemblyName != "FubuMVC.Core"); if (FubuMode.Mode() == "diagnostics") { var names = _scripts.Union(extensionFiles.Select(x => x.Name)); var links = _tags.BuildScriptTags(names.Select(x => "fubu-diagnostics/" + x)); links.Each(x => foot.Append(x)); } else { _scripts.Each(name => { var file = _assets.For(name); foot.Append(file.ToScriptTag(_request)); }); extensionFiles.Each(file => foot.Append(file.ToScriptTag(_request))); } }
public void DevMode_as_is_is_true() { FubuMode.Detector.SetMode("Development"); FubuMode.InDevelopment().ShouldBeTrue(); FubuMode.Mode().ShouldEqual("Development"); }
public void DevMode_is_false() { FubuMode.Detector.SetMode("Production"); FubuMode.InDevelopment().ShouldBeFalse(); FubuMode.Mode().ShouldEqual("Production"); }
public void explicitly_do_not_precompile_views() { ClassUnderTest.PrecompileViews = false; FubuMode.Mode("Production"); ClassUnderTest.PrecompileViews.ShouldBeFalse(); }
public override bool Execute(ModeInput input) { if (input.ClearFlag) { FubuMode.Detector.SetMode(string.Empty); } if (input.DevFlag) { FubuMode.Detector.SetMode(FubuMode.Development); } if (input.ModeFlag.IsNotEmpty()) { FubuMode.Detector.SetMode(input.ModeFlag); } FubuMode.Reset(); var mode = FubuMode.Mode(); if (mode.IsEmpty()) { Console.WriteLine("No FubuMode is set"); } else { Console.WriteLine("FubuMode = '{0}'", FubuMode.Mode()); } return(true); }
public void DevMode_is_false() { Environment.SetEnvironmentVariable("FubuMode", "Production", EnvironmentVariableTarget.Machine); FubuMode.Reset(); FubuMode.InDevelopment().ShouldBeFalse(); FubuMode.Mode().ShouldEqual("Production"); }
public void DevMode_as_is_is_true() { Environment.SetEnvironmentVariable("FubuMode", "Development", EnvironmentVariableTarget.Machine); FubuMode.Reset(); FubuMode.InDevelopment().ShouldBeTrue(); FubuMode.Mode().ShouldEqual("Development"); }
public override bool Execute(ExportInput input) { var runnerDirectory = Assembly.GetExecutingAssembly().Location.ParentDirectory(); var bottling = Task.Factory.StartNew(() => { if (!input.NoBottlingFlag) { new BottleCommand().Execute(new BottleInput { NoZipFlag = true }); } }); var cleaning = Task.Factory.StartNew(() => cleanExplodedBottleContents(runnerDirectory)); var hostCleaning = Task.Factory.StartNew(() => { if (input.HostFlag.IsNotEmpty()) { input.TryToCleanOutFubuContentFolder(); } }); Task.WaitAll(bottling, cleaning, hostCleaning); var directories = input.ToDirectories(); try { _fileSystem.CreateDirectory(input.Output); if (input.CleanFlag) { _fileSystem.CleanDirectory(input.Output); } var projects = input .IncludeProjectsFlag .Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Trim()); projects.Each(BottlesFilter.Include); FubuMode.Mode(string.Empty); var application = new FubuDocsExportingApplication(directories).BuildApplication(); using (var server = application.RunEmbedded(directories.Solution)) { exportContent(input, server); } } catch (Exception e) { Console.WriteLine(e); return(false); } return(true); }
public void adds_the_about_endpoint_if_in_development_mode() { FubuMode.Mode(FubuMode.Development); var graph = BehaviorGraph.BuildEmptyGraph(); graph.BehaviorFor <AboutEndpoint>(x => x.get__about()) .ShouldNotBeNull(); }
public void does_not_activate_when_in_development_mode() { var activated = false; FubuMode.Mode(FubuMode.Development); ClassUnderTest.UseActivation(p => activated = true); ClassUnderTest.Activate(MockFor <IEnumerable <IPackageInfo> >(), MockFor <IPackageLog>()); activated.ShouldBeFalse(); }
public void activates_in_non_development_modes() { var activated = false; FubuMode.Mode("Chuck Norris Mode"); ClassUnderTest.UseActivation(p => activated = true); ClassUnderTest.Activate(MockFor <IEnumerable <IPackageInfo> >(), MockFor <IPackageLog>()); activated.ShouldBeTrueBecause("Chuck Norris would otherwise switch to RoR or MS MVC"); }
public FubuApplication BuildApplication() { FubuMode.Mode(FubuMode.Development); if (!FubuMode.InDevelopment()) { throw new InvalidOperationException("You can't be here without development mode!"); } return(FubuApplication.For <HarnessRegistry>().StructureMap(new Container())); }
public void set_to_another_mode() { theCommand.Execute(new ModeInput { ModeFlag = "Something" }); FubuMode.Reset(); FubuMode.Mode().ShouldEqual("Something"); }
public void DevMode_is_false_with_file() { Environment.SetEnvironmentVariable("FubuMode", "Development", EnvironmentVariableTarget.Machine); FubuMode.Detector = new FubuModeFileDetector(); FubuMode.Detector.SetMode("Production"); FubuMode.InDevelopment().ShouldBeFalse(); FubuMode.Mode().ShouldEqual("Production"); }
protected override void beforeRunning() { FubuMode.Mode(FubuMode.Development); _file = Harness.GetApplicationDirectory().AppendPath("content", "scripts", "ignoreme.js"); _originalText = Guid.NewGuid().ToString(); _newText = Guid.NewGuid().ToString(); new FileSystem().WriteStringToFile(_file, _originalText); }
public void the_mode_is_passed_in() { FubuMode.Mode("ReallyRandom"); FubuMode.Mode().ShouldEqual("ReallyRandom"); using (var server = FubuApplication.DefaultPolicies().StructureMap().RunEmbedded(autoFindPort: true)) { server.Endpoints.Get <OwinAppModeEndpoint>(x => x.get_owin_mode()) .ReadAsText() .ShouldEqual("reallyrandom"); } }
public void DevMode_as_is_is_true_with_file() { Environment.SetEnvironmentVariable("FubuMode", "", EnvironmentVariableTarget.Machine); FubuMode.Detector = new FubuModeFileDetector(); FubuMode.Detector.SetMode("Development"); FubuMode.InDevelopment().ShouldBeTrue(); FubuMode.Mode().ShouldEqual("Development"); }
public void override_devmode() { string isDev = FubuMode.Development; FubuMode.Mode(() => isDev); FubuMode.InDevelopment().ShouldBeTrue(); isDev = "something else"; FubuMode.Reset(); FubuMode.InDevelopment().ShouldBeFalse(); }
public void clear_the_mode() { theCommand.Execute(new ModeInput { DevFlag = true }); theCommand.Execute(new ModeInput { ClearFlag = true }); FubuMode.Reset(); FubuMode.Mode().IsEmpty().ShouldBeTrue(); }
public static void ApplyInjection(OwinSettings settings) { if (FubuMode.InDevelopment() || FubuMode.Mode().EqualsIgnoreCase("diagnostics")) { var injectedContent = PackageRegistry.Properties[TEXT_PROPERTY]; if (injectedContent.IsNotEmpty()) { settings.AddMiddleware <HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions { Content = _ => injectedContent }); } } }
public void override_devmode() { string isDev = FubuMode.Development; FubuMode.Mode(() => isDev); FubuMode.InDevelopment().ShouldBeTrue(); isDev = "something else"; FubuMode.Detector = new EnvironmentVariableDetector(); FubuMode.Detector.SetMode(""); FubuMode.InDevelopment().ShouldBeFalse(); }
public void manual_test_the_auto_reloading_tag() { FubuMode.Mode(FubuMode.Development); using (var server = FubuApplication.DefaultPolicies().StructureMap().RunEmbedded(port: 5601)) { Process.Start("http://localhost:5601/reloaded"); Thread.Sleep(20000); } using (var server = FubuApplication.DefaultPolicies().StructureMap().RunEmbedded(port: 5601)) { Thread.Sleep(20000); } FubuMode.Reset(); }
private void startServer(OwinSettings settings, string physicalPath, int port) { var parameters = new StartOptions { Port = port }; parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl if (physicalPath != null) { FubuMvcPackageFacility.PhysicalRootPath = physicalPath; } var context = new StartContext(parameters) { App = FubuOwinHost.ToAppFunc(_runtime, settings), }; settings.EnvironmentData.ToDictionary().Each(pair => context.EnvironmentData.Add(pair)); settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower(); context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary()); var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(), new AppLoader(new IAppLoaderFactory[0]), new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider()))); try { _server = engine.Start(context); } catch (TargetInvocationException e) { if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied")) { throw new KatanaRightsException(e.InnerException); } throw; } }
public void Receive(StartApplication message) { Console.WriteLine("Trying to start application " + message); PackageRegistry.Properties[HtmlHeadInjectionMiddleware.TEXT_PROPERTY] = message.HtmlHeadInjectedText; if (message.Mode.IsNotEmpty()) { FubuMode.Mode(message.Mode); } Console.WriteLine("FubuMode = " + FubuMode.Mode()); var chooser = new ApplicationSourceChooser(_typeFinder, _messaging); chooser.Find(message, applicationType => { _activator.Initialize(applicationType, message.PortNumber, message.PhysicalPath); }); }
private void startServer(OwinSettings settings, IList <RouteBase> routes, string physicalPath, int port) { var parameters = new StartOptions { Port = port }; parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl // Adding the static middleware settings.AddMiddleware <StaticFileMiddleware>(_services.GetInstance <IFubuApplicationFiles>(), settings); if (physicalPath != null) { FubuMvcPackageFacility.PhysicalRootPath = physicalPath; } Action <IAppBuilder> startup = FubuOwinHost.ToStartup(settings, routes); var context = new StartContext(parameters) { Startup = startup, }; settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower(); context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary()); var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(), new AppLoader(new IAppLoaderFactory[0]), new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider()))); try { _server = engine.Start(context); } catch (TargetInvocationException e) { if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied")) { throw new KatanaRightsException(e.InnerException); } throw; } }
private BehaviorGraph setupActions() { FubuMode.Mode(""); var registry = new FubuRegistry(); registry.Actions.IncludeType <Action1>(); registry.Actions.IncludeType <Action2>(); registry.Actions.IncludeType <Action3>(); registry.Configure(x => { var routeDefinition = new RouteDefinition("{Client}/"); routeDefinition.Input = MockRepository.GenerateMock <IRouteInput>(); routeDefinition.Input.Stub(_ => _.Rank).Return(5); x.BehaviorFor <Action1>(_ => _.M1()).As <RoutedChain>().AddRouteAlias(routeDefinition); }); return(BehaviorGraph.BuildFrom(registry)); }
public void Receive(StartApplication message) { Console.WriteLine("Trying to start application " + message); if (message.UseProductionMode) { Console.WriteLine("FubuMode = Production"); FubuMode.Reset(); } else { Console.WriteLine("FubuMode = Development"); FubuMode.Mode(FubuMode.Development); } var chooser = new ApplicationSourceChooser(_typeFinder, _messaging); chooser.Find(message, applicationType => { _activator.Initialize(applicationType, message.PortNumber, message.PhysicalPath); }); }
public void Receive(StartApplication message) { Console.WriteLine("Trying to start application " + message); PackageRegistry.Properties[HtmlHeadInjectionMiddleware.TEXT_PROPERTY] = message.HtmlHeadInjectedText; if (message.UseProductionMode) { Console.WriteLine("FubuMode = Production"); FubuMode.Reset(); } else { Console.WriteLine("FubuMode = Development"); FubuMode.Mode(FubuMode.Development); } var chooser = new ApplicationSourceChooser(_typeFinder, _messaging); chooser.Find(message, applicationType => { _activator.Initialize(applicationType, message.PortNumber, message.PhysicalPath); }); }
public void SetUp() { FubuMode.Mode(FubuMode.Development); server = FubuApplication.DefaultPolicies().StructureMap().RunEmbedded(port: PortFinder.FindPort(5500)); }