예제 #1
0
        public async Task ItemsLockChanged_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 expectedComment = RandomUtility.NextString();
            var actualValue     = dataBase.LockInfo.IsNotLocked;
            var actualComment   = string.Empty;

            await dataBaseContext.AddItemsLockChangedEventHandlerAsync(DataBaseContext_ItemsLockChanged);

            await dataBase.LockAsync(authentication, expectedComment);

            Assert.IsFalse(actualValue);
            Assert.AreEqual(expectedComment, actualComment);

            await dataBaseContext.RemoveItemsLockChangedEventHandlerAsync(DataBaseContext_ItemsLockChanged);

            await dataBase.UnlockAsync(authentication);

            Assert.IsFalse(actualValue);
            Assert.AreEqual(expectedComment, actualComment);

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

                actualValue   = dataBase.LockInfo.IsNotLocked;
                actualComment = dataBase.LockInfo.Comment;
            }
        }