1/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package androidx.navigation
18
19import android.support.test.filters.SmallTest
20import androidx.navigation.testing.TestNavigator
21import org.junit.Assert.assertSame
22import org.junit.Test
23import org.junit.runner.RunWith
24import org.junit.runners.JUnit4
25
26@SmallTest
27@RunWith(JUnit4::class)
28class NavigatorProviderTest {
29    private val provider = SimpleNavigatorProvider()
30
31    @Test
32    fun set() {
33        val navigator = TestNavigator()
34        provider[NAME] = navigator
35        val foundNavigator: Navigator<NavDestination> = provider[NAME]
36        assertSame("Set destination should be retrieved with get", navigator,
37                foundNavigator)
38    }
39
40    @Test
41    fun plusAssign() {
42        val navigator = TestNavigator()
43        provider += navigator
44        assertSame("Set destination should be retrieved with get", navigator,
45                provider[TestNavigator::class])
46    }
47}
48
49private const val NAME = "TEST"
50