コード例 #1
0
        public async Task RestoreAndUpdateAsyncTest()
        {
            await _restoreService.RestoreAndUpdateAsync(_backup);

            await AssertDatabaseMatchesBackupAsync();

            var authenticators = await AuthenticatorRepository.GetAllAsync();

            for (var i = 0; i < authenticators.Count; i++)
            {
                var authenticator = authenticators[i];
                authenticator.Issuer = "test";
                await AuthenticatorRepository.UpdateAsync(authenticator);
            }

            var categories = await CategoryRepository.GetAllAsync();

            for (var i = 0; i < categories.Count; i++)
            {
                var category = categories[i];
                category.Name = "test";
                await CategoryRepository.UpdateAsync(category);
            }

            await _restoreService.RestoreAndUpdateAsync(_backup);

            authenticators = await AuthenticatorRepository.GetAllAsync();

            Assert.True(authenticators.All(a => a.Issuer != "test"));

            categories = await CategoryRepository.GetAllAsync();

            Assert.True(categories.All(a => a.Name != "test"));
        }
コード例 #2
0
        private async Task AssertDatabaseMatchesBackupAsync()
        {
            var authenticators = await AuthenticatorRepository.GetAllAsync();

            Assert.False(_backup.Authenticators.Except(authenticators, new AuthenticatorComparer()).Any());

            var categories = await CategoryRepository.GetAllAsync();

            Assert.False(_backup.Categories.Except(categories, new CategoryComparer()).Any());

            var authenticatorCategories = await AuthenticatorCategoryRepository.GetAllAsync();

            Assert.False(_backup.AuthenticatorCategories
                         .Except(authenticatorCategories, new AuthenticatorCategoryComparer()).Any());

            var customIcons = await CustomIconRepository.GetAllAsync();

            Assert.False(_backup.CustomIcons.Except(customIcons, new CustomIconComparer()).Any());
        }