コード例 #1
0
        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);
        }
コード例 #2
0
 public void Null_when_not_setup()
 {
     using (var sandbox = new Core.Sandbox().UseLocalDb() as dynamic)
     {
         Assert.Null(sandbox.LocalDb.Instance);
     }
 }
コード例 #3
0
ファイル: LocalDbGrain.cs プロジェクト: ScottSchwalm/Sandbox
        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);
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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));
            }
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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();
        }
コード例 #11
0
 public static Core.Sandbox UseIisExpress(this Core.Sandbox sandbox, string source)
 {
     return(UseIisExpress(sandbox, (box, cfg) => cfg.Source = source));
 }