public void Traits_must_belong_to_the_same_context() { Assert.Throws <ArgumentException>(() => new CKTraitContext(null)); Assert.Throws <ArgumentException>(() => new CKTraitContext(" ")); CKTraitContext c1 = new CKTraitContext("C1"); CKTraitContext c2 = new CKTraitContext("C2"); var t1 = c1.FindOrCreate("T1"); var t2 = c2.FindOrCreate("T2"); Assert.That(t1 != t2); Assert.Throws <InvalidOperationException>(() => t1.Union(t2)); Assert.Throws <InvalidOperationException>(() => t1.Intersect(t2)); Assert.Throws <InvalidOperationException>(() => t1.Except(t2)); Assert.Throws <InvalidOperationException>(() => t1.SymmetricExcept(t2)); Assert.Throws <InvalidOperationException>(() => t1.Overlaps(t2)); Assert.Throws <InvalidOperationException>(() => t1.IsSupersetOf(t2)); Assert.Throws <ArgumentNullException>(() => t1.Union(null)); Assert.Throws <ArgumentNullException>(() => t1.Intersect(null)); Assert.Throws <ArgumentNullException>(() => t1.Except(null)); Assert.Throws <ArgumentNullException>(() => t1.SymmetricExcept(null)); Assert.Throws <ArgumentNullException>(() => t1.Overlaps(null)); Assert.Throws <ArgumentNullException>(() => t1.IsSupersetOf(null)); Assert.Throws <ArgumentNullException>(() => t1.CompareTo(null)); Assert.Throws <ArgumentNullException>(() => c1.CompareTo(null)); }
public void Comparing_tags() { CKTraitContext c1 = CKTraitContext.Create( "C1" ); CKTraitContext c2 = CKTraitContext.Create( "C2" ); c1.CompareTo( c1 ).Should().Be( 0 ); c1.CompareTo( c2 ).Should().BeLessThan( 0 ); var tAc1 = c1.FindOrCreate( "A" ); var tBc1 = c1.FindOrCreate( "B" ); var tABc1 = c1.FindOrCreate( "A|B" ); var tAc2 = c2.FindOrCreate( "A" ); tAc1.CompareTo( tAc1 ).Should().Be( 0 ); tAc1.CompareTo( tBc1 ).Should().BeGreaterThan( 0, "In the same context, A is stronger than B." ); tABc1.CompareTo( tBc1 ).Should().BeGreaterThan( 0, "In the same context, A|B is stronger than B." ); tAc1.CompareTo( tAc2 ).Should().BeLessThan( 0, "Between different contexts, the context ordering drives the ordering." ); tABc1.CompareTo( tAc2 ).Should().BeLessThan( 0, "Between different contexts, the context ordering drives the ordering." ); }
public void Comparing_traits() { CKTraitContext c1 = new CKTraitContext("C1"); CKTraitContext c1Bis = new CKTraitContext("C1"); CKTraitContext c2 = new CKTraitContext("C2"); Assert.That(c1.CompareTo(c1), Is.EqualTo(0)); Assert.That(c1.CompareTo(c2), Is.LessThan(0)); Assert.That(c1Bis.CompareTo(c1), Is.GreaterThan(0)); var tAc1 = c1.FindOrCreate("A"); var tBc1 = c1.FindOrCreate("B"); var tABc1 = c1.FindOrCreate("A|B"); var tAc2 = c2.FindOrCreate("A"); Assert.That(tAc1.CompareTo(tAc1), Is.EqualTo(0)); Assert.That(tAc1.CompareTo(tBc1), Is.GreaterThan(0), "In the same context, A is stronger than B."); Assert.That(tABc1.CompareTo(tBc1), Is.GreaterThan(0), "In the same context, A|B is stronger than B."); Assert.That(tAc1.CompareTo(tAc2), Is.LessThan(0), "Between different contexts, the context ordering drives the ordering."); Assert.That(tABc1.CompareTo(tAc2), Is.LessThan(0), "Between different contexts, the context ordering drives the ordering."); }
public void Comparing_traits() { CKTraitContext c1 = new CKTraitContext( "C1" ); CKTraitContext c1Bis = new CKTraitContext( "C1" ); CKTraitContext c2 = new CKTraitContext( "C2" ); Assert.That( c1.CompareTo( c1 ), Is.EqualTo( 0 ) ); Assert.That( c1.CompareTo( c2 ), Is.LessThan( 0 ) ); Assert.That( c1Bis.CompareTo( c1 ), Is.GreaterThan( 0 ) ); var tAc1 = c1.FindOrCreate( "A" ); var tBc1 = c1.FindOrCreate( "B" ); var tABc1 = c1.FindOrCreate( "A|B" ); var tAc2 = c2.FindOrCreate( "A" ); Assert.That( tAc1.CompareTo( tAc1 ), Is.EqualTo( 0 ) ); Assert.That( tAc1.CompareTo( tBc1 ), Is.GreaterThan( 0 ), "In the same context, A is stronger than B." ); Assert.That( tABc1.CompareTo( tBc1 ), Is.GreaterThan( 0 ), "In the same context, A|B is stronger than B." ); Assert.That( tAc1.CompareTo( tAc2 ), Is.LessThan( 0 ), "Between different contexts, the context ordering drives the ordering." ); Assert.That( tABc1.CompareTo( tAc2 ), Is.LessThan( 0 ), "Between different contexts, the context ordering drives the ordering." ); }
public void Traits_must_belong_to_the_same_context() { Assert.Throws<ArgumentException>( () => new CKTraitContext( null ) ); Assert.Throws<ArgumentException>( () => new CKTraitContext( " " ) ); CKTraitContext c1 = new CKTraitContext( "C1" ); CKTraitContext c2 = new CKTraitContext( "C2" ); var t1 = c1.FindOrCreate( "T1" ); var t2 = c2.FindOrCreate( "T2" ); Assert.That( t1 != t2 ); Assert.Throws<InvalidOperationException>( () => t1.Union( t2 ) ); Assert.Throws<InvalidOperationException>( () => t1.Intersect( t2 ) ); Assert.Throws<InvalidOperationException>( () => t1.Except( t2 ) ); Assert.Throws<InvalidOperationException>( () => t1.SymmetricExcept( t2 ) ); Assert.Throws<InvalidOperationException>( () => t1.Overlaps( t2 ) ); Assert.Throws<InvalidOperationException>( () => t1.IsSupersetOf( t2 ) ); Assert.Throws<ArgumentNullException>( () => t1.Union( null ) ); Assert.Throws<ArgumentNullException>( () => t1.Intersect( null ) ); Assert.Throws<ArgumentNullException>( () => t1.Except( null ) ); Assert.Throws<ArgumentNullException>( () => t1.SymmetricExcept( null ) ); Assert.Throws<ArgumentNullException>( () => t1.Overlaps( null ) ); Assert.Throws<ArgumentNullException>( () => t1.IsSupersetOf( null ) ); Assert.Throws<ArgumentNullException>( () => t1.CompareTo( null ) ); Assert.Throws<ArgumentNullException>( () => c1.CompareTo( null ) ); }