public void WithIndexer() { var expected = this is FieldValues.Throws ? "Copy.FieldValues(x, y) failed.\r\n" + "Indexers are not supported.\r\n" + " - The property WithIndexerType.Item is an indexer and not supported.\r\n" + "Solve the problem by any of:\r\n" + "* Use FieldsSettings and specify how copying is performed:\r\n" + " - ReferenceHandling.Structural means that a the entire graph is traversed and immutable property values are copied.\r\n" + " - For structural Activator.CreateInstance is used to create instances so a parameterless constructor may be needed, can be private.\r\n" + " - ReferenceHandling.References means that references are copied.\r\n" + " - Exclude a combination of the following:\r\n" + " - The indexer property WithIndexerType.Item.\r\n" : "Copy.PropertyValues(x, y) failed.\r\n" + "Indexers are not supported.\r\n" + " - The property WithIndexerType.Item is an indexer and not supported.\r\n" + "Solve the problem by any of:\r\n" + "* Use PropertiesSettings and specify how copying is performed:\r\n" + " - ReferenceHandling.Structural means that a the entire graph is traversed and immutable property values are copied.\r\n" + " - For structural Activator.CreateInstance is used to create instances so a parameterless constructor may be needed, can be private.\r\n" + " - ReferenceHandling.References means that references are copied.\r\n" + " - Exclude a combination of the following:\r\n" + " - The indexer property WithIndexerType.Item.\r\n"; var source = new WithIndexerType(); var target = new WithIndexerType(); var exception = Assert.Throws <NotSupportedException>(() => this.CopyMethod(source, target, ReferenceHandling.Structural)); Assert.AreEqual(expected, exception.Message); }
public void WithIllegalIndexer() { var expected = this is DiffTests.FieldValues.Throws ? "DiffBy.FieldValues(x, y) failed.\r\n" + "Indexers are not supported.\r\n" + " - The property WithIndexerType.Item is an indexer and not supported.\r\n" + "Solve the problem by any of:\r\n" + "* Implement IEquatable<WithIndexerType> for WithIndexerType or use a type that does.\r\n" + "* Use FieldsSettings and specify how comparing is performed:\r\n" + " - Exclude a combination of the following:\r\n" + " - The indexer property WithIndexerType.Item.\r\n" : "DiffBy.PropertyValues(x, y) failed.\r\n" + "Indexers are not supported.\r\n" + " - The property WithIndexerType.Item is an indexer and not supported.\r\n" + "Solve the problem by any of:\r\n" + "* Implement IEquatable<WithIndexerType> for WithIndexerType or use a type that does.\r\n" + "* Use PropertiesSettings and specify how comparing is performed:\r\n" + " - Exclude a combination of the following:\r\n" + " - The indexer property WithIndexerType.Item.\r\n"; var source = new WithIndexerType(); var target = new WithIndexerType(); var exception = Assert.Throws <NotSupportedException>(() => this.DiffMethod(source, target, ReferenceHandling.Structural)); Assert.AreEqual(expected, exception.Message); }