Skip to content

Uebung fakes.v2.0#32

Open
cm-clodos wants to merge 5 commits intoibwgr:masterfrom
cm-clodos:uebung-fakes.V2.0
Open

Uebung fakes.v2.0#32
cm-clodos wants to merge 5 commits intoibwgr:masterfrom
cm-clodos:uebung-fakes.V2.0

Conversation

@cm-clodos
Copy link

Danke für das Mail und die überarbeiteten Tests :) Hier ist mein zweiter Versuch

PersonTest.java , Tests zu isTeen() geschrieben
UserValidatorTest + UserControllerTest 2. Version
Copy link
Contributor

@ideadapt ideadapt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bis auf ein par Kleinigkeiten schaut das super aus. Glaube du hast das Prinzip verstanden!

UserValidator mockitoUv = mock(UserValidator.class);
UserController ctrl = new UserController(mockitoDb, mockitoUv);
//Wenn methoden isValidUsername && doesUsernameExist.thenReturn (Boolean wert)
when(mockitoUv.isValidUsername(anyString())).thenReturn(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testname müsste dann mit withInvalid beginnen ;)

UserController ctrl = new UserController(mockitoUv);
User user = new User("Martin");
//Mockito Returnwert setzen
doReturn(true).when(mockitoUv).doesUsernameExist("Martin");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testname müsste dann mit withValidExistingUsername_ starten ;)

//Act
ctrl.create(user);
boolean userInDB;
userInDB = mockDb.getUsers() == mockDb.users;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getUsers und users ist ja das gleiche objekt. unabhängig davon wieviele elemente in der liste sind, der vergleich ist immer true :)

// Is teen if Age 12 <= && >=18
Period age = getAge();
years = age.getYears();
if (years >= 12 && years <= 18){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

teen kommt von "thirTEEN" und nicht von "twelve" ;)

Nach review überarbeitet :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants