public void Test_Stringify_RoundTrip_OnePropOnly() { PersonParamSet person = new PersonParamSet { Name = "John \"FunnyGuy\" Doe" }; string stringified = person.SaveAsParameters(); PersonParamSet destringified = new PersonParamSet(stringified); destringified.ThrowIfPublicPropertiesNotEqual(person, ignoreProperties: new [] { nameof(PersonParamSet.OriginalParameterInputString), nameof(PersonParamSet.OriginalParameterCollection) }); stringified.ShouldBe("--Name=\"John \"FunnyGuy\" Doe\" "); }
public void Test_GetParameterCollection() { PersonParamSet person = new PersonParamSet { Name = "John \"FunnyGuy\" Doe", Happy = true, NullableTwo = 666 , Race = Races.White }; string stringified = person.SaveAsParameters(); PersonParamSet destringified = new PersonParamSet(stringified); var onlyExplicitCollection = destringified.GetParameterCollection(true, true); onlyExplicitCollection.ShouldSatisfyAllConditions( () => onlyExplicitCollection.Count.ShouldBe(4), () => onlyExplicitCollection.ShouldContain(new KeyValuePair <string, string>("Name", "John \"FunnyGuy\" Doe")), () => onlyExplicitCollection.ShouldContain(new KeyValuePair <string, string>("Happy", "True")), () => onlyExplicitCollection.ShouldContain(new KeyValuePair <string, string>("NullableTwo", "666")), () => onlyExplicitCollection.ShouldContain(new KeyValuePair <string, string>("Race", "White")) ); var allParams = destringified.GetParameterCollection(); allParams.ShouldSatisfyAllConditions( () => allParams.Count.ShouldBe(14), () => allParams.ShouldContain(new KeyValuePair <string, string>("Email", null)), () => allParams.ShouldContain(new KeyValuePair <string, string>("Name", "John \"FunnyGuy\" Doe")), () => allParams.ShouldContain(new KeyValuePair <string, string>("LastName", null)), () => allParams.ShouldContain(new KeyValuePair <string, string>("Path", null)), () => allParams.ShouldContain(new KeyValuePair <string, string>("Age", "0")), () => allParams.ShouldContain(new KeyValuePair <string, string>("Happy", "True")), () => allParams.ShouldContain(new KeyValuePair <string, string>("Drunk", "False")), () => allParams.ShouldContain(new KeyValuePair <string, string>("Rich", "False")), () => allParams.ShouldContain(new KeyValuePair <string, string>("Weight", "0")), () => allParams.ShouldContain(new KeyValuePair <string, string>("NullableTwo", "666")), () => allParams.ShouldContain(new KeyValuePair <string, string>("NullableOne", null)), () => allParams.ShouldContain(new KeyValuePair <string, string>("Gender", "Female")), () => allParams.ShouldContain(new KeyValuePair <string, string>("Race", "White")), () => allParams.ShouldContain(new KeyValuePair <string, string>("RegisteredDate", "0001-01-01T00:00:00.0000000")) ); }
public void Test_Stringify_RoundTrip() { PersonParamSet person = new PersonParamSet { Weight = 134.2M, Age = 24, NullableOne = 1, Drunk = true, Gender = Genders.Male, Email = "*****@*****.**", Path = "Somewhere Over The Rain...forest", RegisteredDate = new DateTime(1988, 02, 28) }; string stringified = person.SaveAsParameters(); stringified.ShouldNotContain(nameof(ParameterSet.OriginalParameterInputString)); PersonParamSet destringified = new PersonParamSet(stringified); destringified.ThrowIfPublicPropertiesNotEqual(person, ignoreProperties: new [] { nameof(PersonParamSet.OriginalParameterInputString), nameof(PersonParamSet.OriginalParameterCollection) }); }
public void Test_Stringify_RoundTrip_OnePropOnly_TestIgnorable() { PersonParamSet person = new PersonParamSet { Name = "John \"FunnyGuy\" Doe" }; person.PublicField = "PublicField Value"; PersonParamSet.PublicStaticProperty = "PublicStaticProperty Value"; person.SetPrivateInstanceProperty(true); string stringified = person.SaveAsParameters(); stringified.ShouldNotContain(nameof(ParameterSet.OriginalParameterInputString)); PersonParamSet destringified = new PersonParamSet(stringified); destringified.ShouldNotBeSameAs(person); destringified.Name.ShouldBe("John \"FunnyGuy\" Doe"); destringified.PublicField.ShouldNotBe(person.PublicField); destringified.PrivateInstanceProperty.ShouldNotBe(person.PrivateInstanceProperty); stringified.ShouldBe("--Name=\"John \"FunnyGuy\" Doe\" "); }