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

Commit

Permalink
Added Channel Tests. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Oct 29, 2019
1 parent e7bc787 commit 67b9254
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package net.cryptic_game.microservice.chat.channel;

import net.cryptic_game.microservice.wrapper.User;
import org.junit.Test;

import java.util.Date;
import java.util.UUID;

import static org.junit.Assert.*;

public class ChannelTests {

@Test
public void testGetUuid() {
final Channel channel = new Channel("test");
assertNotNull(channel.getUuid());
}

@Test
public void testGetName() {
final Channel channel = new Channel("test");
assertEquals("test", channel.getName());
}

@Test
public void testSetName() {
final Channel channel = new Channel("test");
channel.setName("test123");

assertEquals("test123", channel.getName());
}

@Test
public void testAddUser() {
final Channel channel = new Channel("test");
final User testUser = new User(UUID.randomUUID(), "test", "test@test.test", new Date(), new Date());
channel.addUser(testUser);

assertTrue(channel.getUsers().contains(testUser));
}

@Test
public void testRemoveUser() {
final Channel channel = new Channel("test");
final User testUser = new User(UUID.randomUUID(), "test", "test@test.test", new Date(), new Date());
channel.addUser(testUser);

if (!channel.getUsers().contains(testUser)) {
fail();
}

channel.removeUser(testUser);

assertFalse(channel.getUsers().contains(testUser));
}
}

0 comments on commit 67b9254

Please sign in to comment.