-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Mofazzal874/Apan
Integrate Testing done on User and MyCartModel
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.example.projecto; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import com.example.projecto.models.MyCartModel; | ||
import com.example.projecto.models.User; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class UserMyCartIT{ | ||
|
||
private User user; | ||
private MyCartModel cart; | ||
|
||
@Before | ||
public void setUp() { | ||
// Reset singleton instances before each test | ||
User.getInstance(); | ||
MyCartModel.getInstance(); | ||
|
||
// Initialize instances | ||
user = User.getInstance("John Doe", "john@example.com", "password123"); | ||
cart = MyCartModel.getInstance("Product Name", "100", "2023-05-27", "12:00", "1", 100.0); | ||
} | ||
|
||
@Test | ||
public void testUserAndCartIntegration() { | ||
// Update user details | ||
user.setEmail("newemail@example.com"); | ||
|
||
// Simulate an operation that might use updated user info | ||
String userEmail = user.getEmail(); | ||
|
||
// For demonstration purposes, assume cart operations depend on user info | ||
cart.setProductName("Product updated for " + userEmail); | ||
|
||
// Verify that the cart model correctly reflects the change | ||
assertEquals("Product updated for newemail@example.com", cart.getProductName()); | ||
} | ||
|
||
@Test | ||
public void testCartValues() { | ||
// Set new values in the cart | ||
cart.setTotalPrice(200.0); | ||
cart.setTotalQuantity("2"); | ||
|
||
// Verify cart values | ||
assertEquals(200.0, cart.getTotalPrice(), 0.0); | ||
assertEquals("2", cart.getTotalQuantity()); | ||
} | ||
} |