public void ClassWithoutDefaultConstructorCanBeCloned() { var original = new ClassWithoutDefaultConstructor(1234); ClassWithoutDefaultConstructor clone = this.cloneFactory.DeepFieldClone(original); Assert.AreNotSame(original, clone); Assert.AreEqual(original.Dummy, clone.Dummy); }
public void ClassWithoutDefaultConstructorCanBeCloned() { var original = new ClassWithoutDefaultConstructor(1234); ClassWithoutDefaultConstructor clone = this.cloneFactory.DeepFieldClone(original); Assert.AreNotSame(original, clone); Assert.AreEqual(original.Dummy, clone.Dummy); }
public static void Main(string[] args) { //a class without constructors gets a default constructor from the compiler ClassWithoutConstructors c1 = new ClassWithoutConstructors(); //we can invoke this method even if it's not in our source code //we can redefine the default constructor if we want ClassWithDefaultConstructor c2 = new ClassWithDefaultConstructor(); //prints to the console //we can overload the constructors if necessary ClassWithOverloadedConstructors c3 = new ClassWithOverloadedConstructors(); // first constructor (default we wrote) ClassWithOverloadedConstructors c4 = new ClassWithOverloadedConstructors(10); // second constructor (with an int, that we wrote) ClassWithoutDefaultConstructor c5 = new ClassWithoutDefaultConstructor(5); //we cannot make any instance unless we pass an int, because we don't have the default constructor }
public void Serialize_ClassWithoutDefaultConstructor_NoExceptionIsThrown() { //Arrange ClassWithoutDefaultConstructor testClass = _fixture.Create <ClassWithoutDefaultConstructor>(); //Act var serialized = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ClassWithoutDefaultConstructor>(serialized); //Assert deserialized.Should().BeEquivalentTo(testClass); }