Exemplo n.º 1
0
        public async Task ItemsLoaded_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

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

            var dataBaseFilter2 = new DataBaseFilter(DataBaseFlags.NotLoaded | 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.AddItemsLoadedEventHandlerAsync(DataBaseContext_ItemsLoaded);

            await dataBase1.LoadAsync(authentication);

            Assert.AreEqual(expectedDataBase, actualDataBase);

            await dataBaseContext.RemoveItemsLoadedEventHandlerAsync(DataBaseContext_ItemsLoaded);

            await dataBase2.LoadAsync(authentication);

            Assert.AreEqual(expectedDataBase, actualDataBase);

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

                actualDataBase = dataBase;
            }
        }