public void TestAttributeAccessor() { GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue original = new AttributeValue("SnagL"); globalAttributeCollection.Clear(); globalAttributeCollection.Add(attribute, original); Assert.IsTrue(globalAttributeCollection[attribute].Contains("SnagL")); }
public void TestAddMethodThrowsExceptionIfNullAttributeValue() { bool exceptionCaught = false; GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); try { globalAttributeCollection.Add(attribute, null); } catch (System.ArgumentNullException) { exceptionCaught = true; } Assert.IsTrue(exceptionCaught); }
public void TestChangingAttributeProperties() { Attribute attribute = new Attribute("Name"); object oldValue = null; object newValue = null; string propertyChanged = string.Empty; attribute.PropertyChanged += (object sender, PropertyChangedEventArgs<object> e) => { propertyChanged = e.PropertyName; oldValue = e.OldValue; newValue = e.NewValue; }; // Change semantic type EnqueueCallback(() => attribute.SemanticType = SemanticType.Name); EnqueueConditional(() => propertyChanged != string.Empty); EnqueueCallback(() => Assert.AreEqual<string>("SemanticType", propertyChanged)); EnqueueCallback(() => Assert.AreEqual<SemanticType>(SemanticType.Unknown, (SemanticType)oldValue)); EnqueueCallback(() => Assert.AreEqual<SemanticType>(SemanticType.Name, (SemanticType)newValue)); EnqueueCallback(() => oldValue = null); EnqueueCallback(() => newValue = null); EnqueueCallback(() => propertyChanged = string.Empty); // Change visibility EnqueueCallback(() => attribute.Visible = false); EnqueueConditional(() => propertyChanged != string.Empty); EnqueueCallback(() => Assert.AreEqual<string>("Visible", propertyChanged)); EnqueueCallback(() => Assert.IsTrue((bool)oldValue)); EnqueueCallback(() => Assert.IsFalse((bool)newValue)); EnqueueCallback(() => oldValue = null); EnqueueCallback(() => newValue = null); EnqueueCallback(() => propertyChanged = string.Empty); // Change preferred similarity measure EnqueueCallback(() => attribute.SetPreferredSimilarityMeasure(typeof(LevenshteinDistanceStringSimilarityMeasure))); EnqueueConditional(() => propertyChanged != string.Empty); EnqueueCallback(() => Assert.AreEqual<string>("PreferredSimilarityMeasure", propertyChanged)); EnqueueCallback(() => Assert.AreEqual<string>(string.Empty, (string)oldValue)); EnqueueCallback(() => Assert.AreEqual<string>(typeof(LevenshteinDistanceStringSimilarityMeasure).FullName, (string)newValue)); EnqueueCallback(() => oldValue = null); EnqueueCallback(() => newValue = null); EnqueueCallback(() => propertyChanged = string.Empty); EnqueueTestComplete(); }
public void TestInequalityOfAttributesWithEqualityOperator() { Attribute attribute1 = new Attribute("SnagL1"); Attribute attribute2 = new Attribute("SnagL2"); Assert.IsFalse(attribute1 == attribute2); }
public void TestInequalityOfAttributes() { Attribute attribute1 = new Attribute("SnagL1"); Attribute attribute2 = new Attribute("SnagL2"); Assert.AreNotEqual<Attribute>(attribute1, attribute2); }
public void TestCreateVisibleAttributeWithName() { Attribute attribute = new Attribute("Name", true); Assert.AreEqual<string>("Name", attribute.Name); Assert.IsTrue(attribute.Visible); Assert.AreEqual<SemanticType>(attribute.SemanticType, SemanticType.Unknown); }
public void TestCreateHiddenAttributeWithProvidedName() { Attribute attribute = new Attribute("Name", false); Assert.AreEqual<string>("Name", attribute.Name); Assert.IsFalse(attribute.Visible); Assert.AreEqual<SemanticType>(attribute.SemanticType, SemanticType.Unknown); }
public void TestClearMethodClearsGlobalAttributeCollection() { GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue original = new AttributeValue("SnagL"); globalAttributeCollection.Add(attribute, original); // Make sure everything is working. Otherwise, we might have an invalid test. if (!(globalAttributeCollection.GetAttributes().Count > 0)) { Assert.Inconclusive("Attribute collection count wasn't > 0 after attribute added."); } globalAttributeCollection.Clear(); Assert.IsTrue(globalAttributeCollection.GetAttributes().Count == 0); }
public void TestAttributesDefaultToVisible() { Attribute attribute = new Attribute("Name"); Assert.IsTrue(attribute.Visible); }
public void TestToStringReturnsNameOfAttribute() { string expected = "SnagL"; Attribute attribute = new Attribute(expected); Assert.AreEqual(expected, attribute.ToString()); Assert.AreEqual(attribute.Name, attribute.ToString()); }
public void VerifyCollectionContainsAttributeAfterAddingItRetrieveByName() { GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue value = new AttributeValue("SnagL"); bool actual; globalAttributeCollection.Add(attribute, value); actual = globalAttributeCollection.ContainsAttribute("SnagL"); Assert.IsTrue(actual); }
public void TestStringAccessor() { GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue original = new AttributeValue("SnagL"); globalAttributeCollection.Clear(); globalAttributeCollection.Add(attribute, original); Assert.IsTrue(globalAttributeCollection["SnagL"].Count > 0); }
public void TestRemoveByStringRemovesAttribute() { GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue original = new AttributeValue("SnagL"); globalAttributeCollection.Add(attribute, original); if (!globalAttributeCollection.ContainsAttribute(attribute)) { Assert.Inconclusive("The Attribute that was just added to the GlobalAttributeCollection was not found"); } globalAttributeCollection.Remove(attribute.Name); Assert.IsFalse(globalAttributeCollection.ContainsAttribute(attribute)); }
public void TestGetAttributeByName() { Attribute actual; Attribute expected = new Attribute("SnagL"); AttributeValue value = new AttributeValue("SnagL"); GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); globalAttributeCollection.Add(expected, value); actual = globalAttributeCollection.GetAttribute(expected.Name); Assert.AreEqual<Attribute>(expected, actual); }
public void TestContainsAttributeByString() { GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue original = new AttributeValue("SnagL"); globalAttributeCollection.Add(attribute, original); Assert.IsTrue(globalAttributeCollection.ContainsAttribute(attribute.Name)); }
public void TestSetSimilarityMethodAcceptsOnlyISimilarityMeasureObjects() { bool exceptionThrown = false; Attribute attribute = new Attribute("Name"); try { attribute.SetPreferredSimilarityMeasure(typeof(string)); } catch (System.ArgumentException) { exceptionThrown = true; } Assert.IsTrue(exceptionThrown); }
public void TestSettingSimilarityMeasure() { Attribute attribute = new Attribute("Name"); ISimilarityMeasure measure = new AlphabeticalSimilarityMeasure(); attribute.SetPreferredSimilarityMeasure(typeof(AlphabeticalSimilarityMeasure)); Assert.AreEqual(attribute.PreferredSimilarityMeasure, typeof(AlphabeticalSimilarityMeasure).FullName); }
public void TestCreateAttributeWithInvalidPreferredSimilarity() { bool exceptionThrown; string errorMessage; try { Attribute attribute = new Attribute("Name", typeof(Attribute)); exceptionThrown = false; errorMessage = string.Empty; } catch (System.ArgumentException ex) { exceptionThrown = true; errorMessage = ex.Message; } Assert.IsTrue(exceptionThrown); Assert.IsTrue(errorMessage.Contains("The provided type was not a valid Similarity Measure")); }
public void TestAttributesDefaultToUnknownSemanticType() { Attribute attribute = new Attribute("Name"); Assert.IsTrue(attribute.SemanticType == SemanticType.Unknown); }
public void TestCreateAttributeWithNameSemanticTypePrefferedSim() { Attribute attribute = new Attribute("Name", typeof(LevenshteinDistanceStringSimilarityMeasure) , SemanticType.Name); Assert.AreEqual<string>("Name", attribute.Name); Assert.IsTrue(attribute.Visible); Assert.AreEqual<string>(attribute.PreferredSimilarityMeasure, typeof(LevenshteinDistanceStringSimilarityMeasure).FullName); Assert.AreEqual<SemanticType>(attribute.SemanticType, SemanticType.Name); }
public void TestCreateAttributeWithNullName() { bool exceptionThrown; string errorMessage; try { Attribute attribute = new Attribute(null); exceptionThrown = false; errorMessage = string.Empty; } catch (System.ArgumentNullException ex) { exceptionThrown = true; errorMessage = ex.Message; } Assert.IsTrue(exceptionThrown); Assert.IsTrue(errorMessage.Contains("A name must be provided for this attribute")); }
public void TestAttributeValueUpdated() { bool eventRaised = false; GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL"); Attribute attribute = new Attribute("SnagL"); AttributeValue original = new AttributeValue("SnagL"); AttributeValue expected = new AttributeValue("SnagLNew"); AttributeValue actual = null; globalAttributeCollection.AttributeListUpdated += (sender, e) => { actual = e.NewValue; eventRaised = true; }; EnqueueCallback(() => globalAttributeCollection.Clear()); EnqueueCallback(() => globalAttributeCollection.Add(attribute, original)); EnqueueCallback(() => globalAttributeCollection.Update(attribute, expected, original)); EnqueueConditional(() => eventRaised); EnqueueCallback(() => Assert.IsTrue(globalAttributeCollection[attribute].Contains(expected.Value))); EnqueueCallback(() => Assert.AreEqual(expected.Value, actual.Value)); EnqueueTestComplete(); }