<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace NRoles.Engine.Test.Support.PlaceholderMethods {

  [RoleTest(
    Description = "Placeholder in composition method should be replaced by concrete role method",
    CompositionType = typeof(DeepThought),
    TestType = typeof(DeepThoughtTest))]

  public class RDeepThought : Role {
    public int Answer() { return 42; }
  }

  public class DeepThought : Does<RDeepThought> {
    [Placeholder] public int Answer() { return 4 + 2; }
  }

  public class DeepThoughtTest : DynamicTestFixture {
    public override void Test() {
      var thinker = new DeepThought();
      Assert.AreEqual(42, thinker.Answer());
    }
  }

  // TODO: think about placeholders in roles that are also compositions
  //    the placeholders make the method act like an abstract method
  //    their not necessary as abstract methods can be used in roles

  // TODO: placeholder in abstract method

  // TODO: placeholder in an override of a base-class member

  // TODO: calls to placeholder methods must change to callvirt? I don't think so.
}<commit_msg>comments<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace NRoles.Engine.Test.Support.PlaceholderMethods {

  [RoleTest(
    Description = "Placeholder in composition method should be replaced by concrete role method",
    CompositionType = typeof(DeepThought),
    TestType = typeof(DeepThoughtTest))]

  public class RDeepThought : Role {
    public int Answer() { return 42; }
  }

  public class DeepThought : Does<RDeepThought> {
    [Placeholder] public int Answer() { return 4 + 2; }
  }

  public class DeepThoughtTest : DynamicTestFixture {
    public override void Test() {
      var thinker = new DeepThought();
      Assert.AreEqual(42, thinker.Answer());
    }
  }

  // TODO: think about placeholders in roles that are also compositions
  //    the placeholders make the method act like an abstract method
  //    they're not necessary as abstract methods can be used in roles
  //      so issue an error message

  // TODO: placeholder in abstract method

  // TODO: placeholder in an override of a base-class member

  // TODO: calls to placeholder methods must change to callvirt? I don't think so.
}
{'fraction_non_alphanumeric': 0.08146897425073871, 'fraction_numerical': 0.005065428450823132, 'mean_word_length': 3.5229007633587788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6023416', 'n_tokens_mistral': 668, 'n_tokens_neox': 631, 'n_words': 247}