Skip to content

Mattias Hedbom #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
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
28 changes: 25 additions & 3 deletions src/main/java/com/booleanuk/core/TodoItem.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.booleanuk.core;


// Abstraction exercise 1
public class TodoItem {
public String title;
public String detail;
public String status;
private String title;
private String detail;
private String status;

public TodoItem(String title, String detail, String status) {
this.title = title;
Expand All @@ -18,4 +20,24 @@ public void setStatus(String status) {
public String getStatus() {
return this.status;
}



public void setDetail(String detail) {
this.detail = detail;
}

public String getDetail() {
return this.detail;
}



public void setTitle(String title) {
this.title = title;
}

public String getTitle() {
return this.title;
}
}
57 changes: 57 additions & 0 deletions src/test/java/com/booleanuk/core/TodoItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,63 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

// Abstraction exercise 1
class TodoItemTest {

// Status
@Test
public void statusIsUpdated(){
TodoItem todoItem = new TodoItem("Clean room", "Vacuum the livingroom", "Incomplete");
String status = "completed";
todoItem.setStatus(status);

Assertions.assertEquals(status, todoItem.getStatus());
}

@Test
public void correctStatusIsRecieved(){
TodoItem todoItem = new TodoItem("Clean room", "Vacuum the livingroom", "Incomplete");

Assertions.assertEquals("Incomplete", todoItem.getStatus());
}


// Detail
@Test
public void detailIsChanged(){
TodoItem todoItem = new TodoItem("Clean room", "Vacuum the livingroom", "Incomplete");
String detail = "Clean the toilet";
todoItem.setDetail(detail);

Assertions.assertEquals(detail, todoItem.getDetail());
}

@Test
public void correctDetailIsRecieved(){
TodoItem todoItem = new TodoItem("Clean room", "Vacuum the livingroom", "Incomplete");

Assertions.assertEquals("Vacuum the livingroom", todoItem.getDetail());
}


// Title
@Test
public void titleIsChanged(){
TodoItem todoItem = new TodoItem("Clean room", "Vacuum the livingroom", "Incomplete");
String title = "Clean livingroom";
todoItem.setTitle(title);

Assertions.assertEquals(title, todoItem.getTitle());
}

@Test
public void correctTitleIsRecieved(){
TodoItem todoItem = new TodoItem("Clean room", "Vacuum the livingroom", "Incomplete");

Assertions.assertEquals("Clean room", todoItem.getTitle());
}




}
Loading