Q.1.4 Make use of a class named EstateAgent that contains methods to calculate estate agent

sales, estate agent commission, and the top-performing estate agent. The EstateAgent
class must implement an IEstateAgent interface that contains the following:
public interface IEstateAgent {
double EstateAgentSales(double[] propertySales);
double EstateAgentCommission(double propertySales);
int TopEstateAgent(double[] totalSales);
}
Q.1.5 You are required to write unit tests for the application. Create a test package within the
application you created, which will contain the necessary unit tests.
You are required to write the following unit tests:
Test Name Test Purpose
CalculateTotalSales_ReturnsTotalSales() To supply the property sales to the
estate agent sales method. The test
will determine that the correct total
sales value is returned from the estate
agent sales method.
CalculateTotalCommission_ReturnsCommission() To supply a total property sales
amount to the estate agent
commission method. The test will
determine that the correct estate
agent commission has been
calculated.
TopAgent_ReturnsTopPosition() To supply total sales for each estate
agent to the top estate agent method.
The test will determine the top selling
total property sales for the estate
agent..include import method..In Java

1 answer

Here is an example of how the unit tests could be implemented in Java using the JUnit testing framework:

```
import org.junit.Test;
import static org.junit.Assert.*;

public class EstateAgentTests {

@Test
public void CalculateTotalSales_ReturnsTotalSales() {
EstateAgent estateAgent = new EstateAgent();
double[] propertySales = {100000.0, 150000.0, 200000.0};
double expectedTotalSales = 450000.0;

double actualTotalSales = estateAgent.EstateAgentSales(propertySales);

assertEquals(expectedTotalSales, actualTotalSales, 0.001);
}

@Test
public void CalculateTotalCommission_ReturnsCommission() {
EstateAgent estateAgent = new EstateAgent();
double propertySales = 250000.0;
double expectedCommission = 25000.0;

double actualCommission = estateAgent.EstateAgentCommission(propertySales);

assertEquals(expectedCommission, actualCommission, 0.001);
}

@Test
public void TopAgent_ReturnsTopPosition() {
EstateAgent estateAgent = new EstateAgent();
double[] totalSales = {300000.0, 250000.0, 350000.0};
int expectedTopPosition = 2;

int actualTopPosition = estateAgent.TopEstateAgent(totalSales);

assertEquals(expectedTopPosition, actualTopPosition);
}
}
```

Make sure to import the necessary classes and libraries for JUnit testing, and replace `EstateAgent` with the appropriate class name that implements the `IEstateAgent` interface.