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

org.fest.assertions.api.android.util.PropertyAssert Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package org.fest.assertions.api.android.util;

import android.util.Property;
import org.fest.assertions.api.AbstractAssert;

import static org.fest.assertions.api.Assertions.assertThat;

/** Assertions for {@link Property} instances. */
public class PropertyAssert extends AbstractAssert, Property> {
  public PropertyAssert(Property actual) {
    super(actual, PropertyAssert.class);
  }

  public PropertyAssert hasName(String name) {
    isNotNull();
    String actualName = actual.getName();
    assertThat(actualName) //
        .overridingErrorMessage("Expected name <%s> but was <%s>", name, actualName) //
        .isEqualTo(name);
    return this;
  }

  public PropertyAssert hasType(Class type) {
    isNotNull();
    Class actualType = actual.getType();
    assertThat(actualType) //
        .overridingErrorMessage("Expected type <%s> but was <%s>", type, actualType) //
        .isEqualTo(type);
    return this;
  }

  public PropertyAssert isReadOnly() {
    isNotNull();
    assertThat(actual.isReadOnly()) //
        .overridingErrorMessage("Expected read only but was not read only.") //
        .isTrue();
    return this;
  }

  public PropertyAssert isNotReadOnly() {
    isNotNull();
    assertThat(actual.isReadOnly()) //
        .overridingErrorMessage("Expected not read only but was read only.") //
        .isFalse();
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy