Пример #1
0
        public async Task ItemsUnloaded_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

            var dataBaseFilter1 = new DataBaseFilter(DataBaseFlags.Loaded | DataBaseFlags.Public | DataBaseFlags.NotLocked);
            var dataBase1       = await dataBaseFilter1.GetDataBaseAsync(app);

            var dataBaseFilter2 = new DataBaseFilter(DataBaseFlags.Loaded | DataBaseFlags.Public | DataBaseFlags.NotLocked)
            {
                ExcludedDataBaseNames = new string[] { dataBase1.Name }
            };
            var dataBase2 = await dataBaseFilter2.GetDataBaseAsync(app);

            var expectedDataBase = dataBase1;
            var actualDataBase   = null as IDataBase;
            await dataBaseContext.AddItemsUnloadedEventHandlerAsync(DataBaseContext_ItemsUnloaded);

            await dataBase1.UnloadAsync(authentication);

            Assert.AreEqual(expectedDataBase, actualDataBase);

            await dataBaseContext.RemoveItemsUnloadedEventHandlerAsync(DataBaseContext_ItemsUnloaded);

            await dataBase2.UnloadAsync(authentication);

            Assert.AreEqual(expectedDataBase, actualDataBase);

            void DataBaseContext_ItemsUnloaded(object sender, ItemsEventArgs <IDataBase> e)
            {
                var dataBase = e.Items.Single() as IDataBase;

                actualDataBase = dataBase;
            }
        }