Пример #1
0
        public void TestRemoveNonExistentDocument()
        {
            var session = new SessionBuilder().StartDefault().Build();

              Assert.DoesNotThrow(delegate()
              {
            session.RemoveDocument(new SessionDocumentBuilder().StartDefault().Build());
              });
        }
Пример #2
0
        public void TestIsDirty()
        {
            var session = new SessionBuilder().StartDefault().Build();
              var document = new SessionDocumentBuilder().StartDefault().Build();
              session.AddDocument(document);
              session.IsDirty = false;

              session.RemoveDocument(document);

              Assert.IsTrue(session.IsDirty);
        }
Пример #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 TestRemoveNullDocument()
 {
     var session = new SessionBuilder().StartDefault().Build();
       session.RemoveDocument(null);
 }
Пример #5
0
        public void TestSaveDocuments()
        {
            var repo = new XmlSessionRepository();
              var uow = repo.GetUnitOfWork();
              var session1 = new SessionBuilder().StartDefault("session1").Build();
              var doc1 = new SessionDocumentBuilder().StartDefault("doc1").Build();
              session1.AddDocument(doc1);
              var doc2 = new SessionDocumentBuilder().StartDefault("doc2").Build();
              session1.AddDocument(doc2);
              uow.RegisterSavedOrUpdated(session1);
              uow.Commit();

              repo = new XmlSessionRepository();
              var sessionsInRepo = repo.GetAllSessions();
              Assert.AreEqual(1, sessionsInRepo.Count());
              Assert.IsNotNull(sessionsInRepo.FirstOrDefault(s => s.Equals(session1)));
              Assert.AreEqual(2, sessionsInRepo.First().GetDocuments().Count());

              repo = new XmlSessionRepository();
              uow = repo.GetUnitOfWork();
              session1.RemoveDocument(doc1);
              uow.RegisterSavedOrUpdated(session1);
              uow.Commit();

              repo = new XmlSessionRepository();
              sessionsInRepo = repo.GetAllSessions();
              Assert.AreEqual(1, sessionsInRepo.Count());
              Assert.IsNotNull(sessionsInRepo.FirstOrDefault(s => s.Equals(session1)));
              Assert.AreEqual(1, sessionsInRepo.First().GetDocuments().Count());
        }