Skip to content

Commit

Permalink
Merge pull request #18 from Mofazzal874/Apan
Browse files Browse the repository at this point in the history
Integrate Testing done on User and MyCartModel
  • Loading branch information
Apn7 authored May 27, 2024
2 parents e5146fa + 9f5a5c0 commit 6590130
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public void update() {
// Update RecyclerView data
viewAllAdapters.notifyDataSetChanged();
}

@Override
protected void onDestroy() {
super.onDestroy();
Expand Down
53 changes: 53 additions & 0 deletions app/src/test/java/com/example/projecto/UserMyCartIT.java
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());
}
}

0 comments on commit 6590130

Please sign in to comment.