package ru.job4j.generics;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertTrue;

/**
 * Test Class.
 */
public class UserStoreTest {

    /**
     * Test Method.
     */
    @Test
    public void whenAddShouldContains() {
        UserStore<User> users = new UserStore<>(7);
        User user1 = new User("235");
        users.add(user1);
        User result = (User) users.store.get(0);
        assertThat(result, is(user1));
    }

    /**
     * Test Method.
     */
    @Test
    public void whenGiveUserShouldDeleteIt() {
        UserStore<User> users = new UserStore<>(7);
        User user1 = new User("235");
        User user2 = new User("1795");

        users.add(user1);
        users.add(user2);

        users.delete("1795");
        User result = (User) users.store.get(1);
        assertTrue(result == null);
    }

    /**
     * Test Method.
     */
    @Test
    public void whenGiveUserShouldUpdate() {
        UserStore<User> users = new UserStore<>(7);
        User user1 = new User("235");
        User user2 = new User("1795");
        User user3 = new User("077");

        users.add(user1);
        users.add(user2);

        users.replace("235", user3);
        User result = (User) users.store.get(0);

        assertThat(result.getId(), is("077"));
    }

}

@@ -331,38 +331,32 @@
        UserStore
-%3CUser%3E
  users = new Use
@@ -353,34 +353,32 @@
  = new UserStore
-%3C%3E
 (7);%0A        Use
@@ -457,37 +457,42 @@
  = (User) users.
-s
+getS
 tore
+()
 .get(0);%0A       
@@ -632,38 +632,32 @@
        UserStore
-%3CUser%3E
  users = new Use
@@ -654,34 +654,32 @@
  = new UserStore
-%3C%3E
 (7);%0A        Use
@@ -859,29 +859,34 @@
 User) users.
-s
+getS
 tore
+()
 .get(1);%0A   
@@ -1037,14 +1037,8 @@
 tore
-%3CUser%3E
  use
@@ -1059,10 +1059,8 @@
 tore
-%3C%3E
 (7);
@@ -1305,13 +1305,18 @@
 ers.
-s
+getS
 tore
+()
 .get

Store extends Base2