コード例 #1
0
        public async Task ItemsRenamed_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

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

            var oldDataBaseName      = dataBase.Name;
            var expectedDataBaseName = RandomUtility.NextName();
            var actualDataBaseName   = string.Empty;
            await dataBaseContext.AddItemsRenamedEventHandlerAsync(DataBaseContext_ItemsRenamed);

            await dataBase.RenameAsync(authentication, expectedDataBaseName);

            Assert.AreEqual(expectedDataBaseName, actualDataBaseName);

            await dataBaseContext.RemoveItemsRenamedEventHandlerAsync(DataBaseContext_ItemsRenamed);

            await dataBase.RenameAsync(authentication, oldDataBaseName);

            Assert.AreEqual(expectedDataBaseName, actualDataBaseName);

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

                actualDataBaseName = dataBase.Name;
            }
        }