Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Create unit test for Toast logic #227

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2016-2017 DSpot Sp. z o.o
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dspot.declex.test.dialog.toastdialog;

import com.dspot.declex.test.R;

import static com.dspot.declex.actions.Action.*;

import org.androidannotations.annotations.EBean;


@EBean
public class ModelBean {
public void showMessage() {
$Toast("DecleX Test Now");
}

public void showMessageUsingResources() {
$Toast(R.string.message);
}
}
1 change: 1 addition & 0 deletions declex-test/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">DecleX Test</string>
<string name="message">DecleX Test Now</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.dspot.declex.test.dialog.toastdialog;

import com.dspot.declex.actions.ToastActionHolder_;
import com.dspot.declex.test.R;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import static org.junit.Assert.*;

@RunWith(RobolectricTestRunner.class)
@Config(
manifest = "app/src/main/AndroidManifest.xml",
sdk = 25
)
@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*", "org.powermock.*" })
@PrepareForTest({ToastActionHolder_.class})
public class TestToastDialog {

@Rule
public PowerMockRule rule = new PowerMockRule();

@Before
public void setUp() throws Exception {

}

@Test
public void testToastDialogAction() {
ToastActionHolder_ actionToastDialog = ToastActionHolder_.getInstance_(RuntimeEnvironment.application);
assertNotNull(actionToastDialog);
}

@Test
public void testToastDialogActionProperties() {
ToastActionHolder_ actionToastDialog = ToastActionHolder_.getInstance_(RuntimeEnvironment.application);
actionToastDialog.init("DecleX Test Now");
assertNotNull(actionToastDialog);
}

@Test
public void testToastDialogActionResources() {
ToastActionHolder_ actionToastDialog = ToastActionHolder_.getInstance_(RuntimeEnvironment.application);
actionToastDialog.init(R.string.message);
assertNotNull(actionToastDialog);
}
}