Tutorial application for my course about unit testing in Android
unit-testing-in-android-course's Introduction
unit-testing-in-android-course's People
Forkers
qskeksq rikenm gudun-ku yuricfurusho flima srikanth9792 ravichandra8 dymx101 tahaelhosseny oganbelema geniustomato ilgulee fhsbatista bepo00 steven-tjg gameofandroids sprinthubmobile saamyy rubenpla-develop albodelu lennykiano morristech elksa virgoxt houssemzaier victorvicari gatosempai shriharshs pabbu91 solidogen peter-wanden ofrederic tut195 mohitajwani gerosprime splendie fabiorbap rajput2122 manununhez hoossayn viihdavanzo elliotching khinthirisoe wellyogui anavarani mdikkii snthakarar jagdishkk1989 annalyjak codeallstar hadysalhab sunnyshetty blitzv wafaaabdelhafez essamahmed12 ramakrishnajoshi ohmp ahmedkhozam akjaw na95 rafaeltakiyama jlazar89 nguyenngoclinhchi mihudevcom alvindizon vinayjoglekar abhradeepghosh g3l0o aungthiha zizoh sebastian-troncoso jjlii dhananjaym2 shahwaiz90 bejaranix2 emanuelsaldivia kks161994 brunadanielle vanphuoclam satriyop jldelaguila prateeksaraswat10 carolquiterio ajayk1234 soethan98 schraut vishal6042 mayorjay gandalfr ifahimkhan puja110 haroldartienda polamokh muzafakar ogulcanucarsu azim00 learning-something-new manish2rana abishek-verma alokipandeyunit-testing-in-android-course's Issues
unit testing fundamentals exercise do not have description file.
Bug in Excercise 5
In Excercise 5, in EndpointResult class, getUsername() method returns UserId.
counter.java in Example6 under TestDoublesFundamentals should be renamed Counter.java
I received a compiler error during the Test Doubles Fundamentals section because counter.java is not named correctly.
Test Cases in Solution of Exercise 11 are not sufficiently reliable
Test Cases in Solution of Exercise 11 are not sufficiently reliable as they let my wrong implementation pass
My implementation only uses one variable for caching.
Please check
`public class FetchQuestionDetailsUseCase extends BaseObservable<FetchQuestionDetailsUseCase.Listener> {
public interface Listener {
void onQuestionDetailsFetched(QuestionDetails questionDetails);
void onQuestionDetailsFetchFailed();
}
private final int CACHING_TIME_OUT = 60000;
private final FetchQuestionDetailsEndpoint mFetchQuestionDetailsEndpoint;
private final TimeProvider mTimeProvider;
private final Map<String, QuestionDetails> cachedValueMap = new HashMap<>();
private long lastCachedTimestamp;
public FetchQuestionDetailsUseCase(FetchQuestionDetailsEndpoint fetchQuestionDetailsEndpoint,
TimeProvider timeProvider) {
mFetchQuestionDetailsEndpoint = fetchQuestionDetailsEndpoint;
mTimeProvider = timeProvider;
}
public void fetchQuestionDetailsAndNotify(String questionId) {
QuestionDetails cachedData = getValidCachedData(questionId);
if (cachedData != null) {
notifySuccess(cachedData);
} else {
mFetchQuestionDetailsEndpoint.fetchQuestionDetails(questionId, new FetchQuestionDetailsEndpoint.Listener() {
@Override
public void onQuestionDetailsFetched(QuestionSchema question) {
lastCachedTimestamp = mTimeProvider.getCurrentTimestamp();
QuestionDetails questionDetails = schemaToQuestionDetails(question);
cachedValueMap.put(questionId, questionDetails);
notifySuccess(questionDetails);
}
@Override
public void onQuestionDetailsFetchFailed() {
notifyFailure();
}
});
}
}
private QuestionDetails getValidCachedData(String questionId) {
QuestionDetails result = cachedValueMap.get(questionId);
if (result != null &&
mTimeProvider.getCurrentTimestamp() < lastCachedTimestamp + CACHING_TIME_OUT)
return result;
return null;
}
private void notifyFailure() {
for (Listener listener : getListeners()) {
listener.onQuestionDetailsFetchFailed();
}
}
private void notifySuccess(QuestionDetails question) {
for (Listener listener : getListeners()) {
listener.onQuestionDetailsFetched(question);
}
}
@NonNull
private static QuestionDetails schemaToQuestionDetails(QuestionSchema questionSchema) {
return new QuestionDetails(
questionSchema.getId(),
questionSchema.getTitle(),
questionSchema.getBody()
);
}
}
`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.