// Path: app/src/test/java/protect/rentalcalc/TestHelper.java
// static void checkIntField(int expected, String actual)
// {
//     if(actual.isEmpty())
//     {
//         assertEquals(expected, 0);
//     }
//     else
//     {
//         assertEquals(expected, Integer.parseInt(actual));
//     }
// }
// 
// Path: app/src/test/java/protect/rentalcalc/TestHelper.java
// static void preloadProperty(Property property) throws IllegalAccessException
// {
//     // Set the fields to some non-default value which should be
//     // different for every field
//     for(Field field : property.getClass().getDeclaredFields())
//     {
//         if(field.getType() == String.class)
//         {
//             String fieldName = field.getName();
//             String value = fieldName;
// 
//             // These are spinners and the possible values are limited
//             if(fieldName.equals("propertyBeds"))
//             {
//                 value = "5";
//             }
//             else if(fieldName.equals("propertyBaths"))
//             {
//                 value = "5.5";
//             }
// 
//             field.set(property, value);
//         }
// 
//         if(field.getType() == Integer.TYPE)
//         {
//             String fieldName = field.getName();
//             int value = Math.abs(fieldName.hashCode());
// 
//             // These are spinners and the possible values are limited
//             if(fieldName.equals("propertyType"))
//             {
//                 value = value % PropertyType.values().length;
//             }
//             else if(fieldName.equals("propertyParking"))
//             {
//                 value = value % ParkingType.values().length;
//             }
// 
//             Map<String, Integer> maxLengths = new HashMap<>();
//             maxLengths.put("purchasePrice", 13);
//             maxLengths.put("afterRepairsValue", 13);
//             maxLengths.put("downPayment", 3);
//             maxLengths.put("interestRate", 3);
//             maxLengths.put("loanDuration", 2);
//             maxLengths.put("purchaseCosts", 3);
//             maxLengths.put("repairRemodelCosts", 13);
//             maxLengths.put("grossRent", 7);
//             maxLengths.put("otherIncome", 7);
//             maxLengths.put("expenses", 6);
//             maxLengths.put("vacancy", 3);
//             maxLengths.put("appreciation", 3);
//             maxLengths.put("incomeIncrease", 3);
//             maxLengths.put("expenseIncrease", 3);
//             maxLengths.put("sellingCosts", 3);
//             maxLengths.put("landValue", 13);
//             maxLengths.put("incomeTaxRate", 3);
// 
//             if(maxLengths.containsKey(fieldName))
//             {
//                 String strValue = Integer.toString(value);
//                 int maxLength = maxLengths.get(fieldName);
//                 strValue = strValue.substring(0, Math.min(strValue.length(), maxLength));
//                 value = Integer.parseInt(strValue);
//             }
// 
//             field.set(property, value);
//         }
//     }
// }


import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Spinner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import org.robolectric.shadows.ShadowToast;
import java.util.Locale;
import static org.junit.Assert.assertNotNull;
import static protect.rentalcalc.TestHelper.checkIntField;
import static protect.rentalcalc.TestHelper.preloadProperty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;
        checkFields(activity, new Property());
    }

    @Test
    public void startWithoutProperty()
    {
        Intent intent = new Intent();
        final Bundle bundle = new Bundle();
        intent.putExtras(bundle);

        ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class, intent).create();
        Activity activity = (Activity)controller.get();

        checkFields(activity, new Property());
    }

    @Test
    public void startWithoutPropertyAndSave() throws IllegalAccessException
    {
        Intent intent = new Intent();
        final Bundle bundle = new Bundle();
        intent.putExtras(bundle);

        ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class, intent).create();
        Activity activity = (Activity)controller.get();
        controller.start();
        controller.visible();
        controller.resume();

        Property property = new Property();
// Path: app/src/test/java/protect/rentalcalc/TestHelper.java
// static void checkIntField(int expected, String actual)
// {
//     if(actual.isEmpty())
//     {
//         assertEquals(expected, 0);
//     }
//     else
//     {
//         assertEquals(expected, Integer.parseInt(actual));
//     }
// }
// 
// Path: app/src/test/java/protect/rentalcalc/TestHelper.java
// static void preloadProperty(Property property) throws IllegalAccessException
// {
//     // Set the fields to some non-default value which should be
//     // different for every field
//     for(Field field : property.getClass().getDeclaredFields())
//     {
//         if(field.getType() == String.class)
//         {
//             String fieldName = field.getName();
//             String value = fieldName;
// 
//             // These are spinners and the possible values are limited
//             if(fieldName.equals("propertyBeds"))
//             {
//                 value = "5";
//             }
//             else if(fieldName.equals("propertyBaths"))
//             {
//                 value = "5.5";
//             }
// 
//             field.set(property, value);
//         }
// 
//         if(field.getType() == Integer.TYPE)
//         {
//             String fieldName = field.getName();
//             int value = Math.abs(fieldName.hashCode());
// 
//             // These are spinners and the possible values are limited
//             if(fieldName.equals("propertyType"))
//             {
//                 value = value % PropertyType.values().length;
//             }
//             else if(fieldName.equals("propertyParking"))
//             {
//                 value = value % ParkingType.values().length;
//             }
// 
//             Map<String, Integer> maxLengths = new HashMap<>();
//             maxLengths.put("purchasePrice", 13);
//             maxLengths.put("afterRepairsValue", 13);
//             maxLengths.put("downPayment", 3);
//             maxLengths.put("interestRate", 3);
//             maxLengths.put("loanDuration", 2);
//             maxLengths.put("purchaseCosts", 3);
//             maxLengths.put("repairRemodelCosts", 13);
//             maxLengths.put("grossRent", 7);
//             maxLengths.put("otherIncome", 7);
//             maxLengths.put("expenses", 6);
//             maxLengths.put("vacancy", 3);
//             maxLengths.put("appreciation", 3);
//             maxLengths.put("incomeIncrease", 3);
//             maxLengths.put("expenseIncrease", 3);
//             maxLengths.put("sellingCosts", 3);
//             maxLengths.put("landValue", 13);
//             maxLengths.put("incomeTaxRate", 3);
// 
//             if(maxLengths.containsKey(fieldName))
//             {
//                 String strValue = Integer.toString(value);
//                 int maxLength = maxLengths.get(fieldName);
//                 strValue = strValue.substring(0, Math.min(strValue.length(), maxLength));
//                 value = Integer.parseInt(strValue);
//             }
// 
//             field.set(property, value);
//         }
//     }
// }


// Path: app/src/test/java/protect/rentalcalc/PropertyViewActivityTest.java
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Spinner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import org.robolectric.shadows.ShadowToast;
import java.util.Locale;
import static org.junit.Assert.assertNotNull;
import static protect.rentalcalc.TestHelper.checkIntField;
import static protect.rentalcalc.TestHelper.preloadProperty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;

        checkFields(activity, new Property());
    }

    @Test
    public void startWithoutProperty()
    {
        Intent intent = new Intent();
        final Bundle bundle = new Bundle();
        intent.putExtras(bundle);

        ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class, intent).create();
        Activity activity = (Activity)controller.get();

        checkFields(activity, new Property());
    }

    @Test
    public void startWithoutPropertyAndSave() throws IllegalAccessException
    {
        Intent intent = new Intent();
        final Bundle bundle = new Bundle();
        intent.putExtras(bundle);

        ActivityController controller = Robolectric.buildActivity(PropertyViewActivity.class, intent).create();
        Activity activity = (Activity)controller.get();
        controller.start();
        controller.visible();
        controller.resume();

        Property property = new Property();
        preloadProperty(property);