├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── ClearNuGetCaches.bat ├── LICENSE.txt ├── NuGet ├── FeatureToggleNugetTestFeed │ ├── FeatureToggle.4.0.0-rc1.nupkg │ ├── FeatureToggle.4.0.0.nupkg │ ├── FeatureToggle.NetStandard.4.0.0-rc1.nupkg │ └── FeatureToggle.NetStandard.4.0.0.nupkg └── NuGet.exe ├── README.md ├── Release-Notes.md ├── etc ├── logo.png ├── logo.svg └── v4 │ ├── logo.png │ └── logo.svg └── src ├── Examples ├── AspDotNetCoreExample │ ├── .bowerrc │ ├── AspDotNetCoreExample.csproj │ ├── Controllers │ │ └── HomeController.cs │ ├── Models │ │ ├── Printing.cs │ │ └── Saving.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── ViewModels │ │ └── HomeIndexViewModel.cs │ ├── Views │ │ ├── Home │ │ │ ├── About.cshtml │ │ │ ├── Contact.cshtml │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── bower.json │ ├── bundleconfig.json │ └── wwwroot │ │ ├── css │ │ ├── site.css │ │ └── site.min.css │ │ ├── favicon.ico │ │ ├── images │ │ ├── banner1.svg │ │ ├── banner2.svg │ │ ├── banner3.svg │ │ └── banner4.svg │ │ ├── js │ │ ├── site.js │ │ └── site.min.js │ │ └── lib │ │ ├── bootstrap │ │ ├── .bower.json │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ ├── bootstrap-theme.css.map │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap-theme.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ └── js │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.min.js │ │ │ └── npm.js │ │ ├── jquery-validation-unobtrusive │ │ ├── .bower.json │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ │ ├── jquery-validation │ │ ├── .bower.json │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ │ └── jquery │ │ ├── .bower.json │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map ├── ConsoleAppDotNetCore │ ├── ConsoleAppDotNetCore.csproj │ ├── Printing.cs │ ├── Program.cs │ ├── Saving.cs │ ├── Tweeting.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── ExampleWebFormsApplication │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── ExampleWebFormsApplication.csproj │ ├── Feature2Toggle.cs │ ├── NewYears2000Feature.cs │ ├── NewYears3000Feature.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ └── Web.config ├── ExampleWpfApplication │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── BooleanToVisibilityConverter.cs │ ├── ExampleWpfApplication.csproj │ ├── Feature2Toggle.cs │ ├── Feature3Toggle.cs │ ├── FeatureXToggle.cs │ ├── FeatureYToggle.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── ReadMe.txt └── UWP10Example │ ├── App.xaml │ ├── App.xaml.cs │ ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png │ ├── Feature2Toggle.cs │ ├── Feature3Toggle.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Package.appxmanifest │ ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml │ ├── UWP10Example.csproj │ ├── UWP10Example_TemporaryKey.pfx │ └── project.json ├── FeatureToggle.Common ├── AlwaysOffFeatureToggle.cs ├── AlwaysOnFeatureToggle.cs ├── CompositeAndDecorator.cs ├── CompositeOrDecorator.cs ├── ConfigurationDateParser.cs ├── ConfigurationValidator.cs ├── DefaultToDisabledOnErrorDecorator.cs ├── DefaultToEnabledOnErrorDecorator.cs ├── FallbackValueDecorator.cs ├── FeatureToggle.Common.csproj ├── FixedTimeCacheDecorator.cs ├── IAssemblyVersionProvider.cs ├── IBooleanToggleValueProvider.cs ├── IDateTimeToggleValueProvider.cs ├── IDaysOfWeekToggleValueProvider.cs ├── IFeatureToggle.cs ├── ITimePeriodProvider.cs ├── Is.cs ├── RandomFeatureToggle.cs ├── ToggleConfigurationError.cs └── ToggleConfigurationSettings.cs ├── FeatureToggle.Shared ├── EnabledBetweenDatesFeatureToggle.cs ├── EnabledOnDaysOfWeekFeatureToggle.cs ├── EnabledOnOrAfterAssemblyVersionWhereToggleIsDefinedToggle.cs ├── EnabledOnOrAfterDateFeatureToggle.cs ├── EnabledOnOrBeforeDateFeatureToggle.cs ├── FeatureToggle.Shared.projitems ├── FeatureToggle.Shared.shproj ├── FeatureToggleToVisibilityConverter.cs ├── HttpJsonFeatureToggle.cs ├── Internal │ ├── AppSettingsProvider.cs │ ├── ApplicationResourcesSettingsProvider.cs │ ├── BooleanSqlServerProvider.cs │ └── JsonEnabledResponse.cs ├── SimpleFeatureToggle.cs └── SqlFeatureToggle.cs ├── FeatureToggle.sln ├── FeatureToggle ├── FeatureToggle.csproj └── Readme.txt └── Tests ├── FeatureToggle.NetCore.Tests ├── AppSettingsProviderShould.cs ├── FeatureToggle.NetCore.Tests.csproj ├── SolutionPathUtility.cs ├── appSettings.json └── customSettings.json ├── FeatureToggle.NetCore └── FeatureToggle.NetCore.csproj ├── FeatureToggle.NetFull.Tests ├── FeatureToggle.NetFull.Tests.csproj ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── FeatureToggle.NetFull ├── FeatureToggle.NetFull.csproj └── Properties │ └── AssemblyInfo.cs ├── FeatureToggle.Shared.Tests ├── AlwaysOffFeatureToggleShould.cs ├── AlwaysOnFeatureToggleShould.cs ├── ApplicationResourcesSetter.cs ├── CompositeAndDecoratorShould.cs ├── CompositeOrDecoratorShould.cs ├── ConfigurationValidatorShould.cs ├── DefaultToDisabledOnErrorDecoratorShould.cs ├── DefaultToEnabledOnErrorDecoratorShould.cs ├── EnabledBetweenDatesFeatureToggleShould.cs ├── EnabledOnDaysOfWeekFeatureToggleShould.cs ├── EnabledOnOrAfterDateFeatureToggleShould.cs ├── EnabledOnOrBeforeDateFeatureToggleShould.cs ├── FallbackValueDecoratorShould.cs ├── FeatureToggle.Shared.Tests.projitems ├── FeatureToggle.Shared.Tests.shproj ├── Integration │ ├── AppSettingsProviderBooleanShould.cs │ ├── AppSettingsProviderDateTimeShould.cs │ ├── AppSettingsProviderForDaysOfWeekShould.cs │ ├── AppSettingsProviderTimePeriodShould.cs │ ├── ApplicationResourcesSettingsProviderShould.cs │ ├── BooleanHttpJsonProviderShould.cs │ ├── BooleanSqlServerProviderShould.cs │ ├── EnabledOnOrAfterToggleAssemblyVersionShould.cs │ ├── SqlServerSetup │ │ └── CreateLocalSqlExpressTestDb.sql │ └── TestApiServer │ │ ├── Startup.cs │ │ └── TestController.cs ├── IsShould.cs ├── RandomFeatureToggleShould.cs ├── RunOn.cs ├── SimpleCacheDecoratorShould.cs ├── SimpleFeatureToggleShould.cs ├── SqlFeatureToggleShould.cs └── TestToggles │ └── AnErroringToggle.cs ├── FeatureToggle.UAP.Tests ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png ├── FeatureToggle.UAP.Tests.csproj ├── FeatureToggle.UAP.Tests.nuget.props ├── FeatureToggle.UAP.Tests.nuget.targets ├── FeatureToggle.UAP.Tests_TemporaryKey.pfx ├── Package.appxmanifest ├── Properties │ ├── AssemblyInfo.cs │ └── UnitTestApp.rd.xml ├── TestHelpers │ └── RunOn.cs ├── UnitTestApp.xaml ├── UnitTestApp.xaml.cs └── project.json ├── FeatureToggle.UAP ├── FeatureToggle.UAP.csproj ├── Properties │ ├── AssemblyInfo.cs │ └── FeatureToggle.UAP.rd.xml └── project.json └── ManualNugetPackageTesting ├── AspNetCoreWebApplication ├── .bowerrc ├── AspNetCoreWebApplication.csproj ├── Controllers │ └── HomeController.cs ├── Model.cs ├── Printing.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Saving.cs ├── Startup.cs ├── Views │ ├── Home │ │ ├── About.cshtml │ │ ├── Contact.cshtml │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json ├── bower.json ├── bundleconfig.json └── wwwroot │ ├── css │ ├── site.css │ └── site.min.css │ ├── favicon.ico │ ├── images │ ├── banner1.svg │ ├── banner2.svg │ ├── banner3.svg │ └── banner4.svg │ ├── js │ ├── site.js │ └── site.min.js │ └── lib │ ├── bootstrap │ ├── .bower.json │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── npm.js │ ├── jquery-validation-unobtrusive │ ├── .bower.json │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── .bower.json │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── .bower.json │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── ManualNugetPackageCompatibiltyTesting.sln ├── NetCoreConsoleApp ├── Model.cs ├── NetCoreConsoleApp.csproj ├── Printing.cs ├── Program.cs ├── Saving.cs ├── Tweeting.cs └── appsettings.json ├── NetFullConsoleApp ├── App.config ├── Model.cs ├── NetFullConsoleApp.csproj ├── Printing.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Saving.cs └── packages.config └── UAPApp ├── App.xaml ├── App.xaml.cs ├── Assets ├── LockScreenLogo.scale-200.png ├── SplashScreen.scale-200.png ├── Square150x150Logo.scale-200.png ├── Square44x44Logo.scale-200.png ├── Square44x44Logo.targetsize-24_altform-unplated.png ├── StoreLogo.png └── Wide310x150Logo.scale-200.png ├── MainPage.xaml ├── MainPage.xaml.cs ├── Model.cs ├── Package.appxmanifest ├── Printing.cs ├── Properties ├── AssemblyInfo.cs └── Default.rd.xml ├── UAPApp.csproj ├── UAPApp_TemporaryKey.pfx └── project.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute to FeatureToggle 2 | 3 | This project welcomes contributions of source code, ideas, issues, and documentation. 4 | 5 | ## Getting Started 6 | 7 | * Make sure you have a [GitHub account](https://github.com/signup/free) 8 | * If you are new to Git and GitHub you might like to try [GitHub Desktop](https://desktop.github.com/) 9 | * Open an [issue](https://github.com/jason-roberts/FeatureToggle/issues) (or comment on an existing one) before starting work. Please do not submit pull requests (except for minor cosmetic faults) without discussing in an issue first. This is to make the most of your valuable time in case there is development in progress or other work planned. 10 | * Fork the repository on GitHub 11 | 12 | ## Making Changes 13 | 14 | * In your fork, create a well-named branch 15 | * Make your changes in this branch 16 | * Make one or more descriptive commits during your work 17 | * Please reference the the issue number in your commit if applicable by using a hash followed by the issue number 18 | * When making code changes, please ensure all tests still pass and new tests are added when needed 19 | 20 | ## Submitting Changes 21 | 22 | * Push your changes to your clone/branch 23 | * Submit a pull request -------------------------------------------------------------------------------- /ClearNuGetCaches.bat: -------------------------------------------------------------------------------- 1 | echo clearing local NuGet caches for manual nuget package testing 2 | 3 | nuget\nuget.exe locals all -clear 4 | 5 | pause -------------------------------------------------------------------------------- /NuGet/FeatureToggleNugetTestFeed/FeatureToggle.4.0.0-rc1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/NuGet/FeatureToggleNugetTestFeed/FeatureToggle.4.0.0-rc1.nupkg -------------------------------------------------------------------------------- /NuGet/FeatureToggleNugetTestFeed/FeatureToggle.4.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/NuGet/FeatureToggleNugetTestFeed/FeatureToggle.4.0.0.nupkg -------------------------------------------------------------------------------- /NuGet/FeatureToggleNugetTestFeed/FeatureToggle.NetStandard.4.0.0-rc1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/NuGet/FeatureToggleNugetTestFeed/FeatureToggle.NetStandard.4.0.0-rc1.nupkg -------------------------------------------------------------------------------- /NuGet/FeatureToggleNugetTestFeed/FeatureToggle.NetStandard.4.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/NuGet/FeatureToggleNugetTestFeed/FeatureToggle.NetStandard.4.0.0.nupkg -------------------------------------------------------------------------------- /NuGet/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/NuGet/NuGet.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FeatureToggle 2 | 3 | ## Simple, reliable feature toggles in .NET 4 | 5 | Install FeatureToggle easily via NuGet: 6 | 7 | PM> Install-Package FeatureToggle 8 | 9 | # [Release notes/versions](https://github.com/jason-roberts/FeatureToggle/blob/master/Release-Notes.md) 10 | # [Documentation](http://jason-roberts.github.io/FeatureToggle.Docs/) 11 | # [Pluralsight Feature Toggle Course](http://bit.ly/psfeaturetoggle) 12 | # [Twitter updates](https://twitter.com/robertsjason) 13 | 14 | 15 | 16 | [![Build status](https://ci.appveyor.com/api/projects/status/78q3e4vyihapl98w?svg=true)](https://ci.appveyor.com/project/jason-roberts/featuretoggle) [![NuGet](https://img.shields.io/nuget/v/FeatureToggle.svg)](https://www.nuget.org/packages/FeatureToggle) 17 | 18 | 19 | -------- 20 | 21 | ## About Jason Roberts 22 | 23 | Jason Roberts is a Microsoft MVP, [Pluralsight course author](http://bit.ly/psjasonroberts) with over 15 years experience. 24 | 25 | He is the author of the books [Clean C#](http://cleancsharp.com/), [C# Tips](http://bit.ly/sharpbook), and [Keeping Software Soft](http://keepingsoftwaresoft.com). He writes at his blog [DontCodeTired.com](http://dontcodetired.com) and on [Twitter](https://twitter.com/robertsjason) 26 | -------------------------------------------------------------------------------- /etc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/etc/logo.png -------------------------------------------------------------------------------- /etc/v4/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/etc/v4/logo.png -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/AspDotNetCoreExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp1.1 5 | 6 | 7 | 8 | $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using AspDotNetCoreExample.Models; 6 | using AspDotNetCoreExample.ViewModels; 7 | using ASPNetCoreExample.Models; 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | namespace AspDotNetCoreExample.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly Printing _print; 15 | private readonly Saving _save; 16 | 17 | public HomeController(Printing print, Saving save) 18 | { 19 | _print = print; 20 | _save = save; 21 | } 22 | 23 | public IActionResult Index() 24 | { 25 | return View(new HomeIndexViewModel { Printing = _print, Saving = _save }); 26 | } 27 | 28 | public IActionResult About() 29 | { 30 | ViewData["Message"] = "Your application description page."; 31 | 32 | return View(); 33 | } 34 | 35 | public IActionResult Contact() 36 | { 37 | ViewData["Message"] = "Your contact page."; 38 | 39 | return View(); 40 | } 41 | 42 | public IActionResult Error() 43 | { 44 | return View(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Models/Printing.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace AspDotNetCoreExample.Models 4 | { 5 | public class Printing : SimpleFeatureToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Models/Saving.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ASPNetCoreExample.Models 4 | { 5 | public class Saving : SimpleFeatureToggle {} 6 | } -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Hosting; 7 | 8 | namespace AspDotNetCoreExample 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | var host = new WebHostBuilder() 15 | .UseKestrel() 16 | .UseContentRoot(Directory.GetCurrentDirectory()) 17 | .UseIISIntegration() 18 | .UseStartup() 19 | .UseApplicationInsights() 20 | .Build(); 21 | 22 | host.Run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:7241/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "AspDotNetCoreExample": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:7242" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using AspDotNetCoreExample.Models; 6 | using ASPNetCoreExample.Models; 7 | using FeatureToggle.Internal; 8 | using Microsoft.AspNetCore.Builder; 9 | using Microsoft.AspNetCore.Hosting; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.Extensions.Logging; 13 | 14 | namespace AspDotNetCoreExample 15 | { 16 | public class Startup 17 | { 18 | public Startup(IHostingEnvironment env) 19 | { 20 | var builder = new ConfigurationBuilder() 21 | .SetBasePath(env.ContentRootPath) 22 | .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) 23 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) 24 | .AddEnvironmentVariables(); 25 | Configuration = builder.Build(); 26 | } 27 | 28 | public IConfigurationRoot Configuration { get; } 29 | 30 | // This method gets called by the runtime. Use this method to add services to the container. 31 | public void ConfigureServices(IServiceCollection services) 32 | { 33 | // Set provider config so file is read from content root path 34 | var provider = new AppSettingsProvider { Configuration = Configuration }; 35 | 36 | services.AddSingleton(new Printing { ToggleValueProvider = provider }); 37 | services.AddSingleton(new Saving { ToggleValueProvider = provider }); 38 | 39 | // Add framework services. 40 | services.AddMvc(); 41 | } 42 | 43 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 44 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 45 | { 46 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 47 | loggerFactory.AddDebug(); 48 | 49 | if (env.IsDevelopment()) 50 | { 51 | app.UseDeveloperExceptionPage(); 52 | app.UseBrowserLink(); 53 | } 54 | else 55 | { 56 | app.UseExceptionHandler("/Home/Error"); 57 | } 58 | 59 | app.UseStaticFiles(); 60 | 61 | app.UseMvc(routes => 62 | { 63 | routes.MapRoute( 64 | name: "default", 65 | template: "{controller=Home}/{action=Index}/{id?}"); 66 | }); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/ViewModels/HomeIndexViewModel.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace AspDotNetCoreExample.ViewModels 4 | { 5 | public class HomeIndexViewModel 6 | { 7 | public IFeatureToggle Printing { get; set; } 8 | 9 | public IFeatureToggle Saving { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model AspDotNetCoreExample.ViewModels.HomeIndexViewModel 2 | 3 | @{ 4 | ViewData["Title"] = "Home Page"; 5 | } 6 | 7 | @if (Model.Printing.FeatureEnabled) 8 | { 9 | 10 | } 11 | 12 | @if (Model.Saving.FeatureEnabled) 13 | { 14 | 15 | } 16 | 17 |

Notice that the save button is not visible

-------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | 8 |

Development Mode

9 |

10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

12 |

13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

15 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using AspDotNetCoreExample 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "FeatureToggle": { 3 | "Printing": "true", 4 | "Saving": "false" 5 | }, 6 | "Logging": { 7 | "IncludeScopes": false, 8 | "LogLevel": { 9 | "Default": "Warning" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.7", 6 | "jquery": "2.2.0", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Set widths on the form inputs since otherwise they're 100% wide */ 14 | input, 15 | select, 16 | textarea { 17 | max-width: 280px; 18 | } 19 | 20 | /* Carousel */ 21 | .carousel-caption p { 22 | font-size: 20px; 23 | line-height: 1.4; 24 | } 25 | 26 | /* Make .svg files in the carousel display properly in older browsers */ 27 | .carousel-inner .item img[src$=".svg"] { 28 | width: 100%; 29 | } 30 | 31 | /* Hide/rearrange for smaller screens */ 32 | @media screen and (max-width: 767px) { 33 | /* Hide captions */ 34 | .carousel-caption { 35 | display: none; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/AspDotNetCoreExample/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/AspDotNetCoreExample/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 3" 33 | }, 34 | "version": "3.3.7", 35 | "_release": "3.3.7", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.7", 39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86" 40 | }, 41 | "_source": "https://github.com/twbs/bootstrap.git", 42 | "_target": "v3.3.7", 43 | "_originalSource": "bootstrap", 44 | "_direct": true 45 | } -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "2.2.0", 16 | "_release": "2.2.0", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "2.2.0", 20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5" 21 | }, 22 | "_source": "git://github.com/jquery/jquery-dist.git", 23 | "_target": "2.2.0", 24 | "_originalSource": "jquery" 25 | } -------------------------------------------------------------------------------- /src/Examples/AspDotNetCoreExample/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/ConsoleAppDotNetCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp1.1 6 | 2.5.0.0 7 | 8 | 9 | 10 | 11 | PreserveNewest 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | PreserveNewest 23 | 24 | 25 | Always 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/Printing.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ConsoleAppDotNetCore 4 | { 5 | public class Printing : SimpleFeatureToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ConsoleAppDotNetCore 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var p = new Printing(); 10 | var s = new Saving(); 11 | var t = new Tweeting(); 12 | 13 | Console.WriteLine($"Printing is {(p.FeatureEnabled ? "on" : "off")}"); 14 | Console.WriteLine($"Saving is {(s.FeatureEnabled ? "on" : "off")}"); 15 | Console.WriteLine($"Tweeting is {(t.FeatureEnabled ? "on" : "off")}"); 16 | 17 | 18 | Console.ReadLine(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/Saving.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ConsoleAppDotNetCore 4 | { 5 | public class Saving : EnabledOnOrAfterDateFeatureToggle {} 6 | } -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/Tweeting.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ConsoleAppDotNetCore 4 | { 5 | public class Tweeting : EnabledOnOrAfterAssemblyVersionWhereToggleIsDefinedToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Examples/ConsoleAppDotNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "FeatureToggle": { 3 | "Printing": "true", 4 | "Saving": "01-Jan-2014 18:00:00", 5 | "Tweeting": "2.5.0.1" // Assembly version is set to 2.5.0.0 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ExampleWebFormsApplication.Default" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 | 13 |

Feature 1 - not toggled

14 | 15 | 16 |
17 | 18 |

Feature 2 - toggled using a SimpleFeatureToggle called Feature2Toggle

19 | 20 |

The feature2 button is not visible at runtime because it is disabled in the app config.

21 | 22 |
23 | 24 |

Feature 3 - toggled using a EnabledOnOrAfterDateFeatureToggle toggle called NewYears3000Feature

25 | 26 |

The NewYears3000Feature button is not visible at runtime because in in the app config the date is set to new years day 3000.

27 | 28 |
29 | 30 |

Feature 4 - toggled using a EnabledOnOrAfterDateFeatureToggle toggle called NewYears2000Feature

31 | 32 |

The NewYears2000Feature button is visible at runtime because in in the app config the date is set to new years day 2000.

33 | 34 |
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ExampleWebFormsApplication 4 | { 5 | public partial class Default : System.Web.UI.Page 6 | { 7 | protected void Page_Load(object sender, EventArgs e) 8 | { 9 | Feature2Button.Visible = new Feature2Toggle().FeatureEnabled; 10 | 11 | NewYears2000FeatureButton.Visible = new NewYears2000Feature().FeatureEnabled; 12 | 13 | NewYears3000FeatureButton.Visible = new NewYears3000Feature().FeatureEnabled; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace ExampleWebFormsApplication { 11 | 12 | 13 | public partial class Default { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// Feature2Button control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button Feature2Button; 32 | 33 | /// 34 | /// NewYears3000FeatureButton control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.Button NewYears3000FeatureButton; 41 | 42 | /// 43 | /// NewYears2000FeatureButton control. 44 | /// 45 | /// 46 | /// Auto-generated field. 47 | /// To modify move field declaration from designer file to code-behind file. 48 | /// 49 | protected global::System.Web.UI.WebControls.Button NewYears2000FeatureButton; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Feature2Toggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ExampleWebFormsApplication 4 | { 5 | public class Feature2Toggle : SimpleFeatureToggle{} 6 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/NewYears2000Feature.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ExampleWebFormsApplication 4 | { 5 | public class NewYears2000Feature : EnabledOnOrAfterDateFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/NewYears3000Feature.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | 4 | namespace ExampleWebFormsApplication 5 | { 6 | public class NewYears3000Feature : EnabledOnOrAfterDateFeatureToggle {} 7 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ExampleWebFormsApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ExampleWebFormsApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9398ec2b-b44e-4e19-bdf3-17f89f96ce8a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Examples/ExampleWebFormsApplication/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Windows; 5 | 6 | namespace ExampleWpfApplication 7 | { 8 | /// 9 | /// Interaction logic for App.xaml 10 | /// 11 | public partial class App : Application 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/BooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | using FeatureToggle; 6 | 7 | namespace ExampleWpfApplication 8 | { 9 | class BooleanToVisibilityConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var toggle = (IFeatureToggle) value; 14 | 15 | return toggle.FeatureEnabled ? Visibility.Visible : Visibility.Collapsed; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/Feature2Toggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ExampleWpfApplication 4 | { 5 | public class Feature2Toggle : SimpleFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/Feature3Toggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ExampleWpfApplication 4 | { 5 | public class Feature3Toggle : EnabledOnOrAfterDateFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/FeatureXToggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ExampleWpfApplication 4 | { 5 | public class FeatureXToggle : SimpleFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/FeatureYToggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace ExampleWpfApplication 4 | { 5 | public class FeatureYToggle : SimpleFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Note that the feature2 button is not visible at runtime because it is disabled in the app config. 13 | 14 | Note that the Feature 5 button is not visible at runtime because one of its "children" is disabled in the app config. 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | using FeatureToggle; 4 | 5 | namespace ExampleWpfApplication 6 | { 7 | public partial class MainWindow : Window, INotifyPropertyChanged 8 | { 9 | private Feature2Toggle _feature2Toggle; 10 | private Feature3Toggle _feature3Toggle; 11 | private IFeatureToggle _feature5; 12 | 13 | public MainWindow() 14 | { 15 | InitializeComponent(); 16 | 17 | Feature2Toggle = new Feature2Toggle(); 18 | Feature3Toggle = new Feature3Toggle(); 19 | 20 | Feature5 = new CompositeAndDecorator(new FeatureXToggle(), new FeatureYToggle()); 21 | 22 | DataContext = this; 23 | } 24 | 25 | public Feature2Toggle Feature2Toggle 26 | { 27 | get { return _feature2Toggle; } 28 | set 29 | { 30 | _feature2Toggle = value; 31 | Notify("Feature2Toggle"); 32 | } 33 | } 34 | 35 | public Feature3Toggle Feature3Toggle 36 | { 37 | get { return _feature3Toggle; } 38 | set 39 | { 40 | _feature3Toggle = value; 41 | Notify("Feature3Toggle"); 42 | } 43 | } 44 | 45 | 46 | 47 | public IFeatureToggle Feature5 48 | { 49 | get { return _feature5; } 50 | set 51 | { 52 | _feature5 = value; 53 | Notify("Feature5"); 54 | } 55 | } 56 | 57 | 58 | 59 | #region INotifyPropertyChanged Members 60 | 61 | public event PropertyChangedEventHandler PropertyChanged; 62 | 63 | #endregion 64 | 65 | private void Notify(string propertyName) 66 | { 67 | if (PropertyChanged != null) 68 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("ExampleWpfApplication")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("ExampleWpfApplication")] 15 | [assembly: AssemblyCopyright("Copyright © 2011")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ExampleWpfApplication.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.1.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Examples/ExampleWpfApplication/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Ensure the examples web service project (WebServicesForExamples) is up and running before running this WPF app -------------------------------------------------------------------------------- /src/Examples/UWP10Example/App.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | false 11 | 01-Jan-2014 18:00:00 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/StoreLogo.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Feature2Toggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace UWP10Example 4 | { 5 | public class Feature2Toggle : SimpleFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Feature3Toggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace UWP10Example 4 | { 5 | public class Feature3Toggle : EnabledOnOrAfterDateFeatureToggle { } 6 | } -------------------------------------------------------------------------------- /src/Examples/UWP10Example/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | Note that the feature2 button is not visible at runtime because it is disabled in the App.xaml config. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Examples/UWP10Example/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Windows.UI.Xaml.Controls; 3 | 4 | namespace UWP10Example 5 | { 6 | public sealed partial class MainPage : Page, INotifyPropertyChanged 7 | { 8 | private Feature2Toggle _feature2Toggle; 9 | private Feature3Toggle _feature3Toggle; 10 | 11 | public MainPage() 12 | { 13 | InitializeComponent(); 14 | 15 | Feature2Toggle = new Feature2Toggle(); 16 | Feature3Toggle = new Feature3Toggle(); 17 | 18 | DataContext = this; 19 | } 20 | 21 | public Feature2Toggle Feature2Toggle 22 | { 23 | get { return _feature2Toggle; } 24 | set 25 | { 26 | _feature2Toggle = value; 27 | Notify("Feature2Toggle"); 28 | } 29 | } 30 | 31 | public Feature3Toggle Feature3Toggle 32 | { 33 | get { return _feature3Toggle; } 34 | set 35 | { 36 | _feature3Toggle = value; 37 | Notify("Feature3Toggle"); 38 | } 39 | } 40 | 41 | 42 | #region INotifyPropertyChanged Members 43 | 44 | public event PropertyChangedEventHandler PropertyChanged; 45 | 46 | #endregion 47 | 48 | private void Notify(string propertyName) 49 | { 50 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | UWP10Example 7 | Admin 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UWP10Example")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UWP10Example")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /src/Examples/UWP10Example/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Examples/UWP10Example/UWP10Example_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Examples/UWP10Example/UWP10Example_TemporaryKey.pfx -------------------------------------------------------------------------------- /src/Examples/UWP10Example/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" 4 | }, 5 | "frameworks": { 6 | "uap10.0": {} 7 | }, 8 | "runtimes": { 9 | "win10-arm": {}, 10 | "win10-arm-aot": {}, 11 | "win10-x86": {}, 12 | "win10-x86-aot": {}, 13 | "win10-x64": {}, 14 | "win10-x64-aot": {} 15 | } 16 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/AlwaysOffFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle 2 | { 3 | public class AlwaysOffFeatureToggle : IFeatureToggle 4 | { 5 | public bool FeatureEnabled 6 | { 7 | get { return false; } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/AlwaysOnFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle 2 | { 3 | public class AlwaysOnFeatureToggle : IFeatureToggle 4 | { 5 | public bool FeatureEnabled 6 | { 7 | get { return true; } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/CompositeAndDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace FeatureToggle 5 | { 6 | public class CompositeAndDecorator : IFeatureToggle 7 | { 8 | public IFeatureToggle[] WrappedToggles { get; private set; } 9 | 10 | public CompositeAndDecorator(params IFeatureToggle[] togglesToWrap) 11 | { 12 | if (togglesToWrap == null) 13 | { 14 | throw new ArgumentNullException("togglesToWrap"); 15 | } 16 | 17 | if (!togglesToWrap.Any()) 18 | { 19 | throw new ArgumentOutOfRangeException("togglesToWrap", "At least one toggle must be supplied"); 20 | } 21 | 22 | WrappedToggles = togglesToWrap; 23 | } 24 | 25 | 26 | public bool FeatureEnabled 27 | { 28 | get 29 | { 30 | return WrappedToggles.All(x => x.FeatureEnabled); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/CompositeOrDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace FeatureToggle 5 | { 6 | public class CompositeOrDecorator : IFeatureToggle 7 | { 8 | public IFeatureToggle[] WrappedToggles { get; private set; } 9 | 10 | public CompositeOrDecorator(params IFeatureToggle[] togglesToWrap) 11 | { 12 | if (togglesToWrap == null) 13 | { 14 | throw new ArgumentNullException("togglesToWrap"); 15 | } 16 | 17 | if (!togglesToWrap.Any()) 18 | { 19 | throw new ArgumentOutOfRangeException("togglesToWrap", "At least one toggle must be supplied"); 20 | } 21 | 22 | WrappedToggles = togglesToWrap; 23 | } 24 | 25 | 26 | public bool FeatureEnabled 27 | { 28 | get 29 | { 30 | return WrappedToggles.Any(x => x.FeatureEnabled); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/ConfigurationDateParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace FeatureToggle 5 | { 6 | public class ConfigurationDateParser 7 | { 8 | private const string ExpectedDateFormat = @"dd-MMM-yyyy HH:mm:ss"; 9 | 10 | public DateTime ParseDateTimeConfigString(string valueToParse, string configKey) 11 | { 12 | try 13 | { 14 | return DateTime.ParseExact(valueToParse, ExpectedDateFormat, CultureInfo.InvariantCulture); 15 | } 16 | catch (Exception ex) 17 | { 18 | throw new ToggleConfigurationError( 19 | string.Format( 20 | "The value '{0}' cannot be converted to a DateTime as defined in config key '{1}'. The expected format is: {2}", 21 | valueToParse, configKey, ExpectedDateFormat), 22 | ex); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/ConfigurationValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public class ConfigurationValidator 6 | { 7 | public void ValidateStartAndEndDates(DateTime startDate, DateTime endDate, string toggleNameInConfig) 8 | { 9 | if (startDate >= endDate) 10 | throw new ToggleConfigurationError( 11 | string.Format("Configuration for {0} is invalid - the start date must be less then the end date", 12 | toggleNameInConfig)); 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/DefaultToDisabledOnErrorDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | /// 6 | /// This decorator should be used with care or not at all. It will essentially hide any configuration errors 7 | /// or other problems with the wrapped toggle knowing if it should enable the feature or not. 8 | /// This feature is provided as a response to a user request. 9 | /// 10 | public class DefaultToDisabledOnErrorDecorator : IFeatureToggle 11 | { 12 | private readonly Action _logAction; 13 | public IFeatureToggle Toggle { get; private set; } 14 | 15 | /// 16 | /// Decorator constructor that allows the wrapping of another toggle 17 | /// 18 | /// The toggle to wrap (decorate) 19 | /// Optional action that gets called if an exception is thrown by the wrapped toggle before returning enabled = false 20 | public DefaultToDisabledOnErrorDecorator(IFeatureToggle toggle, Action logAction = null) 21 | { 22 | Toggle = toggle; 23 | _logAction = logAction; 24 | } 25 | 26 | public bool FeatureEnabled 27 | { 28 | get 29 | { 30 | try 31 | { 32 | return Toggle.FeatureEnabled; 33 | } 34 | catch (Exception ex) 35 | { 36 | if (_logAction != null) 37 | { 38 | _logAction(ex); 39 | } 40 | 41 | return false; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/DefaultToEnabledOnErrorDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | /// 6 | /// This decorator should be used with care or not at all. It will essentially hide any configuration errors 7 | /// or other problems with the wrapped toggle knowing if it should enable the feature or not. 8 | /// This feature is provided as a response to a user request. 9 | /// 10 | public class DefaultToEnabledOnErrorDecorator : IFeatureToggle 11 | { 12 | private readonly Action _logAction; 13 | public IFeatureToggle Toggle { get; private set; } 14 | 15 | /// 16 | /// Decorator constructor that allows the wrapping of another toggle 17 | /// 18 | /// The toggle to wrap (decorate) 19 | /// Optional action that gets called if an exception is thrown by the wrapped toggle before returning enabled = true 20 | public DefaultToEnabledOnErrorDecorator(IFeatureToggle toggle, Action logAction = null) 21 | { 22 | Toggle = toggle; 23 | _logAction = logAction; 24 | } 25 | 26 | public bool FeatureEnabled 27 | { 28 | get 29 | { 30 | try 31 | { 32 | return Toggle.FeatureEnabled; 33 | } 34 | catch (Exception ex) 35 | { 36 | if (_logAction != null) 37 | { 38 | _logAction(ex); 39 | } 40 | 41 | return true; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/FallbackValueDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public class FallbackValueDecorator : IFeatureToggle 6 | { 7 | private readonly Action _logAction; 8 | 9 | public FallbackValueDecorator(IFeatureToggle primaryToggle, IFeatureToggle fallbackToggle, 10 | Action logAction = null) 11 | { 12 | if (primaryToggle == null) 13 | { 14 | throw new ArgumentNullException(nameof(primaryToggle)); 15 | } 16 | 17 | if (fallbackToggle == null) 18 | { 19 | throw new ArgumentNullException(nameof(fallbackToggle)); 20 | } 21 | 22 | PrimaryToggle = primaryToggle; 23 | FallbackToggle = fallbackToggle; 24 | _logAction = logAction; 25 | } 26 | 27 | public IFeatureToggle PrimaryToggle { get; } 28 | public IFeatureToggle FallbackToggle { get; } 29 | 30 | public bool FeatureEnabled 31 | { 32 | get 33 | { 34 | try 35 | { 36 | return PrimaryToggle.FeatureEnabled; 37 | } 38 | catch (Exception ex) 39 | { 40 | _logAction?.Invoke(ex); 41 | 42 | return FallbackToggle.FeatureEnabled; 43 | } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/FeatureToggle.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard1.4 5 | FeatureToggle 6 | 4.0.2 7 | False 8 | True 9 | Jason Roberts - dontcodetired.com 10 | 11 | 12 | Simple, reliable feature toggles in .NET. This is the .NET Standard package for the main FeatureToggle package. 13 | Copyright 2014-2017 Jason Roberts 14 | https://github.com/jason-roberts/FeatureToggle/blob/master/LICENSE.txt 15 | https://github.com/jason-roberts/FeatureToggle 16 | https://github.com/jason-roberts/FeatureToggle/raw/master/etc/v4/logo.png 17 | 18 | feature toggle branch merge featuretoggle cd continuous delivery 19 | For release notes and history see https://github.com/jason-roberts/FeatureToggle/blob/master/Release-Notes.md 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/FixedTimeCacheDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public class FixedTimeCacheDecorator : IFeatureToggle 6 | { 7 | private readonly TimeSpan _cacheDuration; 8 | private bool _cachedValue; 9 | 10 | public FixedTimeCacheDecorator(IFeatureToggle toggleToWrap, TimeSpan cacheDuration, 11 | Func alternativeNowProvider = null) 12 | { 13 | if (toggleToWrap == null) 14 | { 15 | throw new ArgumentNullException("toggleToWrap"); 16 | } 17 | 18 | WrappedToggle = toggleToWrap; 19 | 20 | _cacheDuration = cacheDuration; 21 | 22 | if (alternativeNowProvider == null) 23 | { 24 | NowProvider = () => DateTime.Now; 25 | } 26 | else 27 | { 28 | NowProvider = alternativeNowProvider; 29 | } 30 | 31 | SetCachedValue(); 32 | } 33 | 34 | public DateTime CachedValueLastUpdatedTime { get; private set; } 35 | public DateTime CacheExpiryTime { get; private set; } 36 | public IFeatureToggle WrappedToggle { get; private set; } 37 | public Func NowProvider { get; set; } 38 | 39 | public bool FeatureEnabled 40 | { 41 | get 42 | { 43 | var cacheHasExpired = NowProvider() > CacheExpiryTime; 44 | 45 | if (cacheHasExpired) 46 | { 47 | SetCachedValue(); 48 | } 49 | 50 | return _cachedValue; 51 | } 52 | } 53 | 54 | private void SetCachedValue() 55 | { 56 | _cachedValue = WrappedToggle.FeatureEnabled; 57 | 58 | CachedValueLastUpdatedTime = NowProvider(); 59 | CacheExpiryTime = CachedValueLastUpdatedTime.Add(_cacheDuration); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/IAssemblyVersionProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public interface IAssemblyVersionProvider 6 | { 7 | Version EvaluateVersion(IFeatureToggle toggle); 8 | } 9 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/IBooleanToggleValueProvider.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle 2 | { 3 | public interface IBooleanToggleValueProvider 4 | { 5 | bool EvaluateBooleanToggleValue(IFeatureToggle toggle); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/IDateTimeToggleValueProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public interface IDateTimeToggleValueProvider 6 | { 7 | DateTime EvaluateDateTimeToggleValue(IFeatureToggle toggle); 8 | } 9 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/IDaysOfWeekToggleValueProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace FeatureToggle 5 | { 6 | public interface IDaysOfWeekToggleValueProvider 7 | { 8 | IEnumerable GetDaysOfWeek(IFeatureToggle toggle); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/IFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle 2 | { 3 | public interface IFeatureToggle 4 | { 5 | bool FeatureEnabled {get;} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/ITimePeriodProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public interface ITimePeriodProvider 6 | { 7 | Tuple EvaluateTimePeriod(IFeatureToggle toggle); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/Is.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle 2 | { 3 | public static class Is where T : IFeatureToggle, new() 4 | { 5 | public static bool Enabled => new T().FeatureEnabled; 6 | public static bool Disabled => ! new T().FeatureEnabled; 7 | } 8 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/RandomFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public class RandomFeatureToggle : IFeatureToggle 6 | { 7 | public bool FeatureEnabled 8 | { 9 | get 10 | { 11 | return RandomGenerator.Next() % 2 == 0; 12 | } 13 | } 14 | 15 | 16 | // Based on: http://blogs.msdn.com/b/pfxteam/archive/2009/02/19/9434171.aspx 17 | static class RandomGenerator 18 | { 19 | private static readonly Random NonThreadLocalInstance = new Random(); 20 | 21 | [ThreadStatic] 22 | private static Random _threadLocalInstance; 23 | 24 | public static int Next() 25 | { 26 | var rnd = _threadLocalInstance; 27 | 28 | if (rnd != null) 29 | { 30 | return rnd.Next(); 31 | } 32 | 33 | int seed; 34 | 35 | lock (NonThreadLocalInstance) seed = NonThreadLocalInstance.Next(); 36 | 37 | _threadLocalInstance = rnd = new Random(seed); 38 | 39 | return rnd.Next(); 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Common/ToggleConfigurationError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FeatureToggle 4 | { 5 | public class ToggleConfigurationError : Exception 6 | { 7 | public ToggleConfigurationError(string message) : base(message) 8 | { 9 | } 10 | 11 | public ToggleConfigurationError(string message, Exception innerException) 12 | : base(message, innerException) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/FeatureToggle.Common/ToggleConfigurationSettings.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle 2 | { 3 | public static class ToggleConfigurationSettings 4 | { 5 | public static readonly string Prefix = "FeatureToggle."; 6 | } 7 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/EnabledBetweenDatesFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using FeatureToggle.Internal; 4 | 5 | namespace FeatureToggle 6 | { 7 | public abstract class EnabledBetweenDatesFeatureToggle : IFeatureToggle 8 | { 9 | 10 | protected EnabledBetweenDatesFeatureToggle() 11 | { 12 | NowProvider = () => DateTime.Now; 13 | #if WINDOWS_UWP 14 | 15 | ToggleValueProvider = new ApplicationResourcesSettingsProvider(); 16 | #else 17 | ToggleValueProvider = new AppSettingsProvider(); 18 | #endif 19 | } 20 | 21 | 22 | 23 | public Func NowProvider { get; set; } 24 | 25 | public virtual ITimePeriodProvider ToggleValueProvider { get; set; } 26 | 27 | 28 | public bool FeatureEnabled 29 | { 30 | get 31 | { 32 | var dates = ToggleValueProvider.EvaluateTimePeriod((this)); 33 | 34 | var now = NowProvider.Invoke(); 35 | 36 | return (now >= dates.Item1 && now <= dates.Item2); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/EnabledOnDaysOfWeekFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using FeatureToggle; 4 | using FeatureToggle.Internal; 5 | 6 | namespace FeatureToggle 7 | { 8 | public abstract class EnabledOnDaysOfWeekFeatureToggle : IFeatureToggle 9 | { 10 | 11 | protected EnabledOnDaysOfWeekFeatureToggle() 12 | { 13 | NowProvider = () => DateTime.Now; 14 | #if WINDOWS_UWP 15 | 16 | ToggleValueProvider = new ApplicationResourcesSettingsProvider(); 17 | #else 18 | ToggleValueProvider = new AppSettingsProvider(); 19 | #endif 20 | } 21 | 22 | 23 | 24 | public Func NowProvider { get; set; } 25 | 26 | public virtual IDaysOfWeekToggleValueProvider ToggleValueProvider { get; set; } 27 | 28 | 29 | public bool FeatureEnabled 30 | { 31 | get 32 | { 33 | var dayToday= NowProvider.Invoke().DayOfWeek; 34 | 35 | var daysShouldBeEnabled = ToggleValueProvider.GetDaysOfWeek(this); 36 | 37 | return daysShouldBeEnabled.Contains(dayToday); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/EnabledOnOrAfterAssemblyVersionWhereToggleIsDefinedToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using FeatureToggle; 4 | using FeatureToggle.Internal; 5 | 6 | // ReSharper disable CheckNamespace 7 | namespace FeatureToggle 8 | // ReSharper restore CheckNamespace 9 | { 10 | public abstract class EnabledOnOrAfterAssemblyVersionWhereToggleIsDefinedToggle : IFeatureToggle 11 | { 12 | public EnabledOnOrAfterAssemblyVersionWhereToggleIsDefinedToggle() 13 | { 14 | #if WINDOWS_UWP 15 | 16 | ToggleValueProvider = new ApplicationResourcesSettingsProvider(); 17 | #else 18 | ToggleValueProvider = new AppSettingsProvider(); 19 | #endif 20 | } 21 | 22 | public virtual IAssemblyVersionProvider ToggleValueProvider { get; set; } 23 | 24 | public bool FeatureEnabled 25 | { 26 | get 27 | { 28 | var assemblyVersionOfDerivedToggle = GetAssemblyVersionOfDerivedToggle(); 29 | 30 | Version configuredToggleVersion = GetConfiguredVersion(); 31 | 32 | 33 | return assemblyVersionOfDerivedToggle >= configuredToggleVersion; 34 | } 35 | } 36 | 37 | private Version GetAssemblyVersionOfDerivedToggle() 38 | { 39 | var assemblyName = this.GetType().GetTypeInfo().Assembly.FullName; 40 | 41 | var assembly = new AssemblyName(assemblyName); 42 | 43 | return assembly.Version; 44 | //#if WINDOWS_UWP 45 | 46 | // var assemblyName = this.GetType().GetTypeInfo().Assembly.FullName; 47 | 48 | // var assembly = new AssemblyName(assemblyName); 49 | 50 | // return assembly.Version; 51 | //#elif NETCORE 52 | 53 | // var assemblyName = this.GetType().GetTypeInfo().Assembly.FullName; 54 | 55 | // var assembly = new AssemblyName(assemblyName); 56 | 57 | // return assembly.Version; 58 | 59 | //#else 60 | // var assemblyName = this.GetType().GetTypeInfo().Assembly.FullName; 61 | // return new AssemblyName(GetType().Assembly.FullName).Version; 62 | 63 | //#endif 64 | } 65 | 66 | private Version GetConfiguredVersion() 67 | { 68 | return ToggleValueProvider.EvaluateVersion(this); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/EnabledOnOrAfterDateFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using FeatureToggle.Internal; 4 | 5 | namespace FeatureToggle 6 | { 7 | public abstract class EnabledOnOrAfterDateFeatureToggle : IFeatureToggle 8 | { 9 | 10 | protected EnabledOnOrAfterDateFeatureToggle() 11 | { 12 | NowProvider = () => DateTime.Now; 13 | #if WINDOWS_UWP 14 | 15 | ToggleValueProvider = new ApplicationResourcesSettingsProvider(); 16 | #else 17 | ToggleValueProvider = new AppSettingsProvider(); 18 | #endif 19 | } 20 | 21 | 22 | 23 | public Func NowProvider { get; set; } 24 | 25 | public virtual IDateTimeToggleValueProvider ToggleValueProvider { get; set; } 26 | 27 | 28 | public bool FeatureEnabled 29 | { 30 | get { return NowProvider.Invoke() >= ToggleValueProvider.EvaluateDateTimeToggleValue(this); } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/EnabledOnOrBeforeDateFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using FeatureToggle.Internal; 4 | 5 | namespace FeatureToggle 6 | { 7 | public abstract class EnabledOnOrBeforeDateFeatureToggle : IFeatureToggle 8 | { 9 | 10 | protected EnabledOnOrBeforeDateFeatureToggle() 11 | { 12 | NowProvider = () => DateTime.Now; 13 | #if WINDOWS_UWP 14 | 15 | ToggleValueProvider = new ApplicationResourcesSettingsProvider(); 16 | #else 17 | ToggleValueProvider = new AppSettingsProvider(); 18 | #endif 19 | } 20 | 21 | 22 | 23 | public Func NowProvider { get; set; } 24 | 25 | public virtual IDateTimeToggleValueProvider ToggleValueProvider { get; set; } 26 | 27 | 28 | public bool FeatureEnabled 29 | { 30 | get { return NowProvider.Invoke() <= ToggleValueProvider.EvaluateDateTimeToggleValue(this); } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/FeatureToggle.Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 8774f64c-a9d9-4405-bbdc-8ba34bd0f250 7 | 8 | 9 | FeatureToggle.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/FeatureToggle.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8774f64c-a9d9-4405-bbdc-8ba34bd0f250 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/FeatureToggleToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS_UWP 2 | 3 | using System; 4 | using Windows.UI.Xaml; 5 | using Windows.UI.Xaml.Data; 6 | 7 | 8 | // ReSharper disable CheckNamespace 9 | namespace FeatureToggle 10 | // ReSharper restore CheckNamespace 11 | { 12 | public class FeatureToggleToVisibilityConverter : IValueConverter 13 | { 14 | 15 | public object Convert(object value, Type targetType, object parameter, string language) 16 | { 17 | return EvaluateVisibility(value); 18 | } 19 | 20 | public object ConvertBack(object value, Type targetType, object parameter, string language) 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | 25 | 26 | private static object EvaluateVisibility(object value) 27 | { 28 | var toggle = (IFeatureToggle)value; 29 | 30 | return toggle.FeatureEnabled ? Visibility.Visible : Visibility.Collapsed; 31 | } 32 | 33 | } 34 | } 35 | #endif -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/HttpJsonFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL 2 | 3 | using System; 4 | using FeatureToggle; 5 | using FeatureToggle.Internal; 6 | 7 | namespace FeatureToggle 8 | { 9 | public abstract class HttpJsonFeatureToggle : IFeatureToggle 10 | { 11 | protected HttpJsonFeatureToggle() 12 | { 13 | ToggleValueProvider = new AppSettingsProvider(); 14 | } 15 | 16 | 17 | public virtual IBooleanToggleValueProvider ToggleValueProvider { get; set; } 18 | 19 | 20 | public bool FeatureEnabled 21 | { 22 | get 23 | { 24 | return ToggleValueProvider.EvaluateBooleanToggleValue(this); 25 | } 26 | } 27 | 28 | } 29 | } 30 | 31 | #endif -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/Internal/JsonEnabledResponse.cs: -------------------------------------------------------------------------------- 1 | namespace FeatureToggle.Internal 2 | { 3 | public class JsonEnabledResponse 4 | { 5 | public bool Enabled { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/SimpleFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using FeatureToggle.Internal; 4 | 5 | // ReSharper disable CheckNamespace 6 | namespace FeatureToggle 7 | // ReSharper restore CheckNamespace 8 | { 9 | public abstract class SimpleFeatureToggle : IFeatureToggle 10 | { 11 | protected SimpleFeatureToggle() 12 | { 13 | #if WINDOWS_UWP 14 | 15 | ToggleValueProvider = new ApplicationResourcesSettingsProvider(); 16 | #else 17 | ToggleValueProvider = new AppSettingsProvider(); 18 | #endif 19 | } 20 | 21 | 22 | public virtual IBooleanToggleValueProvider ToggleValueProvider { get; set; } 23 | 24 | 25 | public bool FeatureEnabled 26 | { 27 | get { return ToggleValueProvider.EvaluateBooleanToggleValue(this); } 28 | } 29 | 30 | public override string ToString() 31 | { 32 | return GetType().Name; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/FeatureToggle.Shared/SqlFeatureToggle.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL 2 | 3 | 4 | // TODO: net core sql support? 5 | using FeatureToggle.Internal; 6 | 7 | namespace FeatureToggle 8 | { 9 | public abstract class SqlFeatureToggle : IFeatureToggle 10 | { 11 | protected SqlFeatureToggle() 12 | { 13 | ToggleValueProvider = new BooleanSqlServerProvider(); 14 | } 15 | 16 | 17 | public virtual IBooleanToggleValueProvider ToggleValueProvider { get; set; } 18 | 19 | 20 | public bool FeatureEnabled 21 | { 22 | get { return ToggleValueProvider.EvaluateBooleanToggleValue(this); } 23 | } 24 | 25 | } 26 | } 27 | 28 | #endif -------------------------------------------------------------------------------- /src/FeatureToggle/Readme.txt: -------------------------------------------------------------------------------- 1 | This is a multi-targeted project that generates multiple platform binaries -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetCore.Tests/AppSettingsProviderShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using FeatureToggle.Internal; 4 | using Microsoft.Extensions.Configuration; 5 | using Xunit; 6 | 7 | namespace FeatureToggle.NetCore.Tests 8 | { 9 | public class AppSettingsProviderShould 10 | { 11 | 12 | [Fact] 13 | public void HaveDefaultConfiguration() 14 | { 15 | Assert.True(new A().FeatureEnabled); 16 | } 17 | 18 | [Fact] 19 | public void SetOptionalConfiguration() 20 | { 21 | var customConfig = BuildCustomConfig(); 22 | 23 | var sut = new AppSettingsProvider{Configuration = customConfig}; 24 | 25 | Assert.Same(customConfig, sut.Configuration); 26 | } 27 | 28 | [Fact] 29 | public void UseOptionalConfigurationWhenReadingConfigValues() 30 | { 31 | var provider = new AppSettingsProvider{Configuration = BuildCustomConfig()}; 32 | 33 | var b = new B(); 34 | b.ToggleValueProvider = provider; 35 | 36 | Assert.True(b.FeatureEnabled); 37 | } 38 | 39 | private IConfigurationRoot BuildCustomConfig() 40 | { 41 | string testDir = System.IO.Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location); 42 | var builder = new ConfigurationBuilder().SetBasePath(testDir).AddJsonFile("customSettings.json"); 43 | IConfigurationRoot customConfig = builder.Build(); 44 | return customConfig; 45 | } 46 | 47 | class A : SimpleFeatureToggle {} 48 | class B : SimpleFeatureToggle {} 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetCore.Tests/FeatureToggle.NetCore.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp1.0 5 | 0.0.2.1 6 | 7 | 8 | 9 | TRACE;DEBUG;NETCOREAPP1_0;NETCORE 10 | 11 | 12 | 13 | TRACE;RELEASE;NETCOREAPP1_0;NETCORE 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Always 44 | 45 | 46 | Always 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetCore.Tests/SolutionPathUtility.cs: -------------------------------------------------------------------------------- 1 | #if NETCORE 2 | 3 | using System; 4 | using System.IO; 5 | using System.Reflection; 6 | using Microsoft.Extensions.PlatformAbstractions; 7 | 8 | namespace FeatureToggle.NetCore.Tests 9 | { 10 | // Original code from: https://github.com/aspnet/Mvc 11 | public static class SolutionPathUtility 12 | { 13 | private const string SolutionName = "FeatureToggle.sln"; 14 | 15 | /// 16 | /// Gets the full path to the project. 17 | /// 18 | /// 19 | /// The parent directory of the project. 20 | /// e.g. samples, test, or test/Websites 21 | /// 22 | /// The project's assembly. 23 | /// The full path to the project. 24 | public static string GetProjectPath(string solutionRelativePath, Assembly assembly) 25 | { 26 | var projectName = assembly.GetName().Name; 27 | var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath; 28 | 29 | var directoryInfo = new DirectoryInfo(applicationBasePath); 30 | do 31 | { 32 | var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName)); 33 | if (solutionFileInfo.Exists) 34 | { 35 | return Path.GetFullPath(Path.Combine(directoryInfo.FullName, solutionRelativePath, projectName)); 36 | } 37 | 38 | directoryInfo = directoryInfo.Parent; 39 | } 40 | while (directoryInfo.Parent != null); 41 | 42 | throw new Exception($"Solution root could not be located using application root {applicationBasePath}."); 43 | } 44 | } 45 | } 46 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetCore.Tests/appSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "FeatureToggle": { 3 | "A": "true", 4 | // simple toggles 5 | "SimpleFeatureTrue": "true", 6 | "SimpleFeatureFalse": "false", 7 | "BeforeDate": "02-Jan-2050 04:05:08", 8 | "TimePeriod": "02-Jan-2050 04:05:08 | 07-Aug-2099 06:05:04", 9 | // erroneous toggles 10 | "NotABooleanValue": "cefwefwecwdcw", 11 | "StartDateAfterEndDate": "02-Jan-2050 04:05:10 | 02-Jan-2050 04:05:09", 12 | "InvalidDateFormat": "02/01/2050 04:05:10", 13 | "StartDateAndEndDateAreTheSame": "02-Jan-2050 04:05:09 | 02-Jan-2050 04:05:09", 14 | "FormatInConfigIsWrong": "01-Jan-2050 04:05:09 | 02/01/2050 04:05:44", 15 | // Days of week toggles 16 | "MondayAndFridayToggle": "Monday, Friday", 17 | "InvalidDayToggle": "Monday, Sun", 18 | 19 | // Version toggles 20 | "MyVersionToggleFor_v0_0_2_0": "0.0.2.0", 21 | "MyVersionToggleFor_v0_0_2_1": "0.0.2.1", 22 | "MyVersionToggleFor_v0_0_2_2": "0.0.2.2" 23 | } 24 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetCore.Tests/customSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "FeatureToggle": { 3 | "B": "true" 4 | } 5 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetCore/FeatureToggle.NetCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp1.0 5 | 6 | 7 | 8 | TRACE;DEBUG;NETCOREAPP1_0;NETCORE 9 | 10 | 11 | 12 | TRACE;RELEASE;NETCOREAPP1_0;NETCORE 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetFull.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FeatureToggle.NetFull.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FeatureToggle.NetFull.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("93852865-148e-4a38-a34c-878b1650c4de")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.0.2.1")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetFull.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.NetFull/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FeatureToggle.NetFull")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FeatureToggle.NetFull")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2368c117-6f0f-439b-8ed8-0b3b3adb1d31")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/AlwaysOffFeatureToggleShould.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | using Xunit; 3 | 4 | namespace FeatureToggle.Shared.Tests 5 | { 6 | public class AlwaysOffFeatureToggleShould 7 | { 8 | [Fact] 9 | public void ReturnAlwaysOff() 10 | { 11 | var sut = new MyAlwaysOffFeatureToggle(); 12 | 13 | Assert.False(sut.FeatureEnabled); 14 | } 15 | 16 | private class MyAlwaysOffFeatureToggle : AlwaysOffFeatureToggle {} 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/AlwaysOnFeatureToggleShould.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | using Xunit; 3 | 4 | namespace FeatureToggle.Shared.Tests 5 | { 6 | public class AlwaysOnFeatureToggleShould 7 | { 8 | [Fact] 9 | public void ReturnAlwaysOn() 10 | { 11 | var sut = new MyAlwaysOnFeatureToggle(); 12 | 13 | Assert.True(sut.FeatureEnabled); 14 | } 15 | 16 | private class MyAlwaysOnFeatureToggle : AlwaysOnFeatureToggle {} 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/ApplicationResourcesSetter.cs: -------------------------------------------------------------------------------- 1 | #if NETFX_CORE 2 | 3 | using Windows.UI.Xaml; 4 | // ReSharper disable CheckNamespace 5 | namespace FeatureToggle.Shared.Tests 6 | // ReSharper restore CheckNamespace 7 | { 8 | /// 9 | /// Used to set resources in XAML/UWP app so that tests can configure resource values 10 | /// 11 | public static class ApplicationResourcesSetter 12 | { 13 | public static void Set(string key, object value) 14 | { 15 | Application.Current.Resources[key] = value; 16 | } 17 | } 18 | } 19 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/CompositeAndDecoratorShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using Xunit; 4 | 5 | namespace FeatureToggle.Tests 6 | { 7 | public class CompositeAndDecoratorShould 8 | { 9 | [Fact] 10 | public void ReturnFalseWhenOneWrappedToggleIsDisabled() 11 | { 12 | var sut = new CompositeAndDecorator(new AnEnabledFeature(), new ADisabledFeature()); 13 | 14 | Assert.False(sut.FeatureEnabled); 15 | } 16 | 17 | 18 | [Fact] 19 | public void ReturnFalseWhenAllWrappedTogglesAreDisabled() 20 | { 21 | var sut = new CompositeAndDecorator(new ADisabledFeature(), new AnotherDisabledFeature()); 22 | 23 | Assert.False(sut.FeatureEnabled); 24 | } 25 | 26 | 27 | [Fact] 28 | public void ReturnTrueWhenAllWrappedTogglesAreEnabled() 29 | { 30 | var sut = new CompositeAndDecorator(new AnEnabledFeature(), new AnotherEnabledFeature()); 31 | 32 | Assert.True(sut.FeatureEnabled); 33 | } 34 | 35 | 36 | [Fact] 37 | public void ErrorWhenNullWrappedTogglesSupplied() 38 | { 39 | Assert.Throws(() => new CompositeAndDecorator(null)); 40 | } 41 | 42 | 43 | [Fact] 44 | public void ErrorWhenNoWrappedTogglesSupplied() 45 | { 46 | Assert.Throws(() => new CompositeAndDecorator()); 47 | } 48 | 49 | 50 | 51 | private class AnEnabledFeature : AlwaysOnFeatureToggle {} 52 | private class AnotherEnabledFeature : AlwaysOnFeatureToggle {} 53 | private class ADisabledFeature : AlwaysOffFeatureToggle {} 54 | private class AnotherDisabledFeature : AlwaysOffFeatureToggle {} 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/CompositeOrDecoratorShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using Xunit; 4 | 5 | namespace FeatureToggle.Tests 6 | { 7 | public class CompositeOrDecoratorShould 8 | { 9 | [Fact] 10 | public void ReturnTrueWhenOneWrappedToggleIsDisabled() 11 | { 12 | var sut = new CompositeOrDecorator(new AnEnabledFeature(), new ADisabledFeature()); 13 | 14 | Assert.True(sut.FeatureEnabled); 15 | } 16 | 17 | 18 | [Fact] 19 | public void ReturnFalseWhenAllWrappedTogglesAreDisabled() 20 | { 21 | var sut = new CompositeOrDecorator(new ADisabledFeature(), new AnotherDisabledFeature()); 22 | 23 | Assert.False(sut.FeatureEnabled); 24 | } 25 | 26 | 27 | [Fact] 28 | public void ReturnTrueWhenAllWrappedTogglesAreEnabled() 29 | { 30 | var sut = new CompositeOrDecorator(new AnEnabledFeature(), new AnotherEnabledFeature()); 31 | 32 | Assert.True(sut.FeatureEnabled); 33 | } 34 | 35 | 36 | [Fact] 37 | public void ErrorWhenNullWrappedTogglesSupplied() 38 | { 39 | Assert.Throws(() => new CompositeOrDecorator(null)); 40 | } 41 | 42 | 43 | [Fact] 44 | public void ErrorWhenNoWrappedTogglesSupplied() 45 | { 46 | Assert.Throws(() => new CompositeOrDecorator()); 47 | } 48 | 49 | 50 | 51 | private class AnEnabledFeature : AlwaysOnFeatureToggle {} 52 | private class AnotherEnabledFeature : AlwaysOnFeatureToggle {} 53 | private class ADisabledFeature : AlwaysOffFeatureToggle {} 54 | private class AnotherDisabledFeature : AlwaysOffFeatureToggle {} 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/ConfigurationValidatorShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using Xunit; 4 | 5 | namespace FeatureToggle.Tests 6 | { 7 | public class ConfigurationValidatorShould 8 | { 9 | [Fact] 10 | public void ErrorWhenStartDateAfterEndDate() 11 | { 12 | var sut = new ConfigurationValidator(); 13 | 14 | var ex = Assert.Throws( 15 | () => sut.ValidateStartAndEndDates(DateTime.MinValue.AddMilliseconds(1), DateTime.MinValue, "FeatureToggle.StartDateAfterEndDate")); 16 | 17 | Assert.Equal( 18 | "Configuration for FeatureToggle.StartDateAfterEndDate is invalid - the start date must be less then the end date", 19 | ex.Message); 20 | } 21 | 22 | [Fact] 23 | public void ErrorWhenStartDateAndEndDateAreTheSame() 24 | { 25 | var sut = new ConfigurationValidator(); 26 | 27 | var ex = Assert.Throws( 28 | () => sut.ValidateStartAndEndDates(DateTime.MinValue, DateTime.MinValue, "FeatureToggle.StartDateAfterEndDate")); 29 | 30 | Assert.Equal( 31 | "Configuration for FeatureToggle.StartDateAfterEndDate is invalid - the start date must be less then the end date", 32 | ex.Message); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/DefaultToDisabledOnErrorDecoratorShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | // ReSharper disable CheckNamespace 5 | namespace FeatureToggle.Tests 6 | // ReSharper restore CheckNamespace 7 | { 8 | public class DefaultToDisabledOnErrorDecoratorShould 9 | { 10 | [Fact] 11 | public void ReturnFalseWhenError() 12 | { 13 | var sut = new DefaultToDisabledOnErrorDecorator(new FeatureToggleThatThrowsAnException()); 14 | 15 | Assert.False(sut.FeatureEnabled); 16 | } 17 | 18 | 19 | [Fact] 20 | public void ReturnConfiguredValueWhenNoError() 21 | { 22 | var sut = new DefaultToDisabledOnErrorDecorator(new FeatureToggleThatDoesNotThrowAnException()); 23 | 24 | Assert.False(sut.FeatureEnabled); 25 | } 26 | 27 | 28 | [Fact] 29 | public void AllowAccessToWrappedToggle() 30 | { 31 | var wrappedToggle = new FeatureToggleThatDoesNotThrowAnException(); 32 | 33 | var sut = new DefaultToDisabledOnErrorDecorator(wrappedToggle); 34 | 35 | Assert.Same(wrappedToggle, sut.Toggle); 36 | } 37 | 38 | 39 | [Fact] 40 | public void CallLoggingActionOnErrorIfSet() 41 | { 42 | var wrappedToggle = new FeatureToggleThatThrowsAnException(); 43 | 44 | string log = ""; 45 | 46 | var sut = new DefaultToDisabledOnErrorDecorator(wrappedToggle, ex => log += ex.Message); 47 | 48 | 49 | 50 | try 51 | { 52 | var isEnabled = sut.FeatureEnabled; 53 | } 54 | catch 55 | { 56 | // ignore exception so we can assert that the specified action was called 57 | } 58 | 59 | 60 | 61 | Assert.Equal("Exception for testing purposes", log); 62 | } 63 | 64 | 65 | private class FeatureToggleThatThrowsAnException : IFeatureToggle { 66 | public bool FeatureEnabled 67 | { 68 | get 69 | { 70 | throw new Exception("Exception for testing purposes"); 71 | } 72 | } 73 | } 74 | 75 | 76 | private class FeatureToggleThatDoesNotThrowAnException : IFeatureToggle 77 | { 78 | public bool FeatureEnabled 79 | { 80 | get { return false; } 81 | } 82 | } 83 | 84 | } 85 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/DefaultToEnabledOnErrorDecoratorShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using Xunit; 4 | 5 | namespace FeatureToggle.Tests 6 | { 7 | public class DefaultToEnabledOnErrorDecoratorShould 8 | { 9 | [Fact] 10 | public void ReturnTrueWhenError() 11 | { 12 | var sut = new DefaultToEnabledOnErrorDecorator(new FeatureToggleThatThrowsAnException()); 13 | 14 | Assert.True(sut.FeatureEnabled); 15 | } 16 | 17 | 18 | [Fact] 19 | public void ReturnConfiguredValueWhenNoError() 20 | { 21 | var sut = new DefaultToEnabledOnErrorDecorator(new FeatureToggleThatDoesNotThrowAnException()); 22 | 23 | Assert.True(sut.FeatureEnabled); 24 | } 25 | 26 | 27 | [Fact] 28 | public void AllowAccessToWrappedToggle() 29 | { 30 | var wrappedToggle = new FeatureToggleThatDoesNotThrowAnException(); 31 | 32 | var sut = new DefaultToEnabledOnErrorDecorator(wrappedToggle); 33 | 34 | Assert.Same(wrappedToggle, sut.Toggle); 35 | } 36 | 37 | 38 | [Fact] 39 | public void CallLoggingActionOnErrorIfSet() 40 | { 41 | var wrappedToggle = new FeatureToggleThatThrowsAnException(); 42 | 43 | string log = ""; 44 | 45 | var sut = new DefaultToEnabledOnErrorDecorator(wrappedToggle, ex => log += ex.Message); 46 | 47 | 48 | 49 | try 50 | { 51 | var isEnabled = sut.FeatureEnabled; 52 | } 53 | catch 54 | { 55 | // ignore exception so we can assert that the specified action was called 56 | } 57 | 58 | 59 | 60 | Assert.Equal("Exception for testing purposes", log); 61 | } 62 | 63 | 64 | private class FeatureToggleThatThrowsAnException : IFeatureToggle { 65 | public bool FeatureEnabled 66 | { 67 | get 68 | { 69 | throw new Exception("Exception for testing purposes"); 70 | } 71 | } 72 | } 73 | 74 | 75 | private class FeatureToggleThatDoesNotThrowAnException : IFeatureToggle 76 | { 77 | public bool FeatureEnabled 78 | { 79 | get { return true; } 80 | } 81 | } 82 | 83 | } 84 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/EnabledOnDaysOfWeekFeatureToggleShould.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL || NETCORE // no Moq support in UWP test projects 2 | 3 | using System; 4 | using FeatureToggle; 5 | using FeatureToggle.Internal; 6 | using Moq; 7 | using Xunit; 8 | 9 | namespace FeatureToggle.Tests 10 | { 11 | public class EnabledOnDaysOfWeekFeatureToggleShould 12 | { 13 | 14 | [Fact] 15 | public void HaveDefaultProvider() 16 | { 17 | var sut = new MyEnabledOnDaysFeatureToggle(); 18 | 19 | Assert.Equal(typeof(AppSettingsProvider), sut.ToggleValueProvider.GetType()); 20 | } 21 | 22 | [Fact] 23 | public void BeEnabledOnlyOnSpecifiedDaysOfWeek() 24 | { 25 | var aMonday = new DateTime(2014, 6, 2); 26 | var aFriday = new DateTime(2014, 6, 6); 27 | var aSaturday= new DateTime(2014, 6, 7); 28 | 29 | var fakeToggleValueProvider = new Mock(); 30 | 31 | fakeToggleValueProvider.Setup(x => x.GetDaysOfWeek(It.IsAny())) 32 | .Returns(new[] {DayOfWeek.Monday, DayOfWeek.Friday}); 33 | 34 | var sut = new MyEnabledOnDaysFeatureToggle 35 | { 36 | ToggleValueProvider = fakeToggleValueProvider.Object, 37 | }; 38 | 39 | sut.NowProvider = () => aMonday; 40 | Assert.True(sut.FeatureEnabled); 41 | 42 | sut.NowProvider = () => aFriday; 43 | Assert.True(sut.FeatureEnabled); 44 | 45 | sut.NowProvider = () => aSaturday; 46 | Assert.False(sut.FeatureEnabled); 47 | } 48 | 49 | 50 | private class MyEnabledOnDaysFeatureToggle : EnabledOnDaysOfWeekFeatureToggle { } 51 | } 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/FallbackValueDecoratorShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using FeatureToggle.Shared.Tests.TestToggles; 4 | using Xunit; 5 | 6 | namespace FeatureToggle.Tests 7 | { 8 | public class FallbackValueDecoratorShould 9 | { 10 | [Fact] 11 | public void ReturnValueOfPrimaryToggleIfAvailable() 12 | { 13 | var sut = new FallbackValueDecorator(new AnEnabledFeature(), new ADisabledFeature()); 14 | 15 | Assert.True(sut.FeatureEnabled); 16 | } 17 | 18 | 19 | [Fact] 20 | public void ReturnValueOfFallbackToggleIfPrimaryToggleNotConfiguredOrErrors() 21 | { 22 | var sut = new FallbackValueDecorator(new AnErroringToggle(), new AnEnabledFeature()); 23 | 24 | Assert.True(sut.FeatureEnabled); 25 | } 26 | 27 | 28 | [Fact] 29 | public void ErrorIfFallbackToggleErrors() 30 | { 31 | var sut = new FallbackValueDecorator(new AnErroringToggle(), new AnErroringToggle()); 32 | 33 | Assert.Throws(() => sut.FeatureEnabled); 34 | } 35 | 36 | 37 | [Fact] 38 | public void ErrorWhenNullPrimaryToggleSupplied() 39 | { 40 | Assert.Throws(() => new FallbackValueDecorator(null, new AnErroringToggle())); 41 | } 42 | 43 | 44 | [Fact] 45 | public void ErrorWhenNullFallbackToggleSupplied() 46 | { 47 | Assert.Throws(() => new FallbackValueDecorator(new AnEnabledFeature(), null)); 48 | } 49 | 50 | 51 | [Fact] 52 | public void CallLoggingActionOnPrimaryToggleFailIfConfigured() 53 | { 54 | var actionWasCalled = false; 55 | 56 | var sut = new FallbackValueDecorator(new AnErroringToggle(), new AnEnabledFeature(), 57 | ex => actionWasCalled = true); 58 | 59 | var isEnabled = sut.FeatureEnabled; 60 | 61 | Assert.True(actionWasCalled); 62 | } 63 | 64 | 65 | private class AnEnabledFeature : AlwaysOnFeatureToggle 66 | { 67 | } 68 | 69 | private class ADisabledFeature : AlwaysOffFeatureToggle 70 | { 71 | } 72 | 73 | 74 | } 75 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/FeatureToggle.Shared.Tests.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ed6bd629-1d2b-4acf-9ad4-23666285ad93 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/AppSettingsProviderBooleanShould.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL || NETCORE 2 | 3 | using System; 4 | using FeatureToggle; 5 | using FeatureToggle.Internal; 6 | using Xunit; 7 | 8 | namespace FeatureToggle.Shared.Tests.Integration 9 | { 10 | public class AppSettingsProviderBooleanShould 11 | { 12 | [Fact] 13 | public void ReadBooleanTrueFromConfig() 14 | { 15 | Assert.True(new AppSettingsProvider().EvaluateBooleanToggleValue(new SimpleFeatureTrue())); 16 | } 17 | 18 | 19 | [Fact] 20 | public void ReadBooleanFalseFromConfig() 21 | { 22 | Assert.False(new AppSettingsProvider().EvaluateBooleanToggleValue(new SimpleFeatureFalse())); 23 | } 24 | 25 | 26 | [Fact] 27 | public void ErrorWhenCannotConvertConfig() 28 | { 29 | var ex = Assert.Throws( 30 | () => 31 | new AppSettingsProvider().EvaluateBooleanToggleValue(new NotABooleanValue())); 32 | 33 | Assert.Equal(typeof(FormatException), ex.InnerException.GetType()); 34 | } 35 | 36 | 37 | [Fact] 38 | public void ErrorWhenKeyNotInConfig() 39 | { 40 | Assert.Throws( 41 | () => 42 | new AppSettingsProvider().EvaluateBooleanToggleValue(new NotInConfig())); 43 | } 44 | 45 | 46 | private class NotABooleanValue : SimpleFeatureToggle 47 | { 48 | } 49 | 50 | private class NotInConfig : SimpleFeatureToggle 51 | { 52 | } 53 | 54 | private class SimpleFeatureFalse : SimpleFeatureToggle 55 | { 56 | } 57 | 58 | private class SimpleFeatureTrue : SimpleFeatureToggle 59 | { 60 | } 61 | } 62 | } 63 | 64 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/AppSettingsProviderDateTimeShould.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL || NETCORE 2 | 3 | using System; 4 | //using System.Configuration; 5 | using FeatureToggle; 6 | using FeatureToggle.Internal; 7 | using Xunit; 8 | 9 | namespace FeatureToggle.Shared.Tests.Integration 10 | { 11 | public class AppSettingsProviderDateTimeShould 12 | { 13 | [Fact] 14 | public void ReadDate() 15 | { 16 | var sut = new AppSettingsProvider(); 17 | 18 | var result = sut.EvaluateDateTimeToggleValue(new BeforeDate()); 19 | 20 | var expected = new DateTime(2050, 1, 2, 4, 5, 8); 21 | 22 | Assert.Equal(result, expected); 23 | } 24 | 25 | [Fact] 26 | public void ErrorWhenBadDateFormat() 27 | { 28 | var ex = Assert.Throws( 29 | () => new AppSettingsProvider().EvaluateDateTimeToggleValue(new InvalidDateFormat())); 30 | 31 | Assert.Equal(typeof(FormatException), ex.InnerException.GetType()); 32 | } 33 | 34 | 35 | private class BeforeDate : EnabledOnOrBeforeDateFeatureToggle 36 | { 37 | }; 38 | 39 | private class InvalidDateFormat : EnabledOnOrAfterDateFeatureToggle 40 | { 41 | }; 42 | 43 | 44 | 45 | 46 | 47 | } 48 | } 49 | 50 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/AppSettingsProviderForDaysOfWeekShould.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL || NETCORE 2 | 3 | using System; 4 | using System.Linq; 5 | using FeatureToggle.Internal; 6 | using Xunit; 7 | 8 | namespace FeatureToggle.Shared.Tests.Integration 9 | { 10 | public class AppSettingsProviderForDaysOfWeekShould 11 | { 12 | [Fact] 13 | public void ReadDaysTimePeriod() 14 | { 15 | IDaysOfWeekToggleValueProvider sut = new AppSettingsProvider(); 16 | 17 | var daysFromConfig = sut.GetDaysOfWeek(new MondayAndFridayToggle()); 18 | 19 | var expected = new[] {DayOfWeek.Monday, DayOfWeek.Friday}; 20 | 21 | Assert.Equal(expected, daysFromConfig); 22 | } 23 | 24 | 25 | [Fact] 26 | public void InvalidDayInConfig() 27 | { 28 | var sut = new AppSettingsProvider(); 29 | 30 | var ex = Assert.Throws(() => sut.GetDaysOfWeek(new InvalidDayToggle()).ToList()); 31 | #if NETCORE 32 | Assert.Equal("The value 'Sun' in config key 'InvalidDayToggle' is not a valid day of the week. Days should be specified in long format. E.g. Friday and not Fri.", ex.Message); 33 | #else 34 | Assert.Equal("The value 'Sun' in config key 'FeatureToggle.InvalidDayToggle' is not a valid day of the week. Days should be specified in long format. E.g. Friday and not Fri.", ex.Message); 35 | #endif 36 | } 37 | 38 | 39 | [Fact] 40 | public void ErrorWhenKeyNotInConfig() 41 | { 42 | Assert.Throws( 43 | () => 44 | new AppSettingsProvider().GetDaysOfWeek(new NotInConfig()).ToList()); 45 | } 46 | 47 | 48 | private class MondayAndFridayToggle : EnabledOnDaysOfWeekFeatureToggle {} 49 | private class InvalidDayToggle : EnabledOnDaysOfWeekFeatureToggle {} 50 | private class NotInConfig : EnabledOnDaysOfWeekFeatureToggle {} 51 | 52 | 53 | } 54 | } 55 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/AppSettingsProviderTimePeriodShould.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL || NETCORE 2 | 3 | 4 | using System; 5 | //using FeatureToggle; 6 | using FeatureToggle.Internal; 7 | using Xunit; 8 | 9 | namespace FeatureToggle.Shared.Tests.Integration 10 | { 11 | public class AppSettingsProviderTimePeriodShould 12 | { 13 | [Fact] 14 | public void ReadTimePeriod() 15 | { 16 | ITimePeriodProvider sut = new AppSettingsProvider(); 17 | 18 | var periodFromConfig = sut.EvaluateTimePeriod(new TimePeriod()); 19 | 20 | var expected = new Tuple(new DateTime(2050, 1, 2, 4, 5, 8), 21 | new DateTime(2099, 8, 7, 6, 5, 4)); 22 | 23 | Assert.Equal(expected, periodFromConfig); 24 | } 25 | 26 | 27 | [Fact] 28 | public void ErrorWhenEndDateFormatIsWrong() 29 | { 30 | var ex = Assert.Throws( 31 | () => 32 | new AppSettingsProvider().EvaluateTimePeriod( 33 | new FormatInConfigIsWrong())); 34 | #if NETCORE 35 | Assert.Equal( 36 | "The value '02/01/2050 04:05:44' cannot be converted to a DateTime as defined in config key 'FormatInConfigIsWrong'. The expected format is: dd-MMM-yyyy HH:mm:ss", 37 | ex.Message); 38 | #else 39 | Assert.Equal( 40 | "The value '02/01/2050 04:05:44' cannot be converted to a DateTime as defined in config key 'FeatureToggle.FormatInConfigIsWrong'. The expected format is: dd-MMM-yyyy HH:mm:ss", 41 | ex.Message); 42 | #endif 43 | } 44 | 45 | 46 | [Fact] 47 | public void ErrorWhenKeyNotInConfig() 48 | { 49 | Assert.Throws( 50 | () => 51 | new AppSettingsProvider().EvaluateBooleanToggleValue(new NotInConfig())); 52 | } 53 | 54 | 55 | private class FormatInConfigIsWrong : EnabledBetweenDatesFeatureToggle 56 | { 57 | } 58 | 59 | private class NotInConfig : SimpleFeatureToggle 60 | { 61 | } 62 | 63 | private class TimePeriod : EnabledBetweenDatesFeatureToggle 64 | { 65 | } 66 | } 67 | } 68 | 69 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/BooleanHttpJsonProviderShould.cs: -------------------------------------------------------------------------------- 1 | // TODO: net core 2 | 3 | #if NETFULL 4 | 5 | using System.Configuration; 6 | using System.Net; 7 | using FeatureToggle.Shared.Tests.Integration.TestApiServer; 8 | using FeatureToggle.Internal; 9 | using FeatureToggle; 10 | using Microsoft.Owin.Hosting; 11 | using Xunit; 12 | 13 | namespace FeatureToggle.Shared.Tests.Integration 14 | { 15 | public class BooleanHttpJsonProviderShould 16 | { 17 | private const string Url = "http://localhost:8084"; 18 | private const string AlternateUrl = "http://localhost:8089"; 19 | 20 | [Fact] 21 | public void ReadBooleanTrueFromHttpJsonEndpoint() 22 | { 23 | using (WebApp.Start(Url)) 24 | { 25 | var sut = new AppSettingsProvider(); 26 | 27 | var toggle = new HttpJsonTrueToggle(); 28 | 29 | Assert.True(sut.EvaluateBooleanToggleValue(toggle)); 30 | } 31 | } 32 | 33 | [Fact] 34 | public void ReadBooleanFalseFromHttpJsonEndpoint() 35 | { 36 | using (WebApp.Start(Url)) 37 | { 38 | var sut = new AppSettingsProvider(); 39 | 40 | var toggle = new HttpJsonFalseToggle(); 41 | 42 | Assert.False(sut.EvaluateBooleanToggleValue(toggle)); 43 | } 44 | } 45 | 46 | 47 | [Fact] 48 | public void ErrorWhenInvalidJsonReceived() 49 | { 50 | using (WebApp.Start(Url)) 51 | { 52 | var sut = new AppSettingsProvider(); 53 | 54 | var toggle = new InvalidHttpJsonToggle(); 55 | 56 | Assert.Throws(() => sut.EvaluateBooleanToggleValue(toggle)); 57 | } 58 | } 59 | 60 | 61 | [Fact] 62 | public void ErrorWhen404() 63 | { 64 | using (WebApp.Start(AlternateUrl)) 65 | { 66 | var sut = new AppSettingsProvider(); 67 | 68 | var toggle = new InvalidHttpJsonToggle(); 69 | 70 | Assert.Throws(() => sut.EvaluateBooleanToggleValue(toggle)); 71 | } 72 | } 73 | 74 | 75 | [Fact] 76 | public void ErrorWhenUrlNotInConfig() 77 | { 78 | var sut = new MissingUrlToggle(); 79 | 80 | Assert.Throws(() => sut.FeatureEnabled); 81 | } 82 | 83 | 84 | 85 | 86 | private class MissingUrlToggle : HttpJsonFeatureToggle { } 87 | private class HttpJsonTrueToggle : HttpJsonFeatureToggle { } 88 | private class HttpJsonFalseToggle : HttpJsonFeatureToggle { } 89 | private class InvalidHttpJsonToggle : HttpJsonFeatureToggle { } 90 | 91 | } 92 | } 93 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/TestApiServer/Startup.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL 2 | 3 | using System.Web.Http; 4 | using Owin; 5 | 6 | namespace FeatureToggle.Shared.Tests.Integration.TestApiServer 7 | { 8 | public class Startup 9 | { 10 | public void Configuration(IAppBuilder appBuilder) 11 | { 12 | var config = new HttpConfiguration(); 13 | 14 | config.Routes.MapHttpRoute("ApiWithAction", "api/{controller}/{action}"); 15 | //config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); 16 | 17 | appBuilder.UseWebApi(config);//.UseNancy(); 18 | } 19 | } 20 | } 21 | 22 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/Integration/TestApiServer/TestController.cs: -------------------------------------------------------------------------------- 1 | // TODO: test http toggle with net core integration project 2 | 3 | #if NETFULL 4 | 5 | using System.Collections.Generic; 6 | using System.Web.Http; 7 | using FeatureToggle.Internal; 8 | 9 | namespace FeatureToggle.Shared.Tests.Integration.TestApiServer 10 | { 11 | public class TestController : ApiController 12 | { 13 | public JsonEnabledResponse GetEnabled() 14 | { 15 | return new JsonEnabledResponse{Enabled=true}; 16 | } 17 | 18 | public JsonEnabledResponse GetDisabled() 19 | { 20 | return new JsonEnabledResponse { Enabled = false }; 21 | } 22 | 23 | public KittyKat GetBadJson() 24 | { 25 | return new KittyKat {Name = "SnowyWowy"}; 26 | } 27 | 28 | public class KittyKat 29 | { 30 | public string Name { get; set; } 31 | } 32 | } 33 | } 34 | 35 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/IsShould.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | using FeatureToggle.Shared.Tests.TestToggles; 3 | using Xunit; 4 | 5 | namespace FeatureToggle.Tests 6 | { 7 | public class IsShould 8 | { 9 | [Fact] 10 | public void ReturnEnabled() 11 | { 12 | Assert.True(Is.Enabled); 13 | Assert.False(Is.Disabled); 14 | 15 | 16 | // Additional convoluted test code below so as to visualize how the fluent syntax reads 17 | 18 | if (Is.Enabled) 19 | { 20 | Assert.True(true); 21 | } 22 | else 23 | { 24 | Assert.True(false); 25 | } 26 | } 27 | 28 | [Fact] 29 | public void ReturnDisabled() 30 | { 31 | Assert.True(Is.Disabled); 32 | Assert.False(Is.Enabled); 33 | 34 | 35 | // Additional convoluted test code below so as to visualize how the fluent syntax reads 36 | 37 | if (Is.Disabled) 38 | { 39 | Assert.True(true); 40 | } 41 | else 42 | { 43 | Assert.True(false); 44 | } 45 | } 46 | 47 | 48 | [Fact] 49 | public void ThrowToggleErrors() 50 | { 51 | Assert.Throws(() => Is.Enabled); 52 | } 53 | 54 | private class Printing : AlwaysOnFeatureToggle {} 55 | private class Saving : AlwaysOffFeatureToggle {} 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/RandomFeatureToggleShould.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using FeatureToggle; 3 | using Xunit; 4 | 5 | namespace FeatureToggle.Tests 6 | { 7 | public class RandomFeatureToggleShould 8 | { 9 | [Fact] 10 | public void BeRandomlyEnabled() 11 | { 12 | var sut = new MyRandomFeatureToggle(); 13 | 14 | var results = new List(); 15 | 16 | 17 | for (var i = 0; i < 100; i++) 18 | { 19 | results.Add(sut.FeatureEnabled); 20 | } 21 | 22 | Assert.Contains(true, results); 23 | Assert.Contains(false, results); 24 | } 25 | 26 | private class MyRandomFeatureToggle : RandomFeatureToggle {} 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/RunOn.cs: -------------------------------------------------------------------------------- 1 | //#if NETFX_CORE 2 | 3 | //using System; 4 | //using System.Threading.Tasks; 5 | //using Windows.UI.Core; 6 | 7 | 8 | 9 | //// ReSharper disable CheckNamespace 10 | //namespace FeatureToggle.Shared.Tests 11 | //// ReSharper restore CheckNamespace 12 | //{ 13 | // public static class RunOn 14 | // { 15 | 16 | // public static async Task Dispatcher(Action a, int timeOut = 5000) 17 | // { 18 | // await 19 | // Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( 20 | // CoreDispatcherPriority.Normal, a.Invoke); 21 | // } 22 | 23 | // } 24 | //} 25 | //#endif 26 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/SimpleFeatureToggleShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FeatureToggle; 3 | using FeatureToggle.Internal; 4 | using Xunit; 5 | 6 | #if NETFULL || NETCORE 7 | using Moq; 8 | #endif 9 | 10 | namespace FeatureToggle.Tests 11 | { 12 | public class SimpleFeatureToggleShould 13 | { 14 | [Fact] 15 | public void HaveDefaultProvider() 16 | { 17 | var sut = new MySimpleFeatureToggle(); 18 | #if NETFULL || NETCORE 19 | Assert.Equal(typeof(AppSettingsProvider), sut.ToggleValueProvider.GetType()); 20 | #else 21 | Assert.Equal(typeof(ApplicationResourcesSettingsProvider), sut.ToggleValueProvider.GetType()); 22 | #endif 23 | } 24 | 25 | #if NETFULL || NETCORE // can't Moq in UWP 26 | [Fact] 27 | public void SetOptionalProviderOnCreation() 28 | { 29 | var fakeProvider = new Mock(); 30 | 31 | fakeProvider.Setup(x => x.EvaluateBooleanToggleValue(It.IsAny())).Returns(true); 32 | 33 | var sut = new MySimpleFeatureToggle(); 34 | sut.ToggleValueProvider = fakeProvider.Object; 35 | 36 | Assert.Equal(true, sut.FeatureEnabled); 37 | } 38 | #endif 39 | 40 | private class MySimpleFeatureToggle : SimpleFeatureToggle { } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/SqlFeatureToggleShould.cs: -------------------------------------------------------------------------------- 1 | #if NETFULL // sql toggle only on full framework for now 2 | 3 | using FeatureToggle; 4 | using FeatureToggle.Internal; 5 | using Moq; 6 | using Xunit; 7 | 8 | namespace FeatureToggle.Tests 9 | { 10 | public class SqlFeatureToggleShould 11 | { 12 | [Fact] 13 | public void HaveDefaultProvider() 14 | { 15 | var sut = new MySqlFeatureToggle(); 16 | 17 | Assert.Equal(typeof(BooleanSqlServerProvider), sut.ToggleValueProvider.GetType()); 18 | } 19 | 20 | 21 | [Fact] 22 | public void DisableFeatureWhenToggleValueIsFalse() 23 | { 24 | var fakeProvider = new Mock(); 25 | 26 | fakeProvider.Setup(x => x.EvaluateBooleanToggleValue(It.IsAny())).Returns(false); 27 | 28 | var sut = new MySqlFeatureToggle(); 29 | sut.ToggleValueProvider = fakeProvider.Object; 30 | 31 | Assert.False(sut.FeatureEnabled); 32 | } 33 | 34 | [Fact] 35 | public void EnableFeatureWhenToggleValueIsTrue() 36 | { 37 | var fakeProvider = new Mock(); 38 | 39 | fakeProvider.Setup(x => x.EvaluateBooleanToggleValue(It.IsAny())).Returns(true); 40 | 41 | var sut = new MySqlFeatureToggle(); 42 | sut.ToggleValueProvider = fakeProvider.Object; 43 | 44 | Assert.True(sut.FeatureEnabled); 45 | } 46 | 47 | private class MySqlFeatureToggle : SqlFeatureToggle { } 48 | } 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.Shared.Tests/TestToggles/AnErroringToggle.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace FeatureToggle.Shared.Tests.TestToggles 4 | { 5 | public class AnErroringToggle : IFeatureToggle 6 | { 7 | public bool FeatureEnabled 8 | { 9 | get { throw new ToggleConfigurationError("Simulated toggle exception"); } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/StoreLogo.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/FeatureToggle.UAP.Tests.nuget.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | D:\dev\FeatureToggle\src\Tests\FeatureToggle.UAP.Tests\project.lock.json 7 | $(UserProfile)\.nuget\packages\ 8 | C:\Users\Admin\.nuget\packages\ 9 | ProjectJson 10 | 4.3.1 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/FeatureToggle.UAP.Tests.nuget.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/FeatureToggle.UAP.Tests_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/FeatureToggle.UAP.Tests/FeatureToggle.UAP.Tests_TemporaryKey.pfx -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | FeatureToggle.UAP.Tests 7 | Admin 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("FeatureToggle.UAP.Tests")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("FeatureToggle.UAP.Tests")] 10 | [assembly: AssemblyCopyright("Copyright © 2017")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | [assembly: AssemblyMetadata("TargetPlatform","UAP")] 14 | 15 | // [assembly: AssemblyVersion("1.0.*")] 16 | [assembly: AssemblyVersion("0.0.2.1")] 17 | [assembly: AssemblyFileVersion("1.0.0.0")] 18 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/Properties/UnitTestApp.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/TestHelpers/RunOn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Windows.UI.Core; 4 | 5 | namespace FeatureToggle.UAP.Tests.TestHelpers 6 | { 7 | // Allows testing when marshaling occurs 8 | public static class RunOn 9 | { 10 | 11 | public static async Task Dispatcher(Action a, int timeOut = 5000) 12 | { 13 | await 14 | Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( 15 | CoreDispatcherPriority.Normal, a.Invoke); 16 | } 17 | 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/UnitTestApp.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP.Tests/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2", 4 | "xunit": "2.2.0", 5 | "xunit.runner.visualstudio": "2.2.0" 6 | }, 7 | "frameworks": { 8 | "uap10.0": {} 9 | }, 10 | "runtimes": { 11 | "win10-arm": {}, 12 | "win10-arm-aot": {}, 13 | "win10-x86": {}, 14 | "win10-x86-aot": {}, 15 | "win10-x64": {}, 16 | "win10-x64-aot": {} 17 | } 18 | } -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FeatureToggle.UAP")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FeatureToggle.UAP")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP/Properties/FeatureToggle.UAP.rd.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Tests/FeatureToggle.UAP/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" 4 | }, 5 | "frameworks": { 6 | "uap10.0": {} 7 | }, 8 | "runtimes": { 9 | "win10-arm": {}, 10 | "win10-arm-aot": {}, 11 | "win10-x86": {}, 12 | "win10-x86-aot": {}, 13 | "win10-x64": {}, 14 | "win10-x64-aot": {} 15 | } 16 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/AspNetCoreWebApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp1.1 5 | 6 | 7 | 8 | $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace AspNetCoreWebApplication.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | private readonly Printing _print; 12 | private readonly Saving _save; 13 | 14 | public HomeController(Printing print, Saving save) 15 | { 16 | _print = print; 17 | _save = save; 18 | 19 | bool p = _print.FeatureEnabled; 20 | bool s = _save.FeatureEnabled; 21 | } 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | public IActionResult About() 28 | { 29 | ViewData["Message"] = "Your application description page."; 30 | 31 | return View(); 32 | } 33 | 34 | public IActionResult Contact() 35 | { 36 | ViewData["Message"] = "Your contact page."; 37 | 38 | return View(); 39 | } 40 | 41 | public IActionResult Error() 42 | { 43 | return View(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Model.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace AspNetCoreWebApplication 4 | { 5 | public class Model 6 | { 7 | private IFeatureToggle Print { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Printing.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace AspNetCoreWebApplication 4 | { 5 | public class Printing : SimpleFeatureToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Hosting; 7 | 8 | namespace AspNetCoreWebApplication 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | var host = new WebHostBuilder() 15 | .UseKestrel() 16 | .UseContentRoot(Directory.GetCurrentDirectory()) 17 | .UseIISIntegration() 18 | .UseStartup() 19 | .UseApplicationInsights() 20 | .Build(); 21 | 22 | host.Run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:18330/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "AspNetCoreWebApplication": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:18331" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Saving.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace AspNetCoreWebApplication 4 | { 5 | public class Saving : EnabledOnOrAfterDateFeatureToggle {} 6 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using FeatureToggle.Internal; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using Microsoft.Extensions.Logging; 11 | 12 | 13 | namespace AspNetCoreWebApplication 14 | { 15 | public class Startup 16 | { 17 | public Startup(IHostingEnvironment env) 18 | { 19 | var builder = new ConfigurationBuilder() 20 | .SetBasePath(env.ContentRootPath) 21 | .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) 22 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) 23 | .AddEnvironmentVariables(); 24 | Configuration = builder.Build(); 25 | } 26 | 27 | public IConfigurationRoot Configuration { get; } 28 | 29 | // This method gets called by the runtime. Use this method to add services to the container. 30 | public void ConfigureServices(IServiceCollection services) 31 | { 32 | // Set provider config so file is read from content root path 33 | var provider = new AppSettingsProvider { Configuration = Configuration }; 34 | 35 | services.AddSingleton(new Printing { ToggleValueProvider = provider }); 36 | services.AddSingleton(new Saving { ToggleValueProvider = provider }); 37 | // Add framework services. 38 | services.AddMvc(); 39 | } 40 | 41 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 42 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 43 | { 44 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 45 | loggerFactory.AddDebug(); 46 | 47 | if (env.IsDevelopment()) 48 | { 49 | app.UseDeveloperExceptionPage(); 50 | app.UseBrowserLink(); 51 | } 52 | else 53 | { 54 | app.UseExceptionHandler("/Home/Error"); 55 | } 56 | 57 | app.UseStaticFiles(); 58 | 59 | app.UseMvc(routes => 60 | { 61 | routes.MapRoute( 62 | name: "default", 63 | template: "{controller=Home}/{action=Index}/{id?}"); 64 | }); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | 8 |

Development Mode

9 |

10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

12 |

13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

15 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNetCoreWebApplication 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Warning" 6 | } 7 | }, 8 | "FeatureToggle": { 9 | "Printing": "true", 10 | "Saving": "01-Jan-2014 18:00:00", 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.7", 6 | "jquery": "2.2.0", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Set widths on the form inputs since otherwise they're 100% wide */ 14 | input, 15 | select, 16 | textarea { 17 | max-width: 280px; 18 | } 19 | 20 | /* Carousel */ 21 | .carousel-caption p { 22 | font-size: 20px; 23 | line-height: 1.4; 24 | } 25 | 26 | /* Make .svg files in the carousel display properly in older browsers */ 27 | .carousel-inner .item img[src$=".svg"] { 28 | width: 100%; 29 | } 30 | 31 | /* Hide/rearrange for smaller screens */ 32 | @media screen and (max-width: 767px) { 33 | /* Hide captions */ 34 | .carousel-caption { 35 | display: none; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 3" 33 | }, 34 | "version": "3.3.7", 35 | "_release": "3.3.7", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.7", 39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86" 40 | }, 41 | "_source": "https://github.com/twbs/bootstrap.git", 42 | "_target": "v3.3.7", 43 | "_originalSource": "bootstrap", 44 | "_direct": true 45 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "2.2.0", 16 | "_release": "2.2.0", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "2.2.0", 20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5" 21 | }, 22 | "_source": "git://github.com/jquery/jquery-dist.git", 23 | "_target": "2.2.0", 24 | "_originalSource": "jquery" 25 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/AspNetCoreWebApplication/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/Model.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetCoreConsoleApp 4 | { 5 | public class Model 6 | { 7 | private IFeatureToggle Print { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/NetCoreConsoleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp1.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Always 15 | PreserveNewest 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/Printing.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetCoreConsoleApp 4 | { 5 | public class Printing : SimpleFeatureToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetCoreConsoleApp 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var p = new Printing(); 10 | var s = new Saving(); 11 | var t = new Tweeting(); 12 | 13 | Console.WriteLine($"Printing is {(p.FeatureEnabled ? "on" : "off")}"); 14 | Console.WriteLine($"Saving is {(s.FeatureEnabled ? "on" : "off")}"); 15 | Console.WriteLine($"Tweeting is {(t.FeatureEnabled ? "on" : "off")}"); 16 | 17 | 18 | Console.ReadLine(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/Saving.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetCoreConsoleApp 4 | { 5 | public class Saving : EnabledOnOrAfterDateFeatureToggle {} 6 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/Tweeting.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetCoreConsoleApp 4 | { 5 | public class Tweeting : EnabledOnOrAfterAssemblyVersionWhereToggleIsDefinedToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetCoreConsoleApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "FeatureToggle": { 3 | "Printing": "true", 4 | "Saving": "01-Jan-2014 18:00:00" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetFullConsoleApp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetFullConsoleApp/Model.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetFullConsoleApp 4 | { 5 | public class Model 6 | { 7 | private IFeatureToggle Print { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetFullConsoleApp/Printing.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetFullConsoleApp 4 | { 5 | public class Printing : SimpleFeatureToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetFullConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFullConsoleApp 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var p = new Printing(); 10 | var s = new Saving(); 11 | 12 | 13 | Console.WriteLine($"Printing is {(p.FeatureEnabled ? "on" : "off")}"); 14 | Console.WriteLine($"Saving is {(s.FeatureEnabled ? "on" : "off")}"); 15 | 16 | 17 | 18 | Console.ReadLine(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetFullConsoleApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NetFullConsoleApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NetFullConsoleApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1c33997a-2451-4a12-a815-2bd2aacb3dff")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/NetFullConsoleApp/Saving.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace NetFullConsoleApp 4 | { 5 | public class Saving : EnabledOnOrAfterDateFeatureToggle {} 6 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | false 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/StoreLogo.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 17 | 18 | namespace UAPApp 19 | { 20 | /// 21 | /// An empty page that can be used on its own or navigated to within a Frame. 22 | /// 23 | public sealed partial class MainPage : Page 24 | { 25 | public MainPage() 26 | { 27 | this.InitializeComponent(); 28 | 29 | var m = new Model(); 30 | 31 | bool b = m.Print.FeatureEnabled; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Model.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace UAPApp 4 | { 5 | public class Model 6 | { 7 | public IFeatureToggle Print { get; set; } = new Printing(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | UAPApp 7 | Admin 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Printing.cs: -------------------------------------------------------------------------------- 1 | using FeatureToggle; 2 | 3 | namespace UAPApp 4 | { 5 | public class Printing : SimpleFeatureToggle {} 6 | } 7 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UAPApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UAPApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/UAPApp_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jason-roberts/FeatureToggle/08e2c6ef9c4e948eb20f53986b2b692b4f6e870b/src/Tests/ManualNugetPackageTesting/UAPApp/UAPApp_TemporaryKey.pfx -------------------------------------------------------------------------------- /src/Tests/ManualNugetPackageTesting/UAPApp/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "FeatureToggle": "4.0.2", 4 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" 5 | }, 6 | "frameworks": { 7 | "uap10.0.14393": {} 8 | }, 9 | "runtimes": { 10 | "win10-arm": {}, 11 | "win10-arm-aot": {}, 12 | "win10-x86": {}, 13 | "win10-x86-aot": {}, 14 | "win10-x64": {}, 15 | "win10-x64-aot": {} 16 | } 17 | } --------------------------------------------------------------------------------