public async Task AddNewDataBaseAsync_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

            var dataBaseName = await dataBaseContext.GenerateNewDataBaseNameAsync();

            var comment = RandomUtility.NextString();
            await dataBaseContext.AddNewDataBaseAsync(authentication, dataBaseName, comment);
        }
Esempio n. 2
0
        public async Task Renamed_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

            var dataBase = await dataBaseContext.AddNewRandomDataBaseAsync(authentication);

            var expectedName = await dataBaseContext.GenerateNewDataBaseNameAsync();

            var oldName    = dataBase.Name;
            var actualName = string.Empty;
            await dataBase.AddRenamedEventHandlerAsync(DataBase_Renamed);

            await dataBase.RenameAsync(authentication, expectedName);

            Assert.AreEqual(expectedName, actualName);
            await dataBase.RemoveRenamedEventHandlerAsync(DataBase_Renamed);

            await dataBase.RenameAsync(authentication, oldName);

            Assert.AreEqual(expectedName, actualName);

            void DataBase_Renamed(object sender, EventArgs e)
            {
                if (sender is IDataBase dataBase)
                {
                    actualName = dataBase.Name;
                }
            }
        }
        public static async Task <IDataBase[]> GenerateDataBasesAsync(this IDataBaseContext dataBaseContext, Authentication authentication, int count)
        {
            var itemList = new List <IDataBase>(count);

            for (var i = 0; i < count; i++)
            {
                var dataBaseName = await dataBaseContext.GenerateNewDataBaseNameAsync(RandomUtility.NextName());

                var comment = RandomUtility.NextString();
                var item    = await dataBaseContext.AddNewDataBaseAsync(authentication, dataBaseName, comment);

                itemList.Add(item);
            }
            return(itemList.ToArray());
        }
        public async Task RenameAsync_Admin_TestAsync()
        {
            var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin);

            var dataBaseFilter = new DataBaseFilter(DataBaseFlags.NotLoaded | DataBaseFlags.Public | DataBaseFlags.NotLocked);
            var dataBase       = await dataBaseFilter.GetDataBaseAsync(app);

            var dataBaseName = await dataBaseContext.GenerateNewDataBaseNameAsync();

            await dataBase.RenameAsync(authentication, dataBaseName);

            Assert.AreEqual(dataBaseName, dataBase.Name);
        }