public void UnifyWithEquivalentProperties_ThrowsForDifferentStoragePropertyType() { var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty(); Assert.That( () => _unsupportedStorageProperty.UnifyWithEquivalentProperties(new[] { property2 }), Throws.ArgumentException.With.Message.EqualTo( "Only equivalent properties can be combined, but this property has type 'UnsupportedStoragePropertyDefinition', and the given property has " + "type 'SimpleStoragePropertyDefinition'.\r\nParameter name: equivalentProperties")); }
public void UnifyWithEquivalentProperties_ThrowsForDifferentExceptionType() { var property1 = new UnsupportedStoragePropertyDefinition(typeof(int), "x", new InvalidOperationException()); var property2 = new UnsupportedStoragePropertyDefinition(typeof(int), "x", new ArgumentException()); Assert.That( () => property1.UnifyWithEquivalentProperties(new[] { property2 }), Throws.ArgumentException.With.Message.EqualTo( "Only equivalent properties can be combined, but this property has inner exception type 'System.InvalidOperationException', and the " + "given property has inner exception type 'System.ArgumentException'.\r\nParameter name: equivalentProperties")); }
public void UnifyWithEquivalentProperties_ThrowsForDifferentMessage() { var exception = new Exception(); var property1 = new UnsupportedStoragePropertyDefinition(typeof(int), "x", exception); var property2 = new UnsupportedStoragePropertyDefinition(typeof(int), "y", exception); Assert.That( () => property1.UnifyWithEquivalentProperties(new[] { property2 }), Throws.ArgumentException.With.Message.EqualTo( "Only equivalent properties can be combined, but this property has message 'x', and the given property has " + "message 'y'.\r\nParameter name: equivalentProperties")); }
public void UnifyWithEquivalentProperties_CombinesProperties() { var property1 = new UnsupportedStoragePropertyDefinition(typeof(int), "x", new Exception()); var property2 = new UnsupportedStoragePropertyDefinition(typeof(int), "x", new Exception()); var property3 = new UnsupportedStoragePropertyDefinition(typeof(int), "x", new Exception()); var result = property1.UnifyWithEquivalentProperties(new[] { property2, property3 }); Assert.That( result, Is.TypeOf <UnsupportedStoragePropertyDefinition>().With.Property("PropertyType").SameAs(typeof(int))); Assert.That(((UnsupportedStoragePropertyDefinition)result).Message, Is.EqualTo("x")); Assert.That(((UnsupportedStoragePropertyDefinition)result).InnerException, Is.SameAs(property1.InnerException)); }