public void CanProcess_NestedTypeValidMember() { //Arrange var value = new NestedType(); var target = new ObjectTextSubstitutionRule <NestedType>(value); var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue.StringValue"); //Act var actual = target.CanProcess(context); //Assert actual.Should().BeTrue(); }
public void CanProcess_NestedTypeNoSuchMember() { //Arrange var value = new SimpleType(); var target = new ObjectTextSubstitutionRule <SimpleType>(value); var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue.NonValue"); //Act var actual = target.CanProcess(context); //Assert actual.Should().BeFalse(); }
public void Process_ComplexTypeWithNullReferenceMemberReturnsEmptyString() { //Arrange var value = new NestedType(); var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue"); var target = new ObjectTextSubstitutionRule <NestedType>(value); //Act var actual = target.Process(context); //Assert actual.Should().BeEmpty(); }
public void CanProcess_SimpleTypeWithField() { //Arrange var value = new SimpleType(); var target = new ObjectTextSubstitutionRule <SimpleType>(value); var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "DoubleField"); //Act var actual = target.CanProcess(context); //Assert actual.Should().BeTrue(); }
public void Process_UsingSimpleTypeWithBadMember() { //Arrange var value = new SimpleType(); var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "BogusValue"); var target = new ObjectTextSubstitutionRule <SimpleType>(value); //Act var actual = target.Process(context); //Assert actual.Should().BeNull(); }
public void Process_ComplexTypeAsFinalValueCallsToString() { //Arrange var value = new NestedType() { SimpleValue = new SimpleType() }; var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue"); var target = new ObjectTextSubstitutionRule <NestedType>(value); //Act var actual = target.Process(context); //Assert actual.Should().Be(SimpleType.SimpleTypeStringName); }
public void Process_UsingSimpleTypeWithWrongCaseShouldWork() { //Arrange var value = new SimpleType() { Int32Value = 1, StringValue = "First" }; var expected = "1"; var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "int32VALUE"); var target = new ObjectTextSubstitutionRule <SimpleType>(value); //Act var actual = target.Process(context); //Assert actual.Should().Be(expected); }
public void Process_UsingNestedTypeWithWrongCaseShouldWork() { //Arrange var expected = 2011; var value = new NestedType() { SimpleValue = new SimpleType() { StringValue = "second", Int32Value = 2 }, DateTimeValue = new DateTime(expected, 10, 25, 1, 2, 3) }; var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "DateTimeValue.yEAR"); var target = new ObjectTextSubstitutionRule <NestedType>(value); //Act var actual = target.Process(context); //Assert actual.Should().Be(expected.ToString()); }
public void Process_UsingNestedType() { //Arrange var expected = "Second"; var value = new NestedType() { SimpleValue = new SimpleType() { StringValue = expected, Int32Value = 2 }, DateTimeValue = new DateTime(2011, 10, 25, 1, 2, 3) }; var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue.StringValue"); var target = new ObjectTextSubstitutionRule <NestedType>(value); //Act var actual = target.Process(context); //Assert actual.Should().Be(expected); }