Exemplo n.º 1
0
        public void EmptyTrait_is_everywhere()
        {
            CKTrait m = Context.EmptyTrait;

            Assert.That(m.ToString() == String.Empty, "Empty trait is the empty string.");
            Assert.That(m.IsAtomic, "Empty trait is considered as atomic.");
            Assert.That(m.AtomicTraits.Count == 0, "Empty trait has no atomic traits inside.");

            Assert.That(Context.FindOrCreate((string)null) == m, "Null gives the empty trait.");
            Assert.That(Context.FindOrCreate("") == m, "Obtaining empty string gives the empty trait.");
            Assert.That(Context.FindOrCreate("+") == m, "Obtaining '+' gives the empty trait.");
            Assert.Throws <ArgumentException>(() => Context.FindOrCreate(" \t \n  "), "No \n inside.");
            Assert.Throws <ArgumentException>(() => Context.FindOrCreate(" \r "), "No \r inside.");
            Assert.That(Context.FindOrCreate("+ \t +") == m, "Leading and trailing '+' are ignored.");
            Assert.That(Context.FindOrCreate("++++") == m, "Multiple + are ignored");
            Assert.That(Context.FindOrCreate("++  +++  + \t +") == m, "Multiple empty strings leads to empty trait.");

            Assert.That(Context.FindOnlyExisting(null), Is.Null);
            Assert.That(Context.FindOnlyExisting(""), Is.Null);
            Assert.That(Context.FindOnlyExisting(" "), Is.Null);
            Assert.That(Context.FindOnlyExisting(" ++  + "), Is.Null);
            Assert.That(Context.FindOnlyExisting("NONE"), Is.Null);
            Assert.That(Context.FindOnlyExisting("NO+NE"), Is.Null);
            Assert.That(Context.FindOnlyExisting("N+O+N+E"), Is.Null);
        }