コード例 #1
0
        // Analysis disable once InconsistentNaming
        public void dumping_objects_with_properties_produces_valid_json()
        {
            using (var lc = new LogConfigurator(FixtureName))
            {
                /*
                 * Class without any properties.
                 */
                var a = NoPropertiesSequenceGenerator.Sequence().GetEnumerator().Current;
                Assert.That(ValidateJson(NoPropertiesDumper.Dump(a)), Is.True);

                /*
                 * Class with only one built-in property.
                 */
                var b = OnePropertySequenceGenerator.Sequence().GetEnumerator().Current;
                Assert.That(ValidateJson(OnePropertyDumper.Dump(b)), Is.True);

                /*
                 * Class with multiple built-in properties.
                 */
                var c = PrimitiveBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                Assert.That(ValidateJson(PrimitiveBuiltinsDumper.Dump(c)), Is.True);

                /*
                 * Class with multiple object properties.
                 */
                var d = ComplexBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                Assert.That(ValidateJson(ComplexBuiltinsDumper.Dump(d)), Is.True);

                /*
                 * Class with an object property that is code generated.
                 */
                var e = AssociationSequenceGenerator.Sequence().GetEnumerator().Current;
                Assert.That(ValidateJson(AssociationDumper.Dump(e)), Is.True);
            }
        }
コード例 #2
0
 // Analysis disable once InconsistentNaming
 public void dumping_objects_without_properties_produces_valid_json()
 {
     using (var lc = new LogConfigurator(FixtureName))
     {
         var a = NoPropertiesSequenceGenerator.Sequence().GetEnumerator().Current;
         Assert.That(ValidateJson(NoPropertiesDumper.Dump(a)), Is.True);
     }
 }
コード例 #3
0
ファイル: equality_tests.cs プロジェクト: aislam62/dogen
        // Analysis disable once InconsistentNaming
        public void identical_objects_are_equal()
        {
            using (var lc = new LogConfigurator(FixtureName))
            {
                var a = ComplexBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                var b = ComplexBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("a: {0}", ComplexBuiltinsDumper.Dump(a));
                Log.DebugFormat("b: {0}", ComplexBuiltinsDumper.Dump(b));

                Assert.That(object.ReferenceEquals(a, b), Is.False);
                Assert.That(a.Equals(b), Is.True);
                Assert.That(a == b, Is.True);
                Assert.That(a != b, Is.False);

                var c = PrimitiveBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                var d = PrimitiveBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("c: {0}", PrimitiveBuiltinsDumper.Dump(c));
                Log.DebugFormat("d: {0}", PrimitiveBuiltinsDumper.Dump(d));

                Assert.That(object.ReferenceEquals(c, d), Is.False);
                Assert.That(c.Equals(d), Is.True);
                Assert.That(c == d, Is.True);
                Assert.That(c != d, Is.False);

                var e = NoPropertiesSequenceGenerator.Sequence().GetEnumerator().Current;
                var f = NoPropertiesSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("e: {0}", NoPropertiesDumper.Dump(e));
                Log.DebugFormat("f: {0}", NoPropertiesDumper.Dump(f));

                Assert.That(object.ReferenceEquals(e, f), Is.False);
                Assert.That(e.Equals(f), Is.True);
                Assert.That(e == f, Is.True);
                Assert.That(e != f, Is.False);

                var g = OnePropertySequenceGenerator.Sequence().GetEnumerator().Current;
                var h = OnePropertySequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("g: {0}", OnePropertyDumper.Dump(g));
                Log.DebugFormat("h: {0}", OnePropertyDumper.Dump(h));

                Assert.That(object.ReferenceEquals(g, h), Is.False);
                Assert.That(g.Equals(h), Is.True);
                Assert.That(g == h, Is.True);
                Assert.That(g != h, Is.False);

                var i = AssociationSequenceGenerator.Sequence().GetEnumerator().Current;
                var j = AssociationSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("g: {0}", AssociationDumper.Dump(i));
                Log.DebugFormat("h: {0}", AssociationDumper.Dump(j));

                Assert.That(object.ReferenceEquals(i, j), Is.False);
                Assert.That(i.Equals(j), Is.True);
                Assert.That(i == j, Is.True);
                Assert.That(i != j, Is.False);

                var k = Package1.AssociationInPackageSequenceGenerator.Sequence().GetEnumerator().Current;
                var m = Package1.AssociationInPackageSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("k: {0}", Package1.AssociationInPackageDumper.Dump(k));
                Log.DebugFormat("m: {0}", Package1.AssociationInPackageDumper.Dump(m));

                Assert.That(object.ReferenceEquals(k, m), Is.False);
                Assert.That(k.Equals(m), Is.True);
                Assert.That(k == m, Is.True);
                Assert.That(k != m, Is.False);

                var l = ShortPrimitiveSequenceGenerator.Sequence().GetEnumerator().Current;
                var n = ShortPrimitiveSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("l: {0}", ShortPrimitiveDumper.Dump(l));
                Log.DebugFormat("n: {0}", ShortPrimitiveDumper.Dump(n));

                Assert.That(object.ReferenceEquals(l, n), Is.False);
                Assert.That(l.Equals(n), Is.True);
                Assert.That(l == n, Is.True);
                Assert.That(l != n, Is.False);
            }
        }
コード例 #4
0
ファイル: equality_tests.cs プロジェクト: aislam62/dogen
        // Analysis disable once InconsistentNaming
        public void an_object_is_equal_to_itself()
        {
            using (var lc = new LogConfigurator(FixtureName))
            {
                #pragma warning disable 1718
                // warning CS1718: A comparison made to same variable. Did you mean to compare
                // warning CS1718: something else?
                var a = ComplexBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("a: {0}", ComplexBuiltinsDumper.Dump(a));
                // Analysis disable once EqualExpressionComparison
                Assert.That(a.Equals(a), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(a == a, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(a != a, Is.False);

                var b = PrimitiveBuiltinsSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("b: {0}", PrimitiveBuiltinsDumper.Dump(b));
                // Analysis disable once EqualExpressionComparison
                Assert.That(b.Equals(b), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(b == b, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(b != b, Is.False);

                var c = NoPropertiesSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("c: {0}", NoPropertiesDumper.Dump(c));
                // Analysis disable once EqualExpressionComparison
                Assert.That(c.Equals(c), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(c == c, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(c != c, Is.False);

                var d = OnePropertySequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("d: {0}", OnePropertyDumper.Dump(d));
                // Analysis disable once EqualExpressionComparison
                Assert.That(d.Equals(d), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(d == d, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(d != d, Is.False);

                var e = AssociationSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("e: {0}", AssociationDumper.Dump(e));
                // Analysis disable once EqualExpressionComparison
                Assert.That(e.Equals(e), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(e == e, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(e != e, Is.False);

                var f = Package1.AssociationInPackageSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("f: {0}", Package1.AssociationInPackageDumper.Dump(f));
                // Analysis disable once EqualExpressionComparison
                Assert.That(f.Equals(f), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(f == f, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(f != f, Is.False);

                var g = ShortPrimitiveSequenceGenerator.Sequence().GetEnumerator().Current;
                Log.DebugFormat("f: {0}", ShortPrimitiveDumper.Dump(g));
                // Analysis disable once EqualExpressionComparison
                Assert.That(g.Equals(g), Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(g == g, Is.True);
                // Analysis disable once EqualExpressionComparison
                Assert.That(g != g, Is.False);
                #pragma warning restore 1718
            }
        }