public void AddLinkToWorkitem() { const string url = "http://qqq.com"; const string title = "Url title"; var workitemAsset = new Asset(new TestOid(new TestAssetType("Workitem"), 100, null)); var workitem = new TestWorkitem(workitemAsset, null); var link = new Link(url, title); var linkAsset = new TestAssetType("Link"); var asset = new Asset(new TestOid(new TestAssetType("Link"), 10, null)); Expect.Call(_mockMetaModel.GetAssetType(VersionOneProcessor.LinkType)).Return(linkAsset); Expect.Call(_mockQueryBuilder.Query(string.Empty, Filter.Empty())).IgnoreArguments().Return(new AssetList()); Expect.Call(_mockServices.New(null, null)).IgnoreArguments().Return(asset); Expect.Call(() => _mockServices.Save(asset)); _repository.ReplayAll(); _processor.AddLinkToEntity(workitem, link); _repository.VerifyAll(); }
public void AddLinkToWorkitemWithExistingLink() { const string type = "Link"; const string url = "http://qqq.com"; const string title = "Url title"; var workitemAsset = new Asset(new TestOid(new TestAssetType("Workitem"), 100, null)); var workitem = new TestWorkitem(workitemAsset, null); var link = new Link(url, title); var linkAsset = new TestAssetType(type); var definitions = new Dictionary<string, IAttributeDefinition> { {Entity.NameProperty, new TestAttributeDefinition(linkAsset)}, {Link.OnMenuProperty, new TestAttributeDefinition(linkAsset)}, {Link.UrlProperty, new TestAttributeDefinition(linkAsset)}, }; var linkOid = new TestOid(new TestAssetType(type, definitions), 10, null); var existedLink = new Asset(linkOid); Expect.Call(_mockMetaModel.GetAssetType(VersionOneProcessor.LinkType)).Return(linkAsset); Expect.Call(_mockQueryBuilder.Query(string.Empty, Filter.Empty())).IgnoreArguments().Return(new AssetList { existedLink }); _repository.ReplayAll(); _processor.AddLinkToEntity(workitem, link); _repository.VerifyAll(); }
private bool Equals(Link other) { return Equals(other.Title, Title) && Equals(other.Url, Url) && other.OnMenu.Equals(OnMenu); }