protected override void Context() { _sessionFactoryProvider = A.Fake <ISessionFactoryProvider>(); _templateFileName = FileHelper.GenerateTemporaryFileName(); CreateFile(_templateFileName); _fileNameToCreate = FileHelper.GenerateTemporaryFileName(); _sessionFactory = A.Fake <ISessionFactory>(); A.CallTo(() => _sessionFactoryProvider.InitalizeSessionFactoryFor(_fileNameToCreate)).Returns(_sessionFactory); sut = new SessionManager(_sessionFactoryProvider); }
public void CreateFactoryFor(string fileName) { //Project file is already open for the same filename if (sessionFactoryIsAlreadyOpenFor(fileName)) { return; } //Project file open, but for another name => save as if (sessionFactoryIsOpen()) { File.Copy(_currentFileName, fileName, true); CloseFactory(); _sessionFactory = _sessionFactoryProvider.OpenSessionFactoryFor(fileName); } //new project from scratch. save file else { FileHelper.DeleteFile(fileName); _sessionFactory = _sessionFactoryProvider.InitalizeSessionFactoryFor(fileName); } _currentFileName = fileName; }