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


C# Dummy类代码示例

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


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

示例1: Should_Generate_Diffs_for_POCOs_and_JObjects

        public void Should_Generate_Diffs_for_POCOs_and_JObjects()
        {
            var sut = ObjectDiffPatch.GenerateDiff<Dummy>(null, null);
            sut.AreEqual.Should().BeTrue();
            sut.OldValues.Should().BeNull();
            sut.NewValues.Should().BeNull();

            var a = new Dummy { Id = "foo" };
            var ja = JObject.FromObject(a);

            sut = ObjectDiffPatch.GenerateDiff(a, null);
            sut.AreEqual.Should().BeFalse();
            sut.OldValues.Should().Be(ja);
            sut.NewValues.Should().BeNull();

            sut = ObjectDiffPatch.GenerateDiff(null, a);
            sut.AreEqual.Should().BeFalse();
            sut.OldValues.Should().BeNull();
            sut.NewValues.Should().Be(ja);

            var b = new Dummy { Id = "bar" };
            var jb = JObject.FromObject(b);
            sut = ObjectDiffPatch.GenerateDiff(a, b);
            sut.AreEqual.Should().BeFalse();
            JToken.DeepEquals(sut.OldValues, ja).Should().BeTrue();
            JToken.DeepEquals(sut.NewValues, jb).Should().BeTrue();

            // now for JObjects
            sut = ObjectDiffPatch.GenerateDiff(ja, jb);
            sut.AreEqual.Should().BeFalse();
            JToken.DeepEquals(sut.OldValues, ja).Should().BeTrue();
            JToken.DeepEquals(sut.NewValues, jb).Should().BeTrue();
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:33,代码来源:ObjectDiffPatchSpecs.cs

示例2: HappyPath

 public void HappyPath()
 {
     var actual = new Dummy { Value = 2 };
     var roundtrip = DataContractSerializerAssert.Roundtrip(actual);
     Assert.AreEqual(roundtrip.Value, actual.Value);
     FieldAssert.Equal(actual, roundtrip);
 }
开发者ID:JohanLarsson,项目名称:Gu.SerializationAsserts,代码行数:7,代码来源:DataContractSerializerAssertTestsRoundtrip.cs

示例3: PutDummy

        public async Task<IHttpActionResult> PutDummy(int id, Dummy dummy)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != dummy.DummyId)
            {
                return BadRequest();
            }

            db.Entry(dummy).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DummyExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
开发者ID:alexaung,项目名称:OBTS,代码行数:32,代码来源:DummiesController.cs

示例4: CreatePropertySetter_Dummy_Ok

 public void CreatePropertySetter_Dummy_Ok()
 {
     PropertySetter setter = DelegateFactory.CreatePropertySetter(typeof(Dummy).GetProperty("Id"));
     var dummy = new Dummy();
     setter(dummy, "1");
     Assert.Equal(dummy.Id, 1);
 }
开发者ID:GSerjo,项目名称:CodeProject,代码行数:7,代码来源:DelegateFactoryTest.cs

示例5: CreatePropertyGetter_Dummy_Ok

 public void CreatePropertyGetter_Dummy_Ok()
 {
     PropertyGetter getter = DelegateFactory.CreatePropertyGetter(typeof(Dummy).GetProperty("Id"));
     var dummy = new Dummy { Id = 1 };
     object actual = getter(dummy);
     Assert.Equal(dummy.Id, actual);
 }
开发者ID:GSerjo,项目名称:CodeProject,代码行数:7,代码来源:DelegateFactoryTest.cs

示例6: Main

	public static void Main() {

		Dummy obj = new Dummy();
			
		obj=null;
		GC.Collect();
	}
开发者ID:ArildF,项目名称:masters,代码行数:7,代码来源:finalizeobjtimeout.cs

示例7: Main

	public static int Main() {

        int returnValue = 0;
		Dummy obj = new Dummy();

		Console.WriteLine("Allocating a Weak handle to object..");
		GCHandle handle = GCHandle.Alloc(obj,GCHandleType.Weak);

		GC.Collect();
		GC.WaitForPendingFinalizers();
		
		if(Dummy.visited == false) {  // has not visited the Finalize()
            returnValue = 100;
			Console.WriteLine("Test for KeepAlive() passed!");
		}
		else {
            returnValue = 1;
			Console.WriteLine("Test for KeepAlive() failed!");
		}

		GC.KeepAlive(obj);	// will keep alive 'obj' till this point
		GC.Collect();

        return returnValue;
	}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:25,代码来源:keepalivehandle.cs

示例8: SelectMany_ObservableSourceSubSourceAdded_NoUpdatesWhenDetached

        public void SelectMany_ObservableSourceSubSourceAdded_NoUpdatesWhenDetached()
        {
            var update = false;
            ICollection<Dummy<ICollection<Dummy<string>>>> coll = new ObservableCollection<Dummy<ICollection<Dummy<string>>>>();
            var dummy = new Dummy<string>() { Item = "23" };
            var dummy2 = new Dummy<ICollection<Dummy<string>>>()
            {
                Item = new List<Dummy<string>>() { dummy }
            };

            var test = coll.WithUpdates().SelectMany(d => d.Item, (d1, d2) => d2.Item);

            test.CollectionChanged += (o, e) => update = true;

            Assert.IsFalse(Sys.Contains(test, "23"));
            Assert.IsFalse(update);

            test.Detach();
            update = false;

            coll.Add(dummy2);

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.IsTrue(test.Contains("23"));
            update = false;

            coll.Remove(dummy2);

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:34,代码来源:SelectManyTest.cs

示例9: Main

    public static int Main(String[] args)
    {
        int iterations = 250;

        try
        {
            iterations = int.Parse(args[0]);
        }
        catch
        {
            Console.WriteLine("Using default number of iterations: 250");
        }

        Console.WriteLine("Creating arrays...");
        Console.WriteLine("test fails if asserts or hangs here");

        try
        {
            Dummy[] arr = new Dummy[iterations];
            for (int i = 0; i < arr.Length; i++)
            {
                // test fails if asserts or hangs here
                Console.WriteLine(i);
                arr[i] = new Dummy();
            }
        }
        catch (OutOfMemoryException)
        {
            // need to bail here
        }

        Console.WriteLine("Test Passed");
        return 100;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:34,代码来源:289745.cs

示例10: Main

	public static int  Main() {

        int returnValue = 0;
		Dummy obj = new Dummy();
		StrDummy strobj = new StrDummy(999);
		Color enumobj = new Color();
	
		GC.Collect();
		GC.WaitForPendingFinalizers();
		
			
		if((Dummy.visited == false) && (StrDummy.flag==true)) {  // has not visited the Finalize()
            returnValue = 100;
			Console.WriteLine("Test passed!");
		}
		else {
            returnValue = 1;
			Console.WriteLine("Test failed!");
		}

		GC.KeepAlive(obj);	// will keep alive 'obj' till this point
		GC.KeepAlive(1000000);
		GC.KeepAlive("long string for testing");
		GC.KeepAlive(-12345678);
		GC.KeepAlive(3456.8989);
		GC.KeepAlive(true);
		GC.KeepAlive(strobj);
		GC.KeepAlive(enumobj);

        return returnValue;
		
	}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:32,代码来源:keepalivetypes.cs

示例11: Linq_SelectMany

        public void Linq_SelectMany()
        {
            var coll = new ObservableCollection<Dummy<IEnumerable<string>>>();
            var update = false;

            var dummy = new Dummy<IEnumerable<string>>()
            {
                Item = new List<string>() { "42" }
            };

            var test = from d in coll.WithUpdates()
                       from s in d.Item
                       select s.Substring(0);

            test.CollectionChanged += (o, e) =>
            {
                update = true;
                Assert.AreEqual("42", e.NewItems[0]);
            };

            Assert.IsFalse(test.Any());
            Assert.IsFalse(update);

            coll.Add(dummy);

            Assert.IsTrue(update);
        }
开发者ID:FrederikP,项目名称:NMF,代码行数:27,代码来源:LinqTest.cs

示例12: TestAutoUpdatingSortedObservableCollection

        public void TestAutoUpdatingSortedObservableCollection()
        {
            var collection = new AutoUpdatingSortedObservableCollection<Dummy> { new Dummy("sss"), new Dummy("eee") };

            var dummy = new Dummy("ggg");
            collection.Add(dummy);

            var sorted = new[] { "eee", "ggg", "sss" };

            for (int i = 0; i < collection.Count; ++i)
            {
                Assert.That(collection[i].Name == sorted[i]);
                Assert.That(collection.BinarySearch(sorted[i], (d, s) => String.Compare(d.Name, s, StringComparison.Ordinal)) == i);
            }

            dummy.Name = "aaa";
            sorted = new[] { "aaa", "eee", "sss" };
            for (int i = 0; i < collection.Count; ++i)
            {
                Assert.That(collection[i].Name == sorted[i]);
                Assert.That(collection.BinarySearch(sorted[i], (d, s) => String.Compare(d.Name, s, StringComparison.Ordinal)) == i);
            }

            dummy.Name = "zzz";
            sorted = new[] { "eee", "sss", "zzz" };
            for (int i = 0; i < collection.Count; ++i)
            {
                Assert.That(collection[i].Name == sorted[i]);
                Assert.That(collection.BinarySearch(sorted[i], (d, s) => String.Compare(d.Name, s, StringComparison.Ordinal)) == i);
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:31,代码来源:TestCore.cs

示例13: AllocateALotOfObjects

 public void AllocateALotOfObjects()
 {
     for (int i = 0; i < length; ++i)
     {
         Dummy dummy = new Dummy();
     }
 }
开发者ID:BackupTheBerlios,项目名称:mbunit-svn,代码行数:7,代码来源:PerfCounterDemo.cs

示例14: Main

	public static void Main() {

		Dummy obj = new Dummy();
		bool result=false;
		
		GC.Collect();
		GC.WaitForPendingFinalizers();
		
			
		if((Dummy.visited == false)) {  // has not visited the Finalize() yet
			result=true;
		}
		
		GC.KeepAlive(obj);	// will keep alive 'obj' till this point
		
		obj=null;
		GC.Collect();
		GC.WaitForPendingFinalizers();
		
		if(result==true && Dummy.visited==true) {
			Console.WriteLine("Test passed!");
			Environment.ExitCode = 0;
		}
		else {
			Console.WriteLine("Test failed!");
			Environment.ExitCode = 1;
		}		
	
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:29,代码来源:keepalivescope.cs

示例15: Main

	public static int Main() {

        int returnValue = 0;
		Dummy[] obj = new Dummy[100];

		for(int i=0;i<100;i++) {
			obj[i]= new Dummy();
		}
			
		GC.Collect();
		GC.WaitForPendingFinalizers();
		
				
		if(Dummy.visited == false) {  // has not visited the Finalize()
            returnValue = 100;
			Console.WriteLine("Test for KeepAlive() passed!");
		}
		else {
            returnValue = 1;
			Console.WriteLine("Test for KeepAlive() failed!");
		}
	
		GC.KeepAlive(obj);	// will keep alive 'obj' till this point

        return returnValue;
	}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:keepalivearray.cs


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