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

            var typeFilter = new TypeFilter();
            var type       = await typeFilter.GetTypeAsync(dataBase);

            var actualValue   = string.Empty;
            var expectedValue = type.TypeInfo.HashValue;
            var template      = type.Template;
            await typeContext.AddItemsChangedEventHandlerAsync(TypeContext_ItemsChanged);

            await template.BeginEditAsync(authentication);

            await template.ModifyRandomMembersAsync(authentication, 5);

            await template.EndEditAsync(authentication);

            Assert.AreNotEqual(expectedValue, actualValue);
            expectedValue = actualValue;
            await typeContext.RemoveItemsChangedEventHandlerAsync(TypeContext_ItemsChanged);

            await template.BeginEditAsync(authentication);

            await template.ModifyRandomMembersAsync(authentication, 5);

            await template.EndEditAsync(authentication);

            Assert.AreEqual(expectedValue, actualValue);

            void TypeContext_ItemsChanged(object sender, ItemsEventArgs <ITypeItem> e)
            {
                if (e.Items.Single() is IType type)
                {
                    actualValue = type.TypeInfo.HashValue;
                }
            }
        }