Skip to content

Instantly share code, notes, and snippets.

View izmajlowiczl's full-sized avatar

Łukasz Izmajłowicz izmajlowiczl

View GitHub Profile
@Test
public void storeSingleWallet() {
Wallet bankWallet = Wallet.create(randomUUID(), "bank");
storage.insert(bankWallet);
assertThat(getStoredWalletNames())
.containsExactly("bank");
}
private List<String> getStoredWalletNames() {
public interface WalletsStorage {
/**
* List all stored {@link Wallet}s. Result is null safe
*
* @return Collection of all stored Wallets or Collections.emptyList() for empty result.
*/
Collection<Wallet> list();
/**
* Stores {@link Wallet} object.
package pl.expensive.db;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import java.util.List;
public class DatabaseSchemaTestHelper {
@izmajlowiczl
izmajlowiczl / build.gradle
Created February 19, 2016 21:16
Test results loggin to console
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
exceptionFormat 'full'
}
}
@izmajlowiczl
izmajlowiczl / DateUtilsTest.java
Created March 29, 2015 21:30
Exploratory test for DateUtils::getRelativeTimeSpanString class from Android SDK.
package pl.izmajlowiczl.bsj.delete_me;
import android.text.format.DateUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import java.util.Calendar;
@izmajlowiczl
izmajlowiczl / todayAt
Created November 19, 2014 09:11
Sets device time Usage: ./todatAt 10 23
#!/bin/sh
# Command to set date for running device:
# adb shell date -s yyyymmdd.hhmmss
now="$(date +'%Y%m%d')"
adb shell date -s $now.$1$2
@izmajlowiczl
izmajlowiczl / TheLastSyncTimestamp.java
Created May 9, 2014 08:37
SharedPreferences with Robolectric
import android.content.SharedPreferences;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class TheLastSyncTimestamp {
@Test
public void homeButtonHidesKeyboard() {
final MenuItem item = mock(MenuItem.class);
when(item.getItemId()).thenReturn(android.R.id.home);
testedFragment.onOptionsItemSelected(item);
verify(keyboardHackerMock).hideKeyboardAndResetBottomPaddingFor(any(View.class));
}
@izmajlowiczl
izmajlowiczl / TasksTestRunner.java
Created December 19, 2013 21:42
Custom RobolectricTestRunner with method for attaching fragments
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
/**
* Customized test runner based on {@link org.robolectric.RobolectricTestRunner}.
*
* Creator: <[email protected]>
@izmajlowiczl
izmajlowiczl / CustomDatePicker.java
Created September 20, 2013 04:16
Date/Time Picker fix for ScrollView
package com.mydriver.customer.ui.common.custom;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.widget.DatePicker;
/**