public void Add_NonExistantFile() { DummyScrImportFileInfoFactory factory = new DummyScrImportFileInfoFactory(); IScrImportFileInfo f1 = CreateStubFileInfo(factory, "file1", new ScrReference(40, 1, 1, ScrVers.English), new ReferenceRange(40, 1,3)); IScrImportFileInfo f2 = factory.Create("IdontExist.blurb", m_mappingList, ImportDomain.Main, null, null, false); f2.Stub(x => x.IsReadable).Return(false); m_fileList.Add(f1); m_fileList.Add(f2); Assert.AreEqual(2, m_fileList.Count); Assert.AreEqual(f1, m_fileList[0]); Assert.AreEqual(f2, m_fileList[1]); m_resolver.VerifyAllExpectations(); Assert.AreEqual(0, m_callCountForVerifyFileRemoved); }
public void TestCheckForOverlaps_KeepFile2() { DummyScrImportFileInfoFactory factory = new DummyScrImportFileInfoFactory(); IScrImportFileInfo f1 = CreateStubFileInfo(factory, "file1", new ScrReference(40, 1, 1, ScrVers.English), new ReferenceRange(40, 1,3)); m_expectedRemovedFiles.Add(f1); IScrImportFileInfo f2 = CreateStubFileInfo(factory, "file2", new ScrReference(40, 3, 1, ScrVers.English), new ReferenceRange(40, 3, 5)); IScrImportFileInfo f3 = CreateStubFileInfo(factory, "file3", new ScrReference(40, 6, 1, ScrVers.English), new ReferenceRange(40, 6, 7)); m_resolver.Expect(x => x.ChooseFileToRemove(f2, f1)).Return(f1); m_fileList.Add(f1); m_fileList.Add(f2); m_fileList.Add(f3); Assert.AreEqual(2, m_fileList.Count); Assert.AreEqual(f2, m_fileList[0]); Assert.AreEqual(f3, m_fileList[1]); m_resolver.VerifyAllExpectations(); Assert.AreEqual(m_expectedRemovedFiles.Count, m_callCountForVerifyFileRemoved); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Test CheckForOverlaps where the user elects to keep file 1 in the Overlapping Files /// dialog /// </summary> /// ------------------------------------------------------------------------------------ private IScrImportFileInfo CreateStubFileInfo(DummyScrImportFileInfoFactory factory, string name, ScrReference startRef, ReferenceRange refRange) { IScrImportFileInfo f = factory.Create(name, m_mappingList, ImportDomain.Main, null, null, false); f.Stub(x => x.IsReadable).Return(true); f.Stub(x => x.IsStillReadable).Return(true); f.Stub(x => x.StartRef).Return(startRef); f.Stub(x => x.BookReferences).Return(new ReferenceRange[] { refRange }); return f; }
public void AddFile_Main() { m_importSettings.ImportTypeEnum = TypeOfImport.Other; DummyScrImportFileInfoFactory factory = new DummyScrImportFileInfoFactory(); ReflectionHelper.SetField(m_importSettings, "m_scrImpFinfoFact", factory); m_importSettings.AddFile("file1", ImportDomain.Main, null, null); Assert.IsTrue(factory.m_mockedScrImportFinfos.ContainsKey("file1")); Assert.AreEqual(factory.m_mockedScrImportFinfos["file1"], ((ScrSfFileList)ReflectionHelper.GetField(m_importSettings, "m_scrFileInfoList"))[0]); }