public void OptionsIn_Equals_Checks_If_Values_Are_Equal() { OptionsIn allOption = OptionsIn.ReturnElements.All; Assert.IsFalse(OptionsIn.CompressionMethod.None.Equals(allOption.Value)); Assert.IsTrue(OptionsIn.ReturnElements.All.Equals(allOption.Value)); }
public void OptionsIn_Parse_Duplicate_Keys_Returns_Single_Item() { var actual = OptionsIn.Parse("returnElements=all;returnElements=all"); Assert.IsNotNull(actual); Assert.AreEqual(1, actual.Count); Assert.AreEqual("returnElements", actual.Keys.Single()); Assert.AreEqual("all", actual.Values.Single()); }
public void OptionsIn_Dictionary_Operator_Performs_Implicit_Conversion() { OptionsIn allOption = OptionsIn.ReturnElements.All; Dictionary <string, string> actual = allOption; Assert.IsNotNull(actual); Assert.AreEqual(1, actual.Count); Assert.AreEqual(allOption.Key, actual.Keys.Single()); Assert.AreEqual(allOption.Value, actual.Values.Single()); }
public void OptionsIn_Parse_Returns_Empty_Dictionary() { var parseNull = OptionsIn.Parse(null); Assert.IsNotNull(parseNull); Assert.IsFalse(parseNull.Any()); var parseEmpty = OptionsIn.Parse(string.Empty); Assert.IsNotNull(parseEmpty); Assert.IsFalse(parseEmpty.Any()); }
public void OptionsIn_String_Operator_Performs_Implicit_Conversion() { OptionsIn nullOption = null; string nullString = nullOption; Assert.IsNull(nullString); OptionsIn allOption = OptionsIn.ReturnElements.All; string allValue = allOption; Assert.AreEqual("returnElements=all", allValue); }
/// <summary> /// Gets the value for the specified option. /// </summary> /// <param name="options">The options.</param> /// <param name="defaultValue">The default value.</param> /// <returns>The option value, if specified; otherwise, the default value.</returns> public static string GetValue(Dictionary <string, string> options, OptionsIn defaultValue) { _log.DebugFormat("Getting OptionsIn value: {0}", defaultValue?.Key); if (defaultValue == null) { return(null); } string value; if (!options.TryGetValue(defaultValue.Key, out value)) { value = defaultValue.Value; } return(value); }
public void OptionsIn_GetValue_Returns_Default_Value() { var returnElementsAll = OptionsIn.Parse("returnElements=all"); var nullValue = OptionsIn.GetValue(returnElementsAll, null); Assert.IsNull(nullValue); var foundValue = OptionsIn.GetValue(returnElementsAll, OptionsIn.ReturnElements.GetValues().Last()); Assert.IsNotNull(foundValue); Assert.AreEqual("all", foundValue); var firstValue = OptionsIn.CascadedDelete.GetValues().Last(); var defaultValue = OptionsIn.GetValue(returnElementsAll, firstValue); Assert.IsNotNull(defaultValue); Assert.AreEqual(firstValue.Value, defaultValue); }
public void OptionsIn_Join_Concatenates_Multiple_Options_Into_Single_String() { Assert.AreEqual( "maxReturnNodes=1;requestLatestValues=2", OptionsIn.Join(OptionsIn.MaxReturnNodes.Eq(1), OptionsIn.RequestLatestValues.Eq(2))); Assert.AreEqual( "compressionMethod=none;compressionMethod=gzip", OptionsIn.Join(OptionsIn.CompressionMethod.GetValues().ToArray <OptionsIn>())); Assert.AreEqual( "requestObjectSelectionCapability=none;requestObjectSelectionCapability=true", OptionsIn.Join(OptionsIn.RequestObjectSelectionCapability.GetValues().ToArray <OptionsIn>())); Assert.AreEqual( "requestPrivateGroupOnly=false;requestPrivateGroupOnly=true", OptionsIn.Join(OptionsIn.RequestPrivateGroupOnly.GetValues().ToArray <OptionsIn>())); Assert.AreEqual( "dataVersion=1.3.1.1;dataVersion=1.4.1.1;dataVersion=2.0", OptionsIn.Join(OptionsIn.DataVersion.Version131, OptionsIn.DataVersion.Version141, OptionsIn.DataVersion.Version200)); }