public void Can_add_localdb_grain_to_sandbox() { var sandbox = new Core.Sandbox().UseLocalDb() as dynamic; Assert.NotNull(sandbox.LocalDb); Assert.IsType <LocalDbGrain>(sandbox.LocalDb); }
public void Null_when_not_setup() { using (var sandbox = new Core.Sandbox().UseLocalDb() as dynamic) { Assert.Null(sandbox.LocalDb.Instance); } }
public void Setup(Core.Sandbox sandbox) { var name = string.IsNullOrWhiteSpace(DatabasePrefix) ? null : string.Format("{0}_{1}", DateTime.Now.Ticks); Instance = new LocalDb(name, Version, sandbox.Location); }
public void Can_register_iis_express_grain() { var src = CreateTempTestDirectory(); using (var sandbox = new Core.Sandbox().UseIisExpress(src).Play() as dynamic) { var url = sandbox.IisExpress.Instance.Endpoints[0] as string; Assert.Equal(Html, Get(url)); } }
public void Can_configure_localdb_using_action() { var sandbox = new Core.Sandbox() .UseLocalDb((sb, cfg) => { cfg.DatabasePrefix = "test"; cfg.Version = LocalDb.Versions.V12; }) as dynamic; Assert.Equal("test", sandbox.LocalDb.DatabasePrefix); Assert.Equal(LocalDb.Versions.V12, sandbox.LocalDb.Version); }
public static Core.Sandbox UseLocalDb(this Core.Sandbox sandbox, Action <dynamic, ILocalDbConfiguration> config = null) { var dynamicSb = sandbox as dynamic; var grain = new LocalDbGrain(); dynamicSb.LocalDb = grain; if (config != null) { config(sandbox, grain); } return(sandbox); }
public static Core.Sandbox UseIisExpress(this Core.Sandbox sandbox, Action <dynamic, IIisExpressConfiguration> config = null) { var dynamicSb = sandbox as dynamic; var grain = new IisExpressGrain(); dynamicSb.IisExpress = grain; if (config != null) { config(sandbox, grain); } return(sandbox); }
public void Can_register_iis_express_grain_with_https() { var src = CreateTempTestDirectory(); using (var sandbox = new Core.Sandbox().UseIisExpress((box, cfg) => { cfg.Source = src; cfg.UseHttps(); }).Play() as dynamic) { var endpoints = sandbox.IisExpress.Instance.Endpoints; var url = endpoints[1] as string; Assert.Equal(Html, Get(url)); } }
public void Can_setup_and_tear_down_localdb() { var path = string.Empty; using (var sandbox = new Core.Sandbox().UseLocalDb() as dynamic) { sandbox.Play(); using (var connection = sandbox.LocalDb.Instance.OpenConnection() as SqlConnection) { path = sandbox.LocalDb.Instance.Location; var dataTable = connection.GetSchema(); Assert.NotNull(dataTable); } } Assert.False(Directory.Exists(path)); }
public void Setup(Core.Sandbox sandbox) { if (string.IsNullOrWhiteSpace(Source) || !Directory.Exists(Source)) { throw new ArgumentNullException("Source", "a source is required for iis express"); } // copy the source to the sandbox location Destination = Path.Combine(sandbox.Location, "Web"); var destination = new DirectoryInfo(Destination); CopyAll(new DirectoryInfo(Source), destination); SetDestinationPermissions(new DirectoryInfo(sandbox.Location)); // create an applicationHost.config var site = IisExpress.AddSiteToApplicationHostConfig(string.Format("sandbox_{0}", sandbox.Id), Destination, Protocols); // create new IisExpress instance Instance = new IisExpress(site.Name); Instance.Start(); }
public static Core.Sandbox UseIisExpress(this Core.Sandbox sandbox, string source) { return(UseIisExpress(sandbox, (box, cfg) => cfg.Source = source)); }