Пример #1
0
        public void TestFillDocumentsInSession()
        {
            const string DOCUMENT_TO_ADD1    = "documentToAdd1";
            const string DOCUMENT_TO_ADD2    = "documentToAdd2";
            const string DOCUMENT_TO_ADD3    = "documentToAdd3";
            const string DOCUMENT_DUPLICATED = "documentDuplicated";

            var session = new SessionBuilder().StartDefault().Build();

            session.AddDocument(new SessionDocumentBuilder().StartDefault("documentToRemove").Build());
            session.AddDocument(new SessionDocumentBuilder().StartDefault(DOCUMENT_DUPLICATED).Build());

            var dteWindowAdapterMock1 = new Mock <IDteWindowAdapter>();

            dteWindowAdapterMock1.Setup(dwa => dwa.FullPath).Returns(DOCUMENT_TO_ADD1);
            dteWindowAdapterMock1.Setup(dwa => dwa.DocumentType).Returns(DocumentType.Text);

            var dteWindowAdapterMock2 = new Mock <IDteWindowAdapter>();

            dteWindowAdapterMock2.Setup(dwa => dwa.FullPath).Returns(DOCUMENT_TO_ADD2);
            dteWindowAdapterMock2.Setup(dwa => dwa.DocumentType).Returns(DocumentType.Text);

            var dteWindowAdapterMock3 = new Mock <IDteWindowAdapter>();

            dteWindowAdapterMock3.Setup(dwa => dwa.FullPath).Returns(DOCUMENT_TO_ADD3);
            dteWindowAdapterMock3.Setup(dwa => dwa.DocumentType).Returns(DocumentType.Text);

            var dteWindowAdapterMock4 = new Mock <IDteWindowAdapter>();

            dteWindowAdapterMock4.Setup(dwa => dwa.FullPath).Returns(DOCUMENT_DUPLICATED);
            dteWindowAdapterMock4.Setup(dwa => dwa.DocumentType).Returns(DocumentType.Text);

            var dteAdapterMock = new Mock <IDteAdapter>();

            dteAdapterMock.Setup(da => da.GetWindowsForValidDocuments()).Returns(
                new List <IDteWindowAdapter>()
            {
                dteWindowAdapterMock1.Object,
                dteWindowAdapterMock2.Object,
                dteWindowAdapterMock3.Object,
                dteWindowAdapterMock4.Object
            });

            var sessionManagerMock = new Mock <ISessionManager>();

            sessionManagerMock.Setup(sm => sm.CurrentSession).Returns((Session)null);

            var controller = new AddinController(sessionManagerMock.Object, null, null, dteAdapterMock.Object, null);

            controller.FillDocumentsInSession(session);

            IEnumerable <SessionDocument> documentsInSession = session.GetDocuments();

            Assert.AreEqual(4, documentsInSession.Count());
            Assert.AreEqual(1, documentsInSession.Where(d => d.Path.Equals(DOCUMENT_TO_ADD1)).Count());
            Assert.AreEqual(1, documentsInSession.Where(d => d.Path.Equals(DOCUMENT_TO_ADD2)).Count());
            Assert.AreEqual(1, documentsInSession.Where(d => d.Path.Equals(DOCUMENT_TO_ADD3)).Count());
            Assert.AreEqual(1, documentsInSession.Where(d => d.Path.Equals(DOCUMENT_DUPLICATED)).Count());
        }
Пример #2
0
        public void TestAddDuplicatedDocument()
        {
            var session = new SessionBuilder().StartDefault().Build();

            Assert.DoesNotThrow(delegate()
            {
                session.AddDocument(new SessionDocumentBuilder().StartDefault().Build());
                session.AddDocument(new SessionDocumentBuilder().StartDefault().Build());
            });

            Assert.AreEqual(1, session.GetDocuments().Count());
        }
Пример #3
0
        public void TestSimpleAddRemoveDocument()
        {
            var session = new SessionBuilder().StartDefault().Build();

            session.AddDocument(new SessionDocumentBuilder().StartDefault("path1").Build());
            session.AddDocument(new SessionDocumentBuilder().StartDefault("path2").Build());

            var document = new SessionDocumentBuilder().StartDefault("path3").Build();

            session.AddDocument(document);
            session.RemoveDocument(document);

            Assert.AreEqual(2, session.GetDocuments().Count());
        }
Пример #4
0
        public void TestRemoveAllDocuments()
        {
            var session = new SessionBuilder().StartDefault().Build();

            session.IsDirty = false;

            session.RemoveAllDocuments();
            Assert.IsFalse(session.IsDirty);

            var document = new SessionDocumentBuilder().StartDefault().Build();

            session.AddDocument(document);
            session.IsDirty = false;

            session.RemoveAllDocuments();

            Assert.AreEqual(0, session.GetDocuments().Count());
            Assert.IsTrue(session.IsDirty);
        }