当前位置: 首页>>代码示例>>C#>>正文


C# Company.CompareTo方法代码示例

本文整理汇总了C#中Company.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Company.CompareTo方法的具体用法?C# Company.CompareTo怎么用?C# Company.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Company的用法示例。


在下文中一共展示了Company.CompareTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestJsonSerialization

        public void TestJsonSerialization()
        {
            try
            {
                IComparable<Company> hs = new Company();
                var some =
                    from c in new TestClientDataContext().Companies
                    where hs.CompareTo(c) != 0
                    select c;

                TestTransformationFramework.CSharpToJS(some.Expression);
            }
            catch (Exception ex)
            {
                var ex0 = ex;
                Assert.AreEqual(typeof(CSharpToJSException), ex0.GetType());
                Assert.IsNotNull(ex0.InnerException);

                var ex0_kvps = ((RelinqException)ex0).PrettyProperties;
                Assert.AreEqual("JsonSerialization", ex0_kvps["Type"]);
                Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]).Where(c => (value(Relinq.Playground.RelinqScriptBuilderExceptionsTests+<>c__DisplayClass8).hs.CompareTo(c) != 0))", ex0_kvps["Input"]);
                Assert.AreEqual("False", ex0_kvps["IsUnexpected"]);

                var ex1 = ex0.InnerException;
                Assert.AreEqual(typeof(LinqVisitorException), ex1.GetType());
                Assert.IsNotNull(ex1.InnerException);

                var ex1_kvps = ((RelinqException)ex1).PrettyProperties;
                Assert.AreEqual("value(Relinq.Infrastructure.Client.Beans.Bean`1[Relinq.Playground.Domain.Company]).Where(c => (value(Relinq.Playground.Domain.Company).CompareTo(c) != 0))", ex1_kvps["Root"]);
                Assert.AreEqual("value(Relinq.Playground.Domain.Company)", ex1_kvps["Expression"]);
                Assert.AreEqual("Constant", ex1_kvps["ExpressionType"]);
                Assert.AreEqual("False", ex1_kvps["IsUnexpected"]);

                var ex2 = ex1.InnerException;
                Assert.AreEqual(typeof(JsonSerializationException), ex2.GetType());
                Assert.IsNull(ex2.InnerException);

                var ex2_kvps = ((RelinqException)ex2).PrettyProperties;
                Assert.AreEqual("ActualVsExpectedTypeMismatch", ex2_kvps["Type"]);
                Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["Root"]);
                Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["RootActualType"]);
                Assert.AreEqual("System.IComparable`1[Relinq.Playground.Domain.Company]", ex2_kvps["RootExpectedType"]);
                Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["Target"]);
                Assert.AreEqual("Relinq.Playground.Domain.Company", ex2_kvps["ActualType"]);
                Assert.AreEqual("System.IComparable`1[Relinq.Playground.Domain.Company]", ex2_kvps["ExpectedType"]);
                Assert.AreEqual("Serialization metadata for type 'System.IComparable`1[[Relinq.Playground.Domain.Company, Relinq.Playground, Version=0.0.0.0, Culture=neutral, PublicKeyToken=ab3a3fb55cfc23d5]]': IsList = False, IsDictionary = False, IsPropertyBag = False, Properties = ", ex2_kvps["Metadata"]);
                Assert.AreEqual("False", ex2_kvps["IsUnexpected"]);


                return;
            }

            Assert.Fail("Expected exception wasn't thrown");
        }
开发者ID:xeno-by,项目名称:relinq,代码行数:54,代码来源:RelinqScriptBuilderExceptionsTests.cs


注:本文中的Company.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。