예제 #1
0
        public async Task ItemsAccessChanged_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;
            await typeContext.AddItemsAccessChangedEventHandlerAsync(TypeContext_ItemsAccessChanged);

            await typeItem.SetPrivateAsync(authentication);

            await typeItem.SetPublicAsync(authentication);

            Assert.AreEqual(expectedTypeItem, actualTypeItem);

            await typeContext.RemoveItemsAccessChangedEventHandlerAsync(TypeContext_ItemsAccessChanged);

            actualTypeItem = null;
            await typeItem.SetPrivateAsync(authentication);

            Assert.IsNull(actualTypeItem);

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