Пример #1
0
        public async Task ItemsCreated_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

            var expectedDataBaseName = await dataBaseContext.GenerateNewDataBaseNameAsync();

            var expectedComment    = RandomUtility.NextString();
            var actualDataBaseName = string.Empty;
            var actualComment      = string.Empty;
            await dataBaseContext.AddItemsCreatedEventHandlerAsync(DataBaseContext_ItemsCreated);

            await dataBaseContext.AddNewDataBaseAsync(authentication, expectedDataBaseName, expectedComment);

            Assert.AreEqual(expectedDataBaseName, actualDataBaseName);
            Assert.AreEqual(expectedComment, actualComment);

            await dataBaseContext.RemoveItemsCreatedEventHandlerAsync(DataBaseContext_ItemsCreated);

            await dataBaseContext.AddNewRandomDataBaseAsync(authentication);

            Assert.AreEqual(expectedDataBaseName, actualDataBaseName);
            Assert.AreEqual(expectedComment, actualComment);

            void DataBaseContext_ItemsCreated(object sender, ItemsCreatedEventArgs <IDataBase> e)
            {
                var dataBaseInfo = (DataBaseInfo)e.Arguments.Single();

                actualDataBaseName = dataBaseInfo.Name;
                actualComment      = dataBaseInfo.Comment;
            }
        }