// review: may want to change LiftDataMapper to IDataMapper<LexEntry> but I (cp) am leaving
        // this for the moment as would also need to change the container builder.Register in WeSayWordsProject
        public LiftLexEntryRepository(LiftDataMapper decoratedDataMapper)
        {
            Guard.AgainstNull(decoratedDataMapper, "decoratedDataMapper");
#if DEBUG
            _constructionStackTrace = new StackTrace();
#endif
            _decoratedDataMapper = decoratedDataMapper;
            _disposed            = false;
        }
Exemple #2
0
 // review: this constructor is only used for tests, and causes grief with
 // the dispose pattern.  Remove and refactor tests to use the other constructor
 // in a using style. cp
 public LexEntryRepository(string path)
 {
     _disposed = true;
                 #if DEBUG
     _constructionStackTrace = new StackTrace();
                 #endif
     LiftDataMapper mapper = new LiftDataMapper(
         path, null, new string[] {}, new ProgressState()
         );
     mapper.Init();
     _decoratedDataMapper = mapper;
     _disposed            = false;
 }
        public void UnlockedLiftFile_ConstructorDoesNotThrow()
        {
            using (var persistedFile = new TempFile())
            {
                var persistedFilePath = persistedFile.Path;

                // Confirm that the file is writable.
                FileStream fileStream = File.OpenWrite(persistedFilePath);
                Assert.IsTrue(fileStream.CanWrite);

                // Close it before creating the LiftDataMapper.
                fileStream.Close();

                LiftDataMapper liftDataMapper = null;
                Assert.That(() => liftDataMapper = CreateDataMapper(persistedFilePath), Throws.Nothing);
                liftDataMapper.Dispose();
            }
        }
        public void UnlockedLiftFile_ConstructorDoesNotThrow()
        {
            string persistedFilePath = _tempFolder.GetTemporaryFile();

            persistedFilePath = Path.GetFullPath(persistedFilePath);

            // Confirm that the file is writable.
            FileStream fileStream = File.OpenWrite(persistedFilePath);

            Assert.IsTrue(fileStream.CanWrite);

            // Close it before creating the LiftDataMapper.
            fileStream.Close();

            // LiftDataMapper constructor shouldn't throw an IOException.
            using (LiftDataMapper liftDataMapper = LiftRepositoryStateUnitializedTests.CreateDataMapper(persistedFilePath))
            {
            }
            Assert.IsTrue(true);             // Constructor didn't throw.
            File.Delete(persistedFilePath);
        }