Ejemplo n.º 1
0
        public void GetDriveByVolumeLabel_Pickup()
        {
            var ramdisk     = new RamDrive();
            var volumeLabel = "Pickup";

            var actual = ramdisk.GetDriveByVolumeLabel(volumeLabel);

            Assert.IsNotNull(actual);
        }
Ejemplo n.º 2
0
        public void CreateDrive()
        {
            char   driveLetter = 'y';
            int    MB          = 100;
            string label       = "Pickup";

            var actual = RamDrive.CreateDrive(driveLetter, MB, label);

            Assert.IsTrue(actual);
        }
Ejemplo n.º 3
0
        public void OneTimeSetUp()
        {
            try { RamDrive.Unmount('X'); } catch { }
            try { RamDrive.Unmount('Y'); } catch { }

            TestDelegate action = () => RamDrive.Mount(128, FileSystem.NTFS, 'X', "MyDriveName");

            Assert.DoesNotThrow(action);

            Drive = DriveInfo.GetDrives().FirstOrDefault(d => d.Name.ToUpper()[0] == 'X');
        }
Ejemplo n.º 4
0
        public void OneTimeTearDown()
        {
            try { RamDrive.Unmount('Y'); } catch { }

            TestDelegate action = () => RamDrive.Unmount('X');

            Assert.DoesNotThrow(action);

            var exists = DriveInfo.GetDrives().Any(d => d.Name.ToUpper()[0] == 'X');

            Assert.IsFalse(exists);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Mounts a drive on system memory and creates SQL database there. (drops database if exists first)
        /// </summary>
        /// <param name="connectionString">Connection string to SQL database</param>
        /// <param name="sizeMegaByte">Size of ram drive in mega bytes</param>
        /// <param name="drive"></param>
        /// <returns></returns>
        public static IDisposable Create(string connectionString, int sizeMegaByte = 256, char drive = 'Z')
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            RamDrive.Mount(sizeMegaByte, RamDisk.FileSystem.NTFS, drive, "SqlInMemory");
            SqlHelper.DropDatabaseAndRecreate(connectionString, null, $"{drive}:\\", force: true);

            return(new Releaser(connectionString, drive));
        }
Ejemplo n.º 6
0
        public void Another_Drive_Format_Should_Work_Correctly(FileSystem fileSystem)
        {
            TestDelegate action = () => RamDrive.Mount(128, fileSystem, 'Y', "RamDisk");

            Assert.DoesNotThrow(action);

            var drive = DriveInfo.GetDrives().FirstOrDefault(d => d.Name.ToUpper()[0] == 'Y');

            Assert.IsNotNull(drive);

            Assert.AreEqual(drive.DriveFormat, fileSystem.ToString());

            TestDelegate action2 = () => RamDrive.Unmount('Y');

            Assert.DoesNotThrow(action2);

            Thread.Sleep(100);

            var exists = DriveInfo.GetDrives().Any(d => d.Name.ToUpper()[0] == 'Y');

            Assert.IsFalse(exists);
        }
 public UpdatePermissionsDbTest(ITestOutputHelper output, CustomWebApplicationFactory factory, RamDrive ramDrive) : base(output,
                                                                                                                         factory, ramDrive)
 {
 }
Ejemplo n.º 8
0
        public DbTestBase(ITestOutputHelper output, CustomWebApplicationFactory factory, RamDrive ramDrive)
        {
            OutputWriter = output;
            if (!ramDrive.Ready)
            {
                throw new Exception($"Ramdrive not ready!: {ramDrive.Error}");
            }
            OutputWriter.WriteLine(ramDrive.Output.ToString());

            WebApplicationFactory <TestStartup> webFactory = factory.WithWebHostBuilder(builder =>
            {
                builder.UseSolutionRelativeContentRoot("BeepBackend");

                builder.ConfigureAppConfiguration((context, configurationBuilder) =>
                {
                    string cfgPath = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json");
                    configurationBuilder.AddJsonFile(cfgPath);
                });

                builder.ConfigureServices(services =>
                {
                    services.AddMvc().AddApplicationPart(typeof(Startup).Assembly);
                });
            });

            WebClient = webFactory.CreateClient(
                new WebApplicationFactoryClientOptions()
            {
                BaseAddress = new Uri("http://localhost/api/")
            });

            var scope = factory.Server.Services.CreateScope();

            UsrManager = scope.ServiceProvider.GetRequiredService <UserManager <User> >();
            DbContext  = scope.ServiceProvider.GetRequiredService <BeepDbContext>();
            _roleMgr   = scope.ServiceProvider.GetRequiredService <RoleManager <Role> >();
        }
Ejemplo n.º 9
0
        public void Null_Drive_Label_Should_Throws_ArgumentNullException()
        {
            TestDelegate action = () => RamDrive.Mount(128, FileSystem.NTFS, 'X', null);

            Assert.Throws <ArgumentNullException>(action);
        }
Ejemplo n.º 10
0
        public void Negative_Drive_Size_Should_Throws_ArgumentException()
        {
            TestDelegate action = () => RamDrive.Mount(-128);

            Assert.Throws <ArgumentException>(action);
        }
Ejemplo n.º 11
0
        public void Duplicate_Drive_Name_Should_Throws_InvalidOperationException()
        {
            TestDelegate action = () => RamDrive.Mount(128, FileSystem.NTFS, 'X', "MyDriveName");

            Assert.Throws <InvalidOperationException>(action);
        }
Ejemplo n.º 12
0
        public void Unmount_NotExists_Drive_Should_Throws_InvalidOperationException()
        {
            TestDelegate action = () => RamDrive.Unmount('Q');

            Assert.Throws <InvalidOperationException>(action);
        }
Ejemplo n.º 13
0
 public AuthControllerTests(ITestOutputHelper output, CustomWebApplicationFactory factory, RamDrive ramDrive)
     : base(output, factory, ramDrive)
 {
 }
Ejemplo n.º 14
0
 public ArticlesPermissionsTest(ITestOutputHelper output, CustomWebApplicationFactory factory, RamDrive ramDrive) : base(output, factory, ramDrive)
 {
 }
Ejemplo n.º 15
0
 public void Dispose()
 {
     SqlHelper.DropDatabase(_connectionString, force: true);
     RamDrive.Unmount(_drive);
 }
 public ArticleFilteringTests(ITestOutputHelper output, CustomWebApplicationFactory factory, RamDrive ramDrive) : base(output,
                                                                                                                       factory, ramDrive)
 {
 }