All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.assertj.android.api.preference.MultiSelectListPreferenceAssert Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
// Copyright 2013 Square, Inc.
package org.assertj.android.api.preference;

import android.annotation.TargetApi;
import android.preference.MultiSelectListPreference;
import java.util.Set;

import static android.os.Build.VERSION_CODES.HONEYCOMB;
import static org.assertj.core.api.Assertions.assertThat;

/** Assertions for {@link MultiSelectListPreference} instances. */
@TargetApi(HONEYCOMB)
public class MultiSelectListPreferenceAssert extends
    AbstractDialogPreferenceAssert {
  public MultiSelectListPreferenceAssert(MultiSelectListPreference actual) {
    super(actual, MultiSelectListPreferenceAssert.class);
  }

  public MultiSelectListPreferenceAssert hasEntries(CharSequence... entries) {
    isNotNull();
    CharSequence[] actualEntries = actual.getEntries();
    assertThat(actualEntries) //
        .overridingErrorMessage("Expected entries <%s> but was <%s>.", entries, actualEntries) //
        .isEqualTo(entries);
    return this;
  }

  public MultiSelectListPreferenceAssert hasEntryValues(CharSequence... values) {
    isNotNull();
    CharSequence[] actualValues = actual.getEntryValues();
    assertThat(actualValues) //
        .overridingErrorMessage("Expected entry values <%s> but was <%s>.", values, actualValues) //
        .isEqualTo(values);
    return this;
  }

  public MultiSelectListPreferenceAssert hasValues(String... values) {
    isNotNull();
    Set actualValues = actual.getValues();
    assertThat(actualValues) //
        .overridingErrorMessage("Expected values <%s> but was <%s>.", values, actualValues) //
        .containsOnly(values);
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy