public void SelectAReferenceType() { var values = new TestReferenceType[] { new TestReferenceType(), new TestReferenceType(), new TestReferenceType() }; var actual = values.GetRandom(); Assert.IsType <TestReferenceType>(actual); }
public void ReferenceTypesCanBeCloned() { var original = new TestReferenceType {TestField = 123, TestProperty = 456}; TestReferenceType clone = this.cloneFactory.DeepFieldClone(original); Assert.AreNotSame(original, clone); Assert.AreEqual(original.TestField, clone.TestField); Assert.AreEqual(original.TestProperty, clone.TestProperty); }
/// <summary> /// Замена конструктора, процедура инициализации объекта /// </summary> public PoolSupportedObjectWithFields Init() { _valueField = ValueFieldProtected = ValueFieldWrongAndPublic = 5; _testReferenceType = new TestReferenceType(); TestReferenceTypeProtected = new TestReferenceType(); TestReferenceTypeWrongAndPublic = new TestReferenceType(); return(this); }
public void ReferenceTypesCanBeCloned() { var original = new TestReferenceType { TestField = 123, TestProperty = 456 }; TestReferenceType clone = this.cloneFactory.DeepFieldClone(original); Assert.AreNotSame(original, clone); Assert.AreEqual(original.TestField, clone.TestField); Assert.AreEqual(original.TestProperty, clone.TestProperty); }
public void ShallowClonesOfArraysCanBeMade() { var original = new TestReferenceType[] { new TestReferenceType() { TestField = 123, TestProperty = 456 } }; TestReferenceType[] clone = this.cloneFactory.ShallowFieldClone(original); Assert.AreSame(original[0], clone[0]); }
public void TopologicalSortEdges_SimpleDependancyChainWithDuplicateItems_ThrowsArgumentException() { List <TestReferenceType> items = Enumerable.Range(1, Random.Next(10, 100)).Select(n => new TestReferenceType()).ToList(); // Edges are such that each entry is dependent on the entry next in the list List <KeyValuePair <TestReferenceType, TestReferenceType> > edges = items.Skip(1) .Zip(items, (a, b) => new KeyValuePair <TestReferenceType, TestReferenceType>(a, b)) .ToList(); // Introduce duplicate item items.Add(items[Random.Next(0, items.Count)]); IEnumerable <TestReferenceType> result = items.TopologicalSortEdges(edges); TestReferenceType firstStep = result.First(); }
public void TopologicalSortEdges_SimpleLoopingDependancyChain_ThrowsAInvalidOperationExceptionOnFirstStep() { IEnumerable <TestReferenceType> enumerable = Enumerable.Range(1, Random.Next(10, 100)).Select(n => new TestReferenceType()).ToList(); // Edges are such that each entry is dependent on the entry next in the list List <KeyValuePair <TestReferenceType, TestReferenceType> > edges = enumerable.Skip(1).Zip( enumerable, (a, b) => new KeyValuePair <TestReferenceType, TestReferenceType>(a, b)).ToList(); // Then add loop by connecting first entry to last edges.Add(new KeyValuePair <TestReferenceType, TestReferenceType>(enumerable.First(), enumerable.Last())); IEnumerable <TestReferenceType> result = enumerable.TopologicalSortEdges(edges); TestReferenceType firstStep = result.First(); }
public void DeepClonesOfArraysCanBeMade() { var original = new TestReferenceType[, ] { { new TestReferenceType() { TestField = 123, TestProperty = 456 } } }; TestReferenceType[,] clone = this.cloneFactory.DeepFieldClone(original); Assert.AreNotSame(original[0, 0], clone[0, 0]); Assert.AreEqual(original[0, 0].TestField, clone[0, 0].TestField); Assert.AreEqual(original[0, 0].TestProperty, clone[0, 0].TestProperty); }