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

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

            var dataBaseInfo             = dataBase.DataBaseInfo;
            var typeContext              = dataBase.GetService(typeof(ITypeContext)) as ITypeContext;
            var expectedModificationInfo = dataBaseInfo.ModificationInfo;
            var actualModificationInfo   = dataBaseInfo.ModificationInfo;

            await dataBase.EnterAsync(authentication);

            await dataBaseContext.AddItemsInfoChangedEventHandlerAsync(DataBaseContext_ItemsInfoChanged);

            await typeContext.AddRandomCategoryAsync(authentication);

            Assert.AreNotEqual(expectedModificationInfo, actualModificationInfo);
            actualModificationInfo = expectedModificationInfo;

            await dataBaseContext.RemoveItemsInfoChangedEventHandlerAsync(DataBaseContext_ItemsInfoChanged);

            await typeContext.AddRandomCategoryAsync(authentication);

            await dataBase.LeaveAsync(authentication);

            Assert.AreEqual(expectedModificationInfo, actualModificationInfo);

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

                actualModificationInfo = dataBase.DataBaseInfo.ModificationInfo;
            }
        }