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

            var actualPath = string.Empty;
            await typeContext.AddItemsCreatedEventHandlerAsync(TypeContext_ItemsCreated);

            var typeItem1 = await typeContext.GenerateAsync(authentication);

            Assert.AreEqual(typeItem1.Path, actualPath);
            await typeContext.RemoveItemsCreatedEventHandlerAsync(TypeContext_ItemsCreated);

            var typeItem2 = await typeContext.GenerateAsync(authentication);

            Assert.AreEqual(typeItem1.Path, actualPath);
            Assert.AreNotEqual(typeItem2.Path, actualPath);

            void TypeContext_ItemsCreated(object sender, ItemsCreatedEventArgs <ITypeItem> e)
            {
                var typeItem = e.Items.Single();

                actualPath = typeItem.Path;
            }
        }