mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
36 lines
1,002 B
C#
36 lines
1,002 B
C#
using System;
|
|
using Cosmos.TestRunner;
|
|
|
|
namespace Cosmos.Compiler.Tests.Bcl.System
|
|
{
|
|
public class ObjectTests
|
|
{
|
|
public class MyType
|
|
{
|
|
public int IntField;
|
|
public object ReferenceField;
|
|
|
|
public MyType Clone()
|
|
{
|
|
return (MyType)MemberwiseClone();
|
|
}
|
|
}
|
|
|
|
public static void Execute()
|
|
{
|
|
var xMyType = new MyType();
|
|
|
|
xMyType.IntField = 42;
|
|
xMyType.ReferenceField = new object();
|
|
|
|
var xCloneType = xMyType.Clone();
|
|
|
|
Assert.AreEqual(xMyType.IntField, xCloneType.IntField, "Cloned object has a different IntField value!");
|
|
Assert.IsTrue(ReferenceEquals(xMyType.ReferenceField, xCloneType.ReferenceField), "References of field aren't the same!");
|
|
|
|
xCloneType.IntField = 56;
|
|
|
|
Assert.AreEqual(xMyType.IntField, 42, "Cloned object is linked to original object!");
|
|
}
|
|
}
|
|
}
|