コード例 #1
0
        public void WhenIndexDefinitionDidNotChangeThenWeShouldNotThrowErrorIfIndexIsInLockedErrorState()
        {
            using (var store = GetDocumentStore())
            {
                var index = new People_ByName();
                index.Execute(store);

                store.Maintenance.Send(new SetIndexesLockOperation(index.IndexName, IndexLockMode.LockedError));

                index.Execute(store);

                store.Maintenance.Send(new SetIndexesLockOperation(index.IndexName, IndexLockMode.Unlock));

                var definition = index.CreateIndexDefinition();
                definition.LockMode       = IndexLockMode.LockedError;
                definition.Fields["Name"] = new IndexFieldOptions
                {
                    Storage = FieldStorage.Yes
                };

                store.Maintenance.Send(new PutIndexesOperation(definition));

                WaitForIndexing(store);

                var e = Assert.Throws <RavenException>(() => index.Execute(store));
                Assert.Contains("IndexAlreadyExistException", e.Message);
            }
        }
コード例 #2
0
ファイル: RavenDB_4110.cs プロジェクト: xinix00/ravendb
        public void WhenIndexDefinitionDidNotChangeThenWeShouldNotThrowErrorIfIndexIsInLockedErrorState()
        {
            using (var store = NewDocumentStore())
            {
                var index = new People_ByName();
                index.Execute(store);

                store.DatabaseCommands.SetIndexLock(index.IndexName, IndexLockMode.LockedError);

                index.Execute(store);
                index.SideBySideExecute(store);

                store.DatabaseCommands.SetIndexLock(index.IndexName, IndexLockMode.Unlock);

                var definition = index.CreateIndexDefinition();
                definition.SortOptions["Name"] = SortOptions.Int;
                store.DatabaseCommands.PutIndex(index.IndexName, definition, true);

                store.DatabaseCommands.SetIndexLock(index.IndexName, IndexLockMode.LockedError);

                Assert.Throws <IndexCompilationException>(() => index.Execute(store));
                Assert.Throws <InvalidOperationException>(() => index.SideBySideExecute(store));
            }
        }