小编Alv*_* RC的帖子

ViewCompat.getWindowInsetsController 已弃用 - 使用哪个替代方案?

更新到 Android Gradle 插件版本后,Jetpack Compose 项目的7.2.2默认文件会出现警告:Theme.kt

ViewCompat.getWindowInsetsController is deprecated
Run Code Online (Sandbox Code Playgroud)

此警告来自项目脚手架期间提供的默认实现:

/* snip */
val view = LocalView.current
    if (!view.isInEditMode) {
        SideEffect {
            (view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
            ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme // <--- This triggers a deprecation warning
        }
    }
Run Code Online (Sandbox Code Playgroud)

文档建议使用WindowCompat.getInsetsController- 但该函数需要访问 aview和 a window

是否有一种简单的方法可以解决此警告而不忽略它?

android kotlin material-components-android android-jetpack-compose

21
推荐指数
1
解决办法
5429
查看次数

How to properly mock MongoDbClient

Context

I'm writing unit tests for an API I've been developing and I just ran into an issue while trying to UnitTest a "Context" for accessing a MongoDB Storage.

I abstracted the current interface for my context:

public interface IProjectsContext
{
    IMongoCollection<Project> Projects { get; }
}
Run Code Online (Sandbox Code Playgroud)

I'm able to successfully use this interface, together with Moq to UnitTest my Repositories.

However, when trying to UnitTest my Context's implementation I've been unable to muster a solution for mocking the inwards: …

c# unit-testing mongodb asp.net-core

2
推荐指数
1
解决办法
2323
查看次数