public void Should_export_to_specified_file()
        {
            EmbeddedResource
            .EndsWith("embeddedsample.txt", StringComparison.OrdinalIgnoreCase)
            .ExportTo(_fileName);

            Assert.That(File.Exists(_fileName), Is.True);
        }
        public void Should_export_to_temp_file_if_overwrite_file_is_on()
        {
            var stream = EmbeddedResource.EndsWith("embeddedsample.txt", StringComparison.OrdinalIgnoreCase);

            _fileName = stream.ExportToTempFile();

            Assert.That(File.Exists(_fileName), Is.True);
        }
Esempio n. 3
0
        public void Should_find_resource_and_return_stream_from_specified_assembly()
        {
            var name = "embeddedsample.txt";

            var resource = EmbeddedResource.EndsWith(name, Assembly.GetExecutingAssembly(), StringComparison.OrdinalIgnoreCase);

            Assert.That(resource, Is.Not.Null);
        }
        public void Should_not_throw_if_overwrite_file_is_on()
        {
            var stream = EmbeddedResource.EndsWith("embeddedsample.txt", StringComparison.OrdinalIgnoreCase);

            stream.ExportTo(_fileName);

            stream.Position = 0;

            Assert.DoesNotThrow(() => stream.ExportTo(_fileName, overwrite: true));
        }
        public void Should_throw_if_file_exists()
        {
            var stream = EmbeddedResource.EndsWith("embeddedsample.txt", StringComparison.OrdinalIgnoreCase);

            stream.ExportTo(_fileName);

            stream.Position = 0;

            Assert.Throws <IOException>(() => stream.ExportTo(_fileName));
        }
Esempio n. 6
0
        /// <summary>
        /// Creates new instance of a <see cref="Library"/> class.
        /// <remarks>It's better to use the only instance of library for process. You can manage it yourself or use <see cref="Library.Instance"/> property.</remarks>
        /// </summary>
        /// <returns></returns>
        public static Library Create()
        {
            //var libraryHandle = Platform.LoadEjdbLibrary();
            var resourceName = string.Format("tcejdb{0}.dll", Environment.Is64BitProcess ? "64" : "32");

            var libraryPath = EmbeddedResource
                              .EndsWith(resourceName)
                              .ExportToTempFile();

            var libraryHandle = Platform.LoadLibraryEx(libraryPath);

            var result = new Library(libraryHandle);

            return(result);
        }
Esempio n. 7
0
        public void Should_throw_if_resource_not_found()
        {
            var name = "embeddedsample.txt";

            Assert.Throws <InvalidOperationException>(() => EmbeddedResource.EndsWith(name, StringComparison.Ordinal));
        }