• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TestObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TestObject的典型用法代码示例。如果您正苦于以下问题:C# TestObject类的具体用法?C# TestObject怎么用?C# TestObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestObject类属于命名空间,在下文中一共展示了TestObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateInstanceScopedKeyString

 public void CreateInstanceScopedKeyString()
 {
     TestObject testObject = new TestObject();
     string typeScopedKey = UniqueKey.GetInstanceScopedString(testObject, "PartialKey");
     string expectedKey = string.Format("{0}[{1}].{2}", typeof(TestObject).FullName, testObject.GetHashCode(), "PartialKey");
     Assert.AreEqual(expectedKey, typeScopedKey);      
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:7,代码来源:UniqueKeyTests.cs


示例2: TestSetObjectPropsPrimitives

		public void TestSetObjectPropsPrimitives()
		{
			JobDataMap jobDataMap = new JobDataMap();
			jobDataMap.Put("intValue", 1);
			jobDataMap.Put("longValue", 2L);
			jobDataMap.Put("floatValue", 3.0f);
			jobDataMap.Put("doubleValue", 4.0);
			jobDataMap.Put("booleanValue", true);
			jobDataMap.Put("shortValue", 5);
			jobDataMap.Put("charValue", 'a');
			jobDataMap.Put("byteValue", 6);
			jobDataMap.Put("stringValue", "S1");
            Dictionary<string, string> map = new Dictionary<string, string>();
			map.Add("A", "B");
			jobDataMap.Put("mapValue", map);

			TestObject myObject = new TestObject();
			factory.SetObjectProperties(myObject, jobDataMap);

			Assert.AreEqual(1, myObject.IntValue);
			Assert.AreEqual(2, myObject.LongValue);
			Assert.AreEqual(3.0f, myObject.FloatValue);
			Assert.AreEqual(4.0, myObject.DoubleValue);
			Assert.IsTrue(myObject.BooleanValue);
			Assert.AreEqual(5, myObject.ShortValue);
			Assert.AreEqual('a', myObject.CharValue);
			Assert.AreEqual((byte) 6, myObject.ByteValue);
			Assert.AreEqual("S1", myObject.StringValue);
			Assert.IsTrue(myObject.MapValue.ContainsKey("A"));
		}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:30,代码来源:PropertySettingJobFactoryTest.cs


示例3: SetupEvaluator

 public void SetupEvaluator()
 {
     _conditionEvaluator = new ConditionEvaluatorIronPython();
     _runtimeMock = new Mock<IWorkflowRuntime>();
     var testObject1 = new TestObject
     {
         Bool = true,
         Number = 1,
         Str = "A"
     };
     var testObject2 = new TestObject
     {
         Bool = false,
         Number = 2,
         Str = "B"
     };
     _runtimeMock.Setup(m => m.Input).Returns(testObject1);
     _runtimeMock.Setup(m => m.ProviderResults).Returns(new[]
     {
         new ProviderRuntimeResult
         {
             ProviderName = "Provider1",
             Result = testObject2,
             ProviderStatus = EWorkflowProviderRuntimeStatus.Success
         }
     });
 }
开发者ID:RiskEngeneers,项目名称:Prototype,代码行数:27,代码来源:ConditionEvaluatorIronPythonTests.cs


示例4: ExtensibleObjectTestCommon

 public ExtensibleObjectTestCommon()
 {
     _obj = new TestObject();
     _dObj = _obj;
     _dObj.Test1 = "TestValue";
     _dObj.Test2 = null;
 }
开发者ID:kernicus,项目名称:WebApiContrib.Formatting.CollectionJson,代码行数:7,代码来源:ExtensibleObjectTest.cs


示例5: ThenStringsCanBeResolvedCorrectly

 public void ThenStringsCanBeResolvedCorrectly(string value, bool expected)
 {
     var input = new TestObject { String = value };
     var filter = TableQuery.GenerateFilterCondition("String", QueryComparisons.Equal, "Test");
     var query = new TableQuery<TestObject>().Where(filter);
     Assert.That(query.Validate(input), Is.EqualTo(expected));
 }
开发者ID:Korthax,项目名称:TableQueryParser,代码行数:7,代码来源:WhenTheQueryContainsASingleEqualToExpression.cs


示例6: ThenDateTimesCanBeResolvedCorrectly

 public void ThenDateTimesCanBeResolvedCorrectly(string value, bool expected)
 {
     var input = new TestObject { DateTime = DateTimeOffset.Parse(value) };
     var filter = TableQuery.GenerateFilterConditionForDate("DateTime", QueryComparisons.Equal, new DateTimeOffset(new DateTime(2015, 01, 03)));
     var query = new TableQuery<TestObject>().Where(filter);
     Assert.That(query.Validate(input), Is.EqualTo(expected));
 }
开发者ID:Korthax,项目名称:TableQueryParser,代码行数:7,代码来源:WhenTheQueryContainsASingleEqualToExpression.cs


示例7: ThenDoublesCanBeResolvedCorrectly

 public void ThenDoublesCanBeResolvedCorrectly(double value, bool expected)
 {
     var input = new TestObject { Double = value };
     var filter = TableQuery.GenerateFilterConditionForDouble("Double", QueryComparisons.Equal, 5.5);
     var query = new TableQuery<TestObject>().Where(filter);
     Assert.That(query.Validate(input), Is.EqualTo(expected));
 }
开发者ID:Korthax,项目名称:TableQueryParser,代码行数:7,代码来源:WhenTheQueryContainsASingleEqualToExpression.cs


示例8: TestException

 public TestException(TestObject obj, string domain, string url, string message)
     : base(message)
 {
     this._obj = obj;
     this._url = url;
     this._domain = domain;
 }
开发者ID:coastcdl,项目名称:autotester,代码行数:7,代码来源:TestException.cs


示例9: RegularChange

        public void RegularChange()
        {
            TestObject[] obj = new TestObject[]
            {
                new TestObject { Foo = 42, Bar = "Hello" },
                new TestObject { Foo = 10, Bar = "World" },
                new TestObject { Foo = 0, Bar = "Not" }
            };
            ObjectPropertyChangedEventArgs args = new ObjectPropertyChangedEventArgs(
                new ObjectSelection(obj.Take(2)),
                new PropertyInfo[] { TestObject.FooProperty });

            Assert.IsTrue(args.HasObject(obj[0]));
            Assert.IsTrue(args.HasObject(obj[1]));
            Assert.IsFalse(args.HasObject(obj[2]));

            Assert.IsTrue(args.HasAnyObject(obj));
            Assert.IsTrue(args.HasAnyObject(obj.Skip(1)));
            Assert.IsFalse(args.HasAnyObject(obj.Skip(2)));

            Assert.IsTrue(args.HasProperty(TestObject.FooProperty));
            Assert.IsFalse(args.HasProperty(TestObject.BarProperty));
            Assert.IsFalse(args.HasProperty(UnrelatedObject.NotProperty));

            Assert.IsTrue(args.HasAnyProperty(TestObject.FooProperty));
            Assert.IsTrue(args.HasAnyProperty(TestObject.FooProperty, TestObject.BarProperty));
            Assert.IsFalse(args.HasAnyProperty(TestObject.BarProperty));
            Assert.IsFalse(args.HasAnyProperty(UnrelatedObject.NotProperty));

            Assert.IsFalse(args.CompleteChange);
        }
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:31,代码来源:ObjectPropertyChangedEventArgsTest.cs


示例10: ThenBooleansCanBeResolvedCorrectly

 public void ThenBooleansCanBeResolvedCorrectly(bool value, bool expected)
 {
     var input = new TestObject { Bool = value };
     var filter = TableQuery.GenerateFilterConditionForBool("Bool", QueryComparisons.Equal, true);
     var query = new TableQuery<TestObject>().Where(filter);
     Assert.That(query.Validate(input), Is.EqualTo(expected));
 }
开发者ID:Korthax,项目名称:TableQueryParser,代码行数:7,代码来源:WhenTheQueryContainsASingleEqualToExpression.cs


示例11: SunnyDay

		public void SunnyDay()
		{
			TestObject dude = new TestObject("Rick Evans", 30);
		    IObjectFactory objectFactory = mocks.StrictMock<IObjectFactory>();
			const string lookupObjectName = "rick";
		    Expect.Call(objectFactory.GetObject(lookupObjectName)).Return(dude).Repeat.Twice();
			ObjectFactoryCreatingFactoryObject factory = new ObjectFactoryCreatingFactoryObject();
		    factory.ObjectFactory = objectFactory;
			factory.TargetObjectName = lookupObjectName;
			factory.AfterPropertiesSet();

            mocks.ReplayAll();

			IGenericObjectFactory gof = (IGenericObjectFactory) factory.GetObject();
			IGenericObjectFactory gofOther = (IGenericObjectFactory) factory.GetObject();
			Assert.IsTrue(Object.ReferenceEquals(gof, gofOther),
				"Not returning a shared instance (Singleton = true).");
			TestObject one = (TestObject) gof.GetObject();
			Assert.IsNotNull(one, "Must never return null (IFactoryObject contract).");
			TestObject two = (TestObject) gof.GetObject();
			Assert.IsNotNull(two, "Must never return null (IFactoryObject contract).");
			Assert.IsTrue(Object.ReferenceEquals(one, two),
			              "Not returning the same instance.");
			mocks.VerifyAll();
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:25,代码来源:ObjectFactoryCreatingFactoryObjectTests.cs


示例12: PrototypeModeWithSingletonTarget

		public void PrototypeModeWithSingletonTarget()
		{
			TestObject dude = new TestObject("Rick Evans", 30);			
            IObjectFactory objectFactory = mocks.StrictMock<IObjectFactory>();
			const string lookupObjectName = "rick";
            Expect.Call(objectFactory.GetObject(lookupObjectName)).Return(dude).Repeat.Twice();
			ObjectFactoryCreatingFactoryObject factory = new ObjectFactoryCreatingFactoryObject();
		    factory.ObjectFactory = objectFactory;
			factory.TargetObjectName = lookupObjectName;
			factory.IsSingleton = false;
			factory.AfterPropertiesSet();

            mocks.ReplayAll();
			IGenericObjectFactory gofOne = (IGenericObjectFactory) factory.GetObject();
			IGenericObjectFactory gofTwo = (IGenericObjectFactory) factory.GetObject();
			Assert.IsFalse(Object.ReferenceEquals(gofOne, gofTwo),
				"Not returning distinct instances (Prototype = true).");
			TestObject one = (TestObject) gofOne.GetObject();
			Assert.IsNotNull(one, "Must never return null (IFactoryObject contract).");
			TestObject two = (TestObject) gofTwo.GetObject();
			Assert.IsNotNull(two, "Must never return null (IFactoryObject contract).");
			Assert.IsTrue(Object.ReferenceEquals(one, two),
				"Not returning the same instance to singleton object.");
			mocks.VerifyAll();
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:25,代码来源:ObjectFactoryCreatingFactoryObjectTests.cs


示例13: ObservableSelect_ChangeItemsTest

        public void ObservableSelect_ChangeItemsTest()
        {
            var collection = new ObservableCollection<TestObject>();
            var values = collection.ObservableSelect(item => item.Value);
            var receivedEvents = new ObservableIndexer<NotifyCollectionChangedAction, int>(_ => 0);

            var expectedValues = new[] { 2, 3, 4 };
            var expectedEvents = new[] { KeyValuePair(NotifyCollectionChangedAction.Replace, 3) };

            var testObject1 = new TestObject { Value = 1 };
            var testObject2 = new TestObject { Value = 2 };
            var testObject3 = new TestObject { Value = 3 };

            NotifyCollectionChangedEventHandler collectionChangedEventHandler = (sender, e) =>
            {
                receivedEvents[e.Action] += 1;
            };

            collection.AddRange(testObject1, testObject2, testObject3);

            values.CollectionChanged += collectionChangedEventHandler;

            foreach (var item in collection)
            {
                item.Value += 1;
            }

            Assert.IsTrue(receivedEvents.SequenceEqual(expectedEvents));
            Assert.IsTrue(values.SequenceEqual(expectedValues));
        }
开发者ID:tom-englert,项目名称:TomsToolbox,代码行数:30,代码来源:ObservableExtensionsTests.cs


示例14: setUp

        public override void setUp()
        {
            base.setUp();

            _toLoad = new List<TestObject>();
            var br = new StreamReader("Resources/all_packed_objects.txt", Constants.CHARSET);
            try
            {
                string line;
                while ((line = br.ReadLine()) != null)
                {
                    string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    var testObject = new TestObject
                                {
                                    Id = ObjectId.FromString(parts[0]),
                                    Type = parts[1],
                                    RawSize = Convert.ToInt32(parts[2]),
                                    Size = Convert.ToInt64(parts[3]),
                                    Offset = Convert.ToInt64(parts[4])
                                };

                    _toLoad.Add(testObject);
                }
            }
            finally
            {
                br.Close();
            }

            Assert.AreEqual(96, _toLoad.Count);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:31,代码来源:WindowCacheGetTest.cs


示例15: ResolvesChildren

        public void ResolvesChildren()
        {
            var testObject = new TestObject() { Id = 1, Children = new List<TestObject>() };
            var child = new TestObject();

            var mChildState = new Mock<IObjectState>(MockBehavior.Strict);
            var builder = new ObjectBuilder<TestObject>(testObject);
            var t1 = builder
                .Dependent(mChildState.Object)
                .Build(state => new ObjectBuilder<TestObject>(child));

            var t2 = t1.Resolve(
                    (resolver, target, dependent) => target.Add(dependent)
                );

            Assert.That(t1, Is.EqualTo(t2));
            Assert.That(builder.DependentObjects.First(), Is.EqualTo(t2));

            var context = (IBuilderContext) t2;
            var resolved = context.Build(null);
            Assert.That(resolved, Is.EqualTo(child));

            var r = builder.Materialise();
            Assert.That(r, Is.EqualTo(testObject));
            Assert.That(r.Children, Is.Not.Null);
            Assert.That(r.Children.First(), Is.EqualTo(child));
        }
开发者ID:andy-uq,项目名称:Echo,代码行数:27,代码来源:BuilderSystemTests.cs


示例16: WhenDependencyPropertyChangesValueChangedIsRaised

        public void WhenDependencyPropertyChangesValueChangedIsRaised()
        {
            // Arrange.
            const string OldValue = "Old Value";
            const string NewValue = "New Value";

            var source = new TestObject { Text = OldValue };
            var callCount = 0;
            DependencyPropertyValueChangedEventArgs args = null;
            var listener = DependencyPropertyChangedListener.Create(source, "Text");
            listener.ValueChanged += (sender, e) =>
                {
                    ++callCount;
                    args = e;
                };

            // Act.
            source.Text = NewValue;

            // Assert.
            Assert.AreEqual(1, callCount);
            Assert.IsNotNull(args);
            Assert.AreEqual(OldValue, args.OldValue);
            Assert.AreEqual(NewValue, args.NewValue);

            // Argument validation.
            TestsHelper.VerifyThrow<ArgumentNullException>(() => DependencyPropertyChangedListener.Create(null, "Text"));
            TestsHelper.VerifyThrow<ArgumentException>(() => DependencyPropertyChangedListener.Create(source, string.Empty));
        }
开发者ID:mparsin,项目名称:Elements,代码行数:29,代码来源:DependencyPropertyChangedListenerTests.cs


示例17: Complex_Specification_Should_Eval_ToTrue

 public void Complex_Specification_Should_Eval_ToTrue()
 {
     var testObject = new TestObject { FirstName = "John", LastName = "Doe", Age = 20 };
     var testSpec = new Specification<TestObject>(x => x.Age < 30) &
                    new Specification<TestObject>(x => x.FirstName.StartsWith("J"));
     Assert.That(testSpec.IsSatisfiedBy(testObject));
 }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:7,代码来源:SpecificationTests.cs


示例18: ParseTestObject

    public bool ParseTestObject(string line, out object obj)
    {
        string[] s = line.Split(',');
        if (s.Length != 2)
        {
            obj = null;
            return false;
        }

        int x;
        if (!int.TryParse(s[0], out x))
        {
            obj = null;
            return false;
        }
        int y;
        if (!int.TryParse(s[1], out y))
        {
            obj = null;
            return false;
        }

        TestObject result = new TestObject();
        result.x = x;
        result.y = y;
        obj = result;
        return true;
    }
开发者ID:cschladetsch,项目名称:UnityTemplate,代码行数:28,代码来源:CustomParseTest.cs


示例19: ObservePathChanged

        public void ObservePathChanged()
        {
            var obj = new ContainerObject();
            string value = "error";
            obj.ObserveProperty(x => x.Test.StringProperty).Subscribe(x => value = x);

            Assert.IsNull(value);

            var test = new TestObject();
            obj.Test = test;
            Assert.IsNull(value);

            obj.Test.StringProperty = "foo";
            Assert.AreEqual("foo", value);

            value = "error";
            obj.Test = null;

            value = "pass";
            test.StringProperty = "bar";
            Assert.AreEqual("pass", value);

            obj.Test = test;
            Assert.AreEqual("bar", value);
        }
开发者ID:kswoll,项目名称:sexy-react,代码行数:25,代码来源:RxObjectTests.cs


示例20: TestObjectReferenceUpdate

        public void TestObjectReferenceUpdate()
        {
            var nodeContainer = new NodeContainer();
            var instance = new TestObject { Name = "Test" };
            var container = new ObjectContainer { Instance = instance };
            var containerNode = nodeContainer.GetOrCreateNode(container);
            var memberNode = containerNode.Children.First();
            var instanceNode = memberNode.Content.Reference.AsObject.TargetNode;

            // Update to a new instance
            var newInstance = new TestObject { Name = "Test2" };
            memberNode.Content.Update(newInstance);
            Helper.TestMemberContentNode(containerNode, memberNode, container, newInstance, nameof(ObjectContainer.Instance), true);
            Helper.TestNonNullObjectReference(memberNode.Content.Reference, newInstance, false);

            var newInstanceNode = nodeContainer.GetNode(newInstance);
            Helper.TestNonNullObjectReference(memberNode.Content.Reference, newInstanceNode, newInstance);
            Assert.AreNotEqual(instanceNode.Guid, newInstanceNode.Guid);

            // Update to null
            memberNode.Content.Update(null);
            Helper.TestMemberContentNode(containerNode, memberNode, container, null, nameof(ObjectContainer.Instance), true);
            Helper.TestNullObjectReference(memberNode.Content.Reference);

            // Update back to the initial instance
            memberNode.Content.Update(instance);
            Helper.TestMemberContentNode(containerNode, memberNode, container, instance, nameof(ObjectContainer.Instance), true);
            Helper.TestNonNullObjectReference(memberNode.Content.Reference, instanceNode, instance);
        }
开发者ID:cg123,项目名称:xenko,代码行数:29,代码来源:TestReferences.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestOutcome类代码示例发布时间:2022-05-24
下一篇:
C# TestObj类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap