public void single_spec() { Animal animal = new Animal { Age = 1, Health = HealthStatus.Healthy, Type = AnimalType.Cow }; var package = new IPackage() { Entity = animal }; var spec = new CowSpecification(); Outcome outcome = spec.IsSatisfiedBy(package); Assert.IsTrue(outcome.Result); }
public void get_type_from_name() { CowSpecification spec = new CowSpecification(); string name = "CowSpecification"; string nSpace = spec.GetType().Namespace; Assembly assembly = typeof(CowSpecification).Assembly; // in the same assembly! Type type = assembly.GetType(string.Format("{0}.{1}", nSpace, name)); // full name - i.e. with namespace (perhaps concatenate) object obj = Activator.CreateInstance(type); Assert.IsNotNull(obj); }