public static void GetIndividualPropertyDetailsByPropertyName_Should_Throw_Exception_When_Obj_Is_Null() { // arrange MyExampleWithIdProperty obj = null; // act Exception ex = Assert.Throws <ArgumentNullException>(() => PropertyHelper .GetIndividualPropertyDetailsByPropertyName(obj, "UniqueId")); // assert Assert.Equal("Value cannot be null.\r\nParameter name: obj", ex.Message); }
public static void GetIndividualPropertyDetailsByPropertyName_Should_Get_Null() { // arrange MyExampleWithIdProperty obj = new MyExampleWithIdProperty { Id = Guid.Parse("5be8f701-8358-4ea9-b2d1-5006d516da21"), SomeString = "Test" }; // act var result = PropertyHelper .GetIndividualPropertyDetailsByPropertyName(obj, "InvalidProperty"); // assert Assert.Null(result); }
public static void GetIndividualPropertyDetailsByPropertyName_Should_Throw_Exception_When_PropertyName_Is_Empty_String() { // arrange MyExampleWithIdProperty obj = new MyExampleWithIdProperty { Id = Guid.Parse("5be8f701-8358-4ea9-b2d1-5006d516da21"), SomeString = "Test" }; // act Exception ex = Assert.Throws <ArgumentNullException>(() => PropertyHelper .GetIndividualPropertyDetailsByPropertyName(obj, "")); // assert Assert.Equal("Value cannot be null.\r\nParameter name: propertyName", ex.Message); }
public static void GetIndividualPropertyDetailsByPropertyName_Should_Get_Value() { // arrange MyExampleWithIdProperty obj = new MyExampleWithIdProperty { Id = Guid.Parse("5be8f701-8358-4ea9-b2d1-5006d516da21"), SomeString = "Test" }; // act var result = PropertyHelper .GetIndividualPropertyDetailsByPropertyName(obj, nameof(MyExampleWithIdProperty.Id)); // assert Assert.NotNull(result); Assert.Equal(obj.Id, result.Value); Assert.Equal(nameof(MyExampleWithIdProperty.Id), result.PropertyInfo.Name); }