예제 #1
0
파일: 289745.cs 프로젝트: CheneyWu/coreclr
    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;
    }
예제 #2
0
        public bool RunTest()
        {
            // ensuring that GC happens even with /debug mode
            obj = null;
            GC.Collect();

            GC.WaitForPendingFinalizers();

            bool ans1 = handle.IsAllocated;
            bool ans2 = copy.IsAllocated;

            //Console.WriteLine("handle.IsAllocated = " + ans1);
            //Console.WriteLine("copy.IsAllocated = " + ans2);

            Dummy target1 = (Dummy)handle.Target;
            Dummy target2 = (Dummy)copy.Target;

            if (((ans1 == true) && (ans2 == true)) && ((target1 == null) && (target2 == null)))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #3
0
	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;
	}
예제 #4
0
        public void WithNullValues_PrintFieldsAsNull()
        {
            var dummy = new Dummy();
            var results = dummy.FormatProperties(x => x.ObjectProperty);

            results.Should().Be("{Dummy: 'ObjectProperty':'null', }");
        }
예제 #5
0
 private void TestToStringVersion(Dummy targetObject, int count)
 {
     for (int i = 0; i < count; i++)
     {
         var devNull = targetObject.ToString();
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
 /// </summary>
 public MainWindowViewModel()
     : base()
 {
     CurrentDummy = new Dummy(444);
     Reset = new Command(OnResetExecute);
     Create = new Command(OnCreateExecute);
 }
 public void HappyPath()
 {
     var actual = new Dummy { Value = 2 };
     var roundtrip = DataContractSerializerAssert.Roundtrip(actual);
     Assert.AreEqual(roundtrip.Value, actual.Value);
     FieldAssert.Equal(actual, roundtrip);
 }
예제 #8
0
        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);
            }
        }
예제 #9
0
	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;
	}
예제 #10
0
        public void LambdaIntSum_ObservableSourceItemRemoved_Updates()
        {
            var update = false;
            var dummy = new Dummy<int>(3);
            var coll = new ObservableCollection<Dummy<int>>() { new Dummy<int>(1), new Dummy<int>(2), dummy };
            var testColl = coll.WithUpdates();

            var test = Observable.Expression(() => testColl.Sum(d => d.Item));

            test.ValueChanged += (o, e) =>
            {
                update = true;
                Assert.AreEqual(6, e.OldValue);
                Assert.AreEqual(3, e.NewValue);
            };

            Assert.AreEqual(6, test.Value);
            Assert.AreEqual(6, testColl.Sum(d => d.Item));
            Assert.IsFalse(update);

            coll.Remove(dummy);

            Assert.IsTrue(update);
            Assert.AreEqual(3, test.Value);
        }
예제 #11
0
파일: Normal.cs 프로젝트: CheneyWu/coreclr
	public static int Main() {

		Dummy obj = new Dummy();
		
		Console.WriteLine("Allocating a normal handle to object..");
		GCHandle handle = GCHandle.Alloc(obj,GCHandleType.Normal); // Normal handle
		
		// ensuring that GC happens even with /debug mode
		obj=null;

		GC.Collect();
		GC.WaitForPendingFinalizers();
		
		if(Dummy.flag == 0) {
			
			Console.WriteLine("Test for GCHandleType.Normal passed!");
            return 100;
		}
		else {
			
			Console.WriteLine("Test for GCHandleType.Normal failed!");
            return 1;
		}


	}
예제 #12
0
        public void RunTest()
        {
            obj = null;
            GC.Collect();

            GC.WaitForPendingFinalizers();  // makes sure Finalize() is called.
        }
예제 #13
0
 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);
 }
예제 #14
0
 public void AllocateALotOfObjects()
 {
     for (int i = 0; i < length; ++i)
     {
         Dummy dummy = new Dummy();
     }
 }
예제 #15
0
		public CreateObj() {
			
			obj = new Dummy[10000];
			for(int i=0;i<10000;i++) {
				obj[i] = new Dummy();
			}
		}
예제 #16
0
파일: LinqTest.cs 프로젝트: FrederikP/NMF
        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);
        }
	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;
		}		
	
	}
예제 #18
0
	public static void Main() {

		Dummy[] arr = new Dummy[1000];

		for(int i=0;i<1000;i++) {
			try {
				arr[i] = new Dummy();
			}catch(Exception e) {
				Console.WriteLine("Caught: {0}",e);

				FACTOR=FACTOR/4;
				Console.WriteLine("FACTOR: {0}",FACTOR);

				GC.Collect();
				GC.WaitForPendingFinalizers();
			}
		}
		
		for(int i=0;i<1000;i++) {
			
			if(arr[i].value!=99) {
				Environment.ExitCode=1;
				Console.WriteLine("Test failed");
				return;
			}
		}
		Environment.ExitCode=0;
		Console.WriteLine("Test passed");
		
		GC.KeepAlive(arr);	// arr should not be collected till here
	}
예제 #19
0
	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;
		
	}
예제 #20
0
	public static void Main() {

		Dummy[] obj = new Dummy[100];
		
		try {
			for(int i=0;i<100;i++) {
				obj[i]= new Dummy();
			throw new Exception();
		}
		} catch(Exception e) {
			Console.WriteLine("Caught: {0}",e);		
			GC.Collect();
			GC.WaitForPendingFinalizers();
		} finally {
			Console.WriteLine("Should come here..still keeping object alive");
			GC.KeepAlive(obj);
		}
			
	
		if(Dummy.visited == false) {  // has not visited the Finalize()
			Environment.ExitCode = 0;
			Console.WriteLine("Test for KeepAlive() passed!");
		}
		else {
			Environment.ExitCode = 1;
			Console.WriteLine("Test for KeepAlive() failed!");
		}
	
	}
        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();
        }
예제 #22
0
        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);
        }
예제 #23
0
        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);
        }
예제 #24
0
		public void SelectMany_ObservableSourceSubSourceAdded_Updates()
		{
			var update = 0;
			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++;
				Assert.AreEqual("23", e.NewItems[0]);
			};

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

			coll.Add(dummy2);

            Assert.AreEqual(1, update);
			Assert.IsTrue(Sys.Contains(test, "23"));
		}
예제 #25
0
 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);
 }
        public void CanMove()
        {
            var d1 = new Dummy();
            var d2 = new Dummy();
            var d3 = new Dummy();
            _dummyBrowserViewModel.MatchedEntities.Add(d1);
            _dummyBrowserViewModel.MatchedEntities.Add(d2);
            _dummyBrowserViewModel.MatchedEntities.Add(d3);

            _dummyBrowserViewModel.MoveToFirst();
            Assert.AreSame(d1, _dummyBrowserViewModel.CurrentEntity);

            _dummyBrowserViewModel.MoveToNext();
            Assert.AreSame(d2, _dummyBrowserViewModel.CurrentEntity);

            //loop for next
            _dummyBrowserViewModel.MoveToNext();
            _dummyBrowserViewModel.MoveToNext();
            Assert.AreSame(d1, _dummyBrowserViewModel.CurrentEntity);

            _dummyBrowserViewModel.MoveToLast();
            Assert.AreSame(d3, _dummyBrowserViewModel.CurrentEntity);

            //loop for previous
            for (int i = 0; i < 3; i++)
            {
                _dummyBrowserViewModel.MoveToPrevious();
            }
            Assert.AreSame(d3, _dummyBrowserViewModel.CurrentEntity);
        }
예제 #27
0
	public static void Main() {

		Dummy obj = new Dummy();
			
		obj=null;
		GC.Collect();
	}
예제 #28
0
        public void WithDefinedProperties_PrintValuesAndNamesCorrectly()
        {
            var dummy = new Dummy {StringProperty = "StringProperty value", IntProperty = 10};
            var results = dummy.FormatProperties(x => x.StringProperty, x => x.IntProperty);

            results.Should().Be("{Dummy: 'StringProperty':'StringProperty value', 'IntProperty':'10', }");
        }
예제 #29
0
        public CreateObj() {
            obj1 = new Dummy();
            obj2 = new Dummy();

             
            GC.SuppressFinalize(obj1);    // should not call the Finalize() for obj1
            GC.SuppressFinalize(obj2);    // should not call the Finalize() for obj2
        }
 public void Setup()
 {
     _dummy = new Dummy();
     _changingProperties = new List<string>();
     _changedProperties = new List<string>();
     _dummy.PropertyChanged += (sender, args) => _changedProperties.Add(args.PropertyName);
     _dummy.PropertyChanging += (sender, args) => _changingProperties.Add(args.PropertyName);
 }
예제 #31
0
 protected QualityControlReportingController(Dummy d)
 {
 }
 protected IntervieweesController(Dummy d)
 {
 }
예제 #33
0
 public void SetAxe()
 {
     this.dummy = new Dummy(100, 500);
 }
예제 #34
0
 protected SideBarController(Dummy d)
 {
 }
 protected HomeWithRouteAreaAttributeController(Dummy d)
 {
 }
 protected FormController(Dummy d)
 {
 }
예제 #37
0
 protected KendoEditorFilesController(Dummy d)
 {
 }
 public void TestInit()
 {
     //Arrange
     this.axe   = new Axe(AxeAttack, AxeDurability);
     this.dummy = new Dummy(DummyHealth, DummyExp);
 }
예제 #39
0
 public void Testinit()
 {
     this.axe   = new Axe(AxeAttack, AxeDurability);
     this.dummy = new Dummy(DummyHp, DummyExp);
 }
 protected HomeController(Dummy d)
 {
 }
예제 #41
0
 protected Ctrl66Controller(Dummy d)
 {
 }
 protected LoginController(Dummy d)
 {
 }
예제 #43
0
 protected BaseController(Dummy d)
 {
 }
예제 #44
0
 public void InitializeAxe()
 {
     dummy = new Dummy(20, 10);
 }
 protected NewsletterController(Dummy d)
 {
 }
예제 #46
0
 protected AdminUserController(Dummy d)
 {
 }
 protected ConfirmController(Dummy d)
 {
 }
예제 #48
0
 public void SetUp()
 {
     axe   = new Axe(attack, durabolity);
     dummy = new Dummy(5, 6);
 }
 protected AccountController(Dummy d)
 {
 }
 protected CollectionController(Dummy d)
 {
 }
 protected RestorePasswordController(Dummy d)
 {
 }
예제 #52
0
 protected ElmahController(Dummy d)
 {
 }
 protected ContactController(Dummy d)
 {
 }
예제 #54
0
 protected CustomersController(Dummy d)
 {
 }
 protected UsersController(Dummy d)
 {
 }
예제 #56
0
 protected AboutController(Dummy d)
 {
 }
예제 #57
0
 protected SiteSettingsController(Dummy d)
 {
 }
예제 #58
0
 protected ClientesController(Dummy d)
 {
 }
 protected StudentGroupController(Dummy d)
 {
 }
 protected DiagnosticController(Dummy d)
 {
 }