|
| 1 | +package com.google.unity.ads.nativead; |
| 2 | + |
| 3 | +import static com.google.common.truth.Truth.assertThat; |
| 4 | + |
| 5 | +import com.google.testing.junit.testparameterinjector.TestParameter; |
| 6 | +import org.junit.Test; |
| 7 | +import org.junit.runner.RunWith; |
| 8 | +import org.robolectric.RobolectricTestParameterInjector; |
| 9 | + |
| 10 | +/** Tests for {@link UnityNativeTemplateType} */ |
| 11 | +@RunWith(RobolectricTestParameterInjector.class) |
| 12 | +public final class UnityNativeTemplateTypeTest { |
| 13 | + |
| 14 | + private enum TemplateTypeTestCase { |
| 15 | + INVALID_INDEX(-1, UnityNativeTemplateType.MEDIUM), // should return default value |
| 16 | + ZERO(0, UnityNativeTemplateType.SMALL), |
| 17 | + ONE(1, UnityNativeTemplateType.MEDIUM), |
| 18 | + MISSING_INDEX(2, UnityNativeTemplateType.MEDIUM); // should return default value |
| 19 | + |
| 20 | + final int intValue; |
| 21 | + final UnityNativeTemplateType expectedTemplateType; |
| 22 | + |
| 23 | + TemplateTypeTestCase(int intValue, UnityNativeTemplateType expectedTemplateType) { |
| 24 | + this.intValue = intValue; |
| 25 | + this.expectedTemplateType = expectedTemplateType; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + public void fromIntValue_returnsCorrectTemplateType(@TestParameter TemplateTypeTestCase testCase) |
| 31 | + throws Exception { |
| 32 | + assertThat(UnityNativeTemplateType.fromIntValue(testCase.intValue)) |
| 33 | + .isEqualTo(testCase.expectedTemplateType); |
| 34 | + assertThat(UnityNativeTemplateType.fromIntValue(testCase.intValue).resourceId()) |
| 35 | + .isEqualTo(testCase.expectedTemplateType.resourceId()); |
| 36 | + } |
| 37 | +} |
0 commit comments