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


C# Mock.GetHashCode方法代码示例

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


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

示例1: CreateDataset

        private static Mock<IProxyDataset> CreateDataset(int index, IEnumerable<Mock<IProxyDataset>> children)
        {
            var proxy = new Mock<IProxyDataset>();
            {
                proxy.Setup(p => p.Name)
                    .Returns(index.ToString(CultureInfo.InvariantCulture));
                proxy.Setup(p => p.Children())
                    .Returns(children.Select(c => c.Object));
                proxy.Setup(p => p.Id)
                    .Returns(new DatasetId(index));
                proxy.Setup(d => d.Equals(It.IsAny<IProxyDataset>()))
                    .Returns<IProxyDataset>(other => ReferenceEquals(other, proxy.Object));
                proxy.Setup(d => d.Equals(It.IsAny<object>()))
                    .Returns<object>(other => ReferenceEquals(other, proxy.Object));
                proxy.Setup(d => d.GetHashCode())
                    .Returns(proxy.GetHashCode());
            }

            return proxy;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:20,代码来源:DatasetGraphPresenterTest.cs

示例2: CreateDynamicType

 private static Type CreateDynamicType(DynamicType dynamicType)
 {
     Mock<Type> type = new Mock<Type>();
     type.Setup(t => t.Name).Returns(dynamicType.TypeName);
     type.Setup(t => t.Namespace).Returns("SampleNamespace");
     type.Setup(t => t.FullName).Returns("SampleNamespace." + dynamicType.TypeName);
     type
         .Setup(t => t.GetProperties(It.IsAny<BindingFlags>()))
         .Returns(dynamicType.Properties.Select(property => CreateProperty(property, type.Object)).Cast<PropertyInfo>().ToArray());
     type.Setup(t => t.IsAssignableFrom(type.Object)).Returns(true);
     type.Setup(t => t.GetHashCode()).Returns(type.GetHashCode());
     type.Setup(t => t.Equals(It.IsAny<object>())).Returns((Type t) => Object.ReferenceEquals(type.Object, t));
     return type.Object;
 }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataConventionModelBuilderTests.cs

示例3: CreateProperty

        private static PropertyInfo CreateProperty(DynamicProperty property, Type reflectedType)
        {
            Mock<PropertyInfo> pi = new Mock<PropertyInfo>();
            pi.Setup(p => p.Name).Returns(property.Name);

            if (property.Type is DynamicType)
            {
                property.Type = CreateDynamicType(property.Type as DynamicType);
            }

            pi.Setup(p => p.PropertyType).Returns(property.Type as Type);
            pi.Setup(p => p.ReflectedType).Returns(reflectedType);
            pi.Setup(p => p.DeclaringType).Returns(reflectedType);
            pi.Setup(p => p.CanRead).Returns(true);
            pi.Setup(p => p.CanWrite).Returns(true);
            pi.Setup(p => p.GetGetMethod(It.IsAny<bool>())).Returns(typeof(Product).GetProperty("ID").GetGetMethod());
            pi.Setup(p => p.GetCustomAttributes(It.IsAny<bool>())).Returns(property.Attributes);
            pi.Setup(p => p.GetHashCode()).Returns(pi.GetHashCode());
            pi.Setup(p => p.Equals(It.IsAny<object>())).Returns((PropertyInfo p) => Object.ReferenceEquals(pi.Object, p));
            return pi.Object;
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:21,代码来源:ODataConventionModelBuilderTests.cs

示例4: CreateMockDataset

        private static IProxyDataset CreateMockDataset()
        {
            var dataset = new Mock<IProxyDataset>();
            {
                dataset.Setup(d => d.Equals(It.IsAny<IProxyDataset>()))
                    .Returns<IProxyDataset>(other => ReferenceEquals(other, dataset.Object));

                dataset.Setup(d => d.Equals(It.IsAny<object>()))
                    .Returns<object>(other => ReferenceEquals(other, dataset.Object));

                dataset.Setup(d => d.GetHashCode())
                    .Returns(dataset.GetHashCode());
            }

            return dataset.Object;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:16,代码来源:DatasetFacadeForScriptsTest.cs


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