protected virtual void ClearSharedRepositories()
 {
     using (Repositories.Use())
     {
         TestModelRepo.DeleteRange(TestModelRepo.GetAll(x => true), autoupdate: true);
         TestModel8Repo.DeleteRange(TestModel8Repo.GetAll(x => true), autoupdate: true);
         TestModel7Repo.DeleteRange(TestModel7Repo.GetAll(x => true), autoupdate: true);
     }
 }
Exemple #2
0
        private void SharedRerositoryMainPartTest()
        {
            TestModelRepoLazy  = new Lazy <IRepository <TestModel> >(() => Repositories.GetRepository <TestModel>());
            TestModel2RepoLazy = new Lazy <IRepository <TestModel2> >(() => Repositories.GetRepository <TestModel2>());


            IDisposable disposable;

            using (disposable = Repositories.Use())
            {
                disposable.Should().Be.OfType <SharedRepositories>();

                TestModelRepo.DeleteRange(TestModelRepo.GetAll()).UpdateAll();
                TestModel2Repo.DeleteRange(TestModel2Repo.GetAll()).UpdateAll();

                TestModelRepo.AddOne(new TestModel()
                {
                    TestId = 1, TestData = "blabla"
                }).UpdateAll();

                using (disposable = Repositories.Use())
                {
                    disposable.Should().Be.OfType <SharedRepositories.FakeDisposable>();
                    TestModel2Repo.AddOne(new TestModel2()
                    {
                        TestId = 1, TestData = "blabla"
                    }).UpdateAll();
                }

                ((object)TestModelRepo).Should().Be.SameAs(Repositories.GetRepository <TestModel>())
                .Should().Be.SameAs(Repositories.GetRepository <TestModel>());


                TestModelRepo.DeleteRange(TestModelRepo.GetAll()).UpdateAll();
                TestModel2Repo.DeleteRange(TestModel2Repo.GetAll()).UpdateAll();
            }
        }