package net.sf.anathema.hero.template.parser;

import net.sf.anathema.hero.template.TemplateTypeImpl;
import net.sf.anathema.character.framework.xml.GenericCharacterTemplate;
import net.sf.anathema.character.framework.xml.presentation.GenericPresentationTemplate;
import net.sf.anathema.hero.dummy.DummyMundaneCharacterType;
import net.sf.anathema.lib.util.SimpleIdentifier;
import org.junit.Assert;
import org.junit.Test;

public class GenericPresentationPropertiesTest {

  @Test
  public void subtypedAutoGeneratedNewResource() throws Exception {
    GenericPresentationTemplate template = setTemplateType(new TemplateTypeImpl(new DummyMundaneCharacterType(), new SimpleIdentifier("HeroicSubtype")));
    assertExpectedResource(template, "CharacterGenerator.Templates.Dummy.HeroicSubtype");
  }

  private GenericPresentationTemplate setTemplateType(TemplateTypeImpl templateType) {
    GenericCharacterTemplate dummyCharacterTemplate = new GenericCharacterTemplate();
    dummyCharacterTemplate.setTemplateType(templateType);
    return new GenericPresentationTemplate(dummyCharacterTemplate);
  }

  private void assertExpectedResource(GenericPresentationTemplate template, String expected) {
    Assert.assertEquals(expected, template.getNewActionResource());
  }
}