예제 #1
0
        public async Task ItemsLockChanged_Type_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

            var typeFilter       = new TypeFilter(TypeFlags.NotBeingEdited | TypeFlags.NotReferenced | TypeFlags.Public | TypeFlags.NotLocked);
            var typeItem         = (await typeFilter.GetTypeAsync(dataBase)) as ITypeItem;
            var expectedTypeItem = typeItem;
            var actualTypeItem   = null as ITypeItem;
            var comment          = RandomUtility.NextString();
            await typeContext.AddItemsLockChangedEventHandlerAsync(TypeContext_ItemsLockChanged);

            await typeItem.LockAsync(authentication, comment);

            await typeItem.UnlockAsync(authentication);

            Assert.AreEqual(expectedTypeItem, actualTypeItem);

            await typeContext.RemoveItemsLockChangedEventHandlerAsync(TypeContext_ItemsLockChanged);

            actualTypeItem = null;
            await typeItem.LockAsync(authentication, comment);

            Assert.IsNull(actualTypeItem);

            void TypeContext_ItemsLockChanged(object sender, ItemsEventArgs <ITypeItem> e)
            {
                if (e.Items.Single() is ITypeItem typeItem)
                {
                    actualTypeItem = typeItem;
                }
            }
        }