Beispiel #1
0
 public void PostInsert_autoflush_without_flush_adds_to_solr()
 {
     var entity = new Entity {Description = "pepe"};
     using (var session = sessionFactory.OpenSession()) {
         session.Save(entity);
     }
     mockSolr.AssertWasCalled(x => x.Add(entity, null), o => o.Repeat.Once().Return(null));
 }
Beispiel #2
0
 public void PostInsert_manual_flush_without_flush_doesnt_add_to_solr() {
     var entity = new Entity {Description = "pepe"};
     mockSolr.addDocParams &= x => x.Expect(0);
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
     }
 }
Beispiel #3
0
 public void PostInsert_with_commit_adds_to_solr() {
     var entity = new Entity();
     mockSolr.addDocParams &= x => x.Expect(1);
     using (var session = sessionFactory.OpenSession()) {
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Commit();
         }
     }
 } 
Beispiel #4
0
 public void PostInsert_manual_flush_adds_to_solr()
 {
     var entity = new Entity {Description = "pepe"};
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
         session.Flush();
     }
     mockSolr.AssertWasCalled(x => x.Add(entity), o => o.Repeat.Once().Return(null));
 }
 public void Add_includes_parameters_when_configured()
 {
     var entity = new Entity { Description = "pepe" };
     using (var session = sessionFactory.OpenSession())
     {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
         session.Flush();
     }
     mockSolr.AssertWasCalled(x => x.Add(entity, addParameters), o => o.Repeat.Once().Return(null));
 }
Beispiel #6
0
 public void PostInsert_autoflush_without_flush_adds_to_solr() {
     var entity = new Entity {Description = "pepe"};
     mockSolr.addDocParams += (e, p) => {
         Assert.AreSame(entity, e);
         Assert.IsNull(p);
         return null;
     };
     mockSolr.addDocParams &= x => x.Expect(1);
     using (var session = sessionFactory.OpenSession()) {
         session.Save(entity);
     }
 }
Beispiel #7
0
 public void PostInsert_autoflush_without_flush_adds_to_solr()
 {
     var entity = new Entity {Description = "pepe"};
     mockSolr.Expect(x => x.Add(entity))
         .Repeat.Once()
         .Return(null);
     mockSolr.Replay();
     using (var session = sessionFactory.OpenSession()) {
         session.Save(entity);
     }
     mockSolr.VerifyAllExpectations();
 }
Beispiel #8
0
 public void PostInsert_manual_flush_adds_to_solr() {
     var entity = new Entity {Description = "pepe"};
     mockSolr.addDocParams += (e, p) => {
         Assert.AreSame(entity, e);
         Assert.IsNull(p);
         return null;
     };
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
         session.Flush();
     }
 }
 public void Add_includes_parameters_when_configured() {
     var entity = new Entity { Description = "pepe" };
     mockSolr.addDocParams += (doc, param) => {
         Assert.AreSame(entity, doc);
         Assert.AreSame(addParameters, param);
         return null;
     };
     mockSolr.addDocParams &= x => x.Expect(1);
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
         session.Flush();
     }
 }
Beispiel #10
0
 public void Insert_with_multiple_transactions2()
 {
     var entity = new Entity();
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Commit;
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Commit();
         }
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Rollback();
         }
     }
     mockSolr.AssertWasCalled(x => x.Add(entity, null), o => o.Repeat.Once().Return(null));
 }
Beispiel #11
0
 public void Insert_with_multiple_transactions2()
 {
     var entity = new Entity();
     mockSolr.Expect(x => x.Add(entity))
         .Repeat.Once()
         .Return(null);
     mockSolr.Replay();
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Commit;
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Commit();
         }
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Rollback();
         }
     }
     mockSolr.VerifyAllExpectations();
 }
Beispiel #12
0
 public void PostInsert_without_commit_doesnt_add_to_solr()
 {
     var entity = new Entity();
     using (var session = sessionFactory.OpenSession()) {
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Rollback();
         }
     }
     mockSolr.AssertWasNotCalled(x => x.Add(entity, null));
 }
Beispiel #13
0
 public void PostInsert_without_commit_doesnt_add_to_solr()
 {
     var entity = new Entity();
     mockSolr.Expect(x => x.Add(entity))
         .Repeat.Never()
         .Return(null);
     mockSolr.Replay();
     using (var session = sessionFactory.OpenSession()) {
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Rollback();
         }
     }
     mockSolr.VerifyAllExpectations();
 }
Beispiel #14
0
 public void PostInsert_manual_flush_without_flush_doesnt_add_to_solr()
 {
     var entity = new Entity {Description = "pepe"};
     mockSolr.Expect(x => x.Add(entity))
         .Repeat.Never()
         .Return(null);
     mockSolr.Replay();
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
     }
     mockSolr.VerifyAllExpectations();
 }
Beispiel #15
0
 public void PostInsert_manual_flush_without_flush_doesnt_add_to_solr()
 {
     var entity = new Entity {Description = "pepe"};
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Never;
         session.Save(entity);
     }
     mockSolr.AssertWasNotCalled(x => x.Add(entity, null));
 }
Beispiel #16
0
 public void Insert_with_multiple_transactions() {
     var entity = new Entity();
     mockSolr.addDocParams &= x => x.Expect(1);
     using (var session = sessionFactory.OpenSession()) {
         session.FlushMode = FlushMode.Commit;
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Rollback();
         }
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Commit();
         }
     }
 }
Beispiel #17
0
 public void PostInsert_with_commit_adds_to_solr()
 {
     var entity = new Entity();
     using (var session = sessionFactory.OpenSession()) {
         using (var tx = session.BeginTransaction()) {
             session.Save(entity);
             tx.Commit();
         }
     }
     mockSolr.AssertWasCalled(x => x.Add(entity, null), o => o.Repeat.Once().Return(null));
 }