Bug 790 - testExecuteWhenValidCommandThenSuccess
Summary: testExecuteWhenValidCommandThenSuccess
Status: RESOLVED FIXED
Alias: None
Product: Gear and Member Management System for library
Classification: Unclassified
Component: Test (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- enhancement
Assignee: keithlam5
URL:
Depends on:
Blocks:
 
Reported: 2023-11-27 22:24 HKT by keithlam5
Modified: 2023-11-27 22:35 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description keithlam5 2023-11-27 22:24:40 HKT
The actual result is  "We do not have any sets for this gear." and it is the correct result. The expected result in the test case is set incorrectly.
----
   @Test
    public void testExecuteWhenValidCommandThenSuccess() {
        Member m1 = new Member("001", "keith");
        Member m2 = new Member("002", "jason");
        Member m3 = new Member("003", "paul");

        Gear e1 = new Gear("E1", "3D_Scanner");
        Gear e2 = new Gear("E2", "Smart_Glasses");

        cmd.execute(new String[] {"listGearStatus"});

        String expected =
                """                 
                [E1 3D_Scanner]
                  Current status: Unvailable
                
                [E2 Smart_Glasses]
                  Current status: Unvailable
                  
                """;
        assertEquals(expected, outContent.toString());

        CmdArrive cmdArrive = new CmdArrive();
        cmdArrive.execute(new String[] {"arrive", "E1"});
        cmdArrive.execute(new String[] {"arrive", "E2"});

        outContent.reset();

        cmd.execute(new String[] {"listMemberStatus"});

        expected = """
                [E1 3D_Scanner]
                  E1_1
                    Current status: Available
                                
                [E2 Smart_Glasses]
                  E2_1
                    Current status: Available
                    
                """;

        assertEquals(expected, outContent.toString());
Comment 1 keithlam5 2023-11-27 22:35:53 HKT
Changed the code to be:

String expected =
                """                 
                [E1 3D_Scanner]
                  We do not have any sets for this gear.
                
                [E2 Smart_Glasses]
                  We do not have any sets for this gear.
                  
                """;