public void GetAttribute_NonExitentAttribute() { var attrs = new FileEntity("test"); Assert.IsNull(attrs.GetAttribute("test")); Assert.IsNull(attrs.GetAttribute("")); }
public void Remove_OneKey() { IEntity attrs = new FileEntity("test"); attrs = attrs.SetAttribute(new Attribute("test", new IntValue(42), AttributeSource.Custom)); Assert.IsNotNull(attrs.GetAttribute("test")); attrs = attrs.RemoveAttribute("test"); Assert.IsNull(attrs.GetAttribute("test")); }
public void SetAttribute_NewAttribute() { IEntity attrs = new FileEntity("test"); Assert.IsNull(attrs.GetAttribute("test")); attrs = attrs.SetAttribute(new Attribute("test", new IntValue(42), AttributeSource.Custom)); Assert.IsNotNull(attrs.GetAttribute("test")); Assert.AreEqual(42, attrs.GetValue <IntValue>("test").Value); }
public void SetEntity_NonMarkedEntityWithReplaceFalse() { var entity = new FileEntity("test"); _entityManager.SetEntity(entity, false); entity.SetAttribute(new Attribute("test", new IntValue(1), AttributeSource.Custom)); Assert.IsNotNull(entity.GetAttribute("test")); var modified = _entityManager.GetModified(); Assert.AreEqual(1, modified.Count); Assert.AreEqual(entity.Path, modified[0].Path); Assert.IsNull(modified[0].GetAttribute("test")); }
public void SetEntity_ModifiedListIsAListOfCopies() { var entity = new FileEntity("test"); _entityManager.SetEntity(entity, true); entity.SetAttribute(new Attribute("test", new IntValue(1), AttributeSource.Custom)); Assert.IsNotNull(entity.GetAttribute("test")); var modified = _entityManager.GetModified(); Assert.AreEqual(1, modified.Count); Assert.AreEqual(entity.Path, modified[0].Path); Assert.IsNull(modified[0].GetAttribute("test")); }
public void SetEntity_MarkedEntityWithReplaceFalse() { var entity1 = new FileEntity("test1") .SetAttribute(new Attribute("a", new IntValue(1), AttributeSource.Custom)); var entity2 = new FileEntity("test1") .SetAttribute(new Attribute("a", new IntValue(2), AttributeSource.Custom)); _entityManager.SetEntity(entity1, true); _entityManager.SetEntity(entity2, false); entity1.SetAttribute(new Attribute("test", new IntValue(1), AttributeSource.Custom)); Assert.IsNotNull(entity1.GetAttribute("test")); entity2.SetAttribute(new Attribute("test", new IntValue(1), AttributeSource.Custom)); Assert.IsNotNull(entity2.GetAttribute("test")); var modified = _entityManager.GetModified(); Assert.AreEqual(1, modified.Count); Assert.AreEqual(entity1.Path, modified[0].Path); Assert.IsNull(modified[0].GetAttribute("test")); Assert.AreEqual(1, modified[0].GetValue <IntValue>("a").Value); }
public void GetAttribute_NullAttributeName() { var attrs = new FileEntity("test"); attrs.GetAttribute(null); }