public void ParametersTest(WsFederationMessageTheoryData theoryData) { TestUtilities.WriteHeader($"{this}.ParametersTest", theoryData); try { var wsFederationMessage = new WsFederationMessage { IssuerAddress = theoryData.IssuerAddress, Wreply = theoryData.Wreply, Wct = theoryData.Wct }; Assert.Equal(theoryData.IssuerAddress, wsFederationMessage.IssuerAddress); Assert.Equal(theoryData.Wreply, wsFederationMessage.Wreply); Assert.Equal(theoryData.Wct, wsFederationMessage.Wct); // add parameter wsFederationMessage.SetParameter(theoryData.Parameter1.Key, theoryData.Parameter1.Value); // add parameters var nameValueCollection = new NameValueCollection { { theoryData.Parameter2.Key, theoryData.Parameter2.Value }, { theoryData.Parameter3.Key, theoryData.Parameter3.Value } }; wsFederationMessage.SetParameters(nameValueCollection); // validate the parameters are added Assert.Equal(theoryData.Parameter1.Value, wsFederationMessage.Parameters[theoryData.Parameter1.Key]); Assert.Equal(theoryData.Parameter2.Value, wsFederationMessage.Parameters[theoryData.Parameter2.Key]); Assert.Equal(theoryData.Parameter3.Value, wsFederationMessage.Parameters[theoryData.Parameter3.Key]); // remove parameter wsFederationMessage.SetParameter(theoryData.Parameter1.Key, null); // validate the parameter is removed Assert.False(wsFederationMessage.Parameters.ContainsKey(theoryData.Parameter1.Key)); // create redirectUri var uriString = wsFederationMessage.BuildRedirectUrl(); Uri uri = new Uri(uriString); // convert query back to WsFederationMessage var wsFederationMessageReturned = WsFederationMessage.FromQueryString(uri.Query); // validate the parameters in the returned wsFederationMessage Assert.Equal(theoryData.Parameter2.Value, wsFederationMessageReturned.Parameters[theoryData.Parameter2.Key]); Assert.Equal(theoryData.Parameter3.Value, wsFederationMessageReturned.Parameters[theoryData.Parameter3.Key]); theoryData.ExpectedException.ProcessNoException(); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex); } }