public void Converts_From_Int() { //Arrange var id = new HiveId(1234); var converter = TypeDescriptor.GetConverter(typeof(HiveId)); var encodedId = id.ToString(); //Assert Assert.IsTrue(converter.CanConvertFrom(typeof(int))); Assert.IsTrue(converter.CanConvertTo(typeof(string))); Assert.AreEqual(1234, converter.ConvertTo(id, typeof(int))); Assert.IsTrue(id.Equals(converter.ConvertFrom(1234))); Assert.IsTrue(id.Equals(converter.ConvertFrom(encodedId))); Assert.AreEqual(id, converter.ConvertFrom(1234)); Assert.AreEqual(id, converter.ConvertFrom(encodedId)); }
public void EqualsImpl_WhenPassedGuid() { var val1 = Guid.NewGuid(); var val2 = new HiveId(val1); Assert.AreEqual(HiveIdValueTypes.Guid, val2.Value.Type); Assert.IsTrue(val1 == val2.Value); Assert.IsTrue(val2.Equals((object)val1)); // Test for passing into Equals(obj) method }
public void Converts_From_HiveId() { //Arrange var rawId = new HiveId("test-id"); var converter = TypeDescriptor.GetConverter(typeof(HiveId)); //Act //Assert Assert.IsTrue(converter.CanConvertFrom(typeof(HiveId))); Assert.IsTrue(converter.CanConvertTo(typeof(HiveId))); Assert.AreEqual(rawId, converter.ConvertTo(rawId, typeof(HiveId))); Assert.IsTrue(rawId.Equals(converter.ConvertFrom(rawId))); Assert.AreEqual(rawId, converter.ConvertFrom(rawId)); }
public void Converts_From_String() { //Arrange var rawId = new HiveId("My-Test-Template.cshtml"); var encodedId = rawId.ToString(); var converter = TypeDescriptor.GetConverter(typeof(HiveId)); //Act //Assert Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsTrue(converter.CanConvertTo(typeof(string))); Assert.AreEqual(encodedId, converter.ConvertTo(rawId, typeof(string))); Assert.IsTrue(rawId.Equals(converter.ConvertFrom(encodedId))); Assert.AreEqual(rawId, converter.ConvertFrom(encodedId)); }
/// <summary> /// Checks if the node Id is the root node and if so creates the root node and appends it to the /// NodeCollection based on the standard tree parameters /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> /// <remarks> /// This method ensure that all of the correct meta data is set for the root node so that the Rebel application works /// as expected. Meta data such as 'treeId' and 'searchable' /// </remarks> protected bool AddRootNodeToCollection(HiveId id, FormCollection queryStrings) { Mandate.ParameterNotEmpty(id, "id"); Mandate.ParameterCondition(!id.IsNullValueOrEmpty(), "id"); //if its the root model if (id.Equals(TreeId)) { //get the root model var rootNode = CreateRootNode(queryStrings); NodeCollection.Add(rootNode); return(true); } return(false); }
/// <summary> /// Checks if the node Id is the root node and if so creates the root node and appends it to the /// NodeCollection based on the standard tree parameters /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> /// <remarks> /// This method ensure that all of the correct meta data is set for the root node so that the Umbraco application works /// as expected. Meta data such as 'treeId' and 'searchable' /// </remarks> protected bool AddRootNodeToCollection(HiveId id, FormCollection queryStrings) { Mandate.ParameterNotEmpty(id, "id"); Mandate.ParameterCondition(!id.IsNullValueOrEmpty(), "id"); //if its the root model if (id.Equals(TreeId)) { //get the root model var rootNode = CreateRootNode(queryStrings); NodeCollection.Add(rootNode); return true; } return false; }