public void MoreThanOneItemDoesNotExist() { ProductVersionList list = new ProductVersionList { new ProductDefinition { Version = 1 }, new ProductDefinition { Version = 2 }, new ProductDefinition { Version = 42 }, new ProductDefinition { Version = 3 } }; Product product = list.GetVersion(4); Assert.AreEqual(2, product.Version); }
public void MoreThanOneItem() { ProductVersionList list = new ProductVersionList { new ProductDefinition { Version = 1 }, new ProductDefinition { Version = 2 }, new ProductDefinition { Version = 42 }, new ProductDefinition { Version = 3 } }; Product product = list.GetCurrentVersion(); Assert.AreEqual(42, product.Version); }
public void OneItemDoesNotExist() { ProductVersionList list = new ProductVersionList { new ProductDefinition { Version = 42 } }; list.GetVersion(43); }
public void EmptyList() { ProductVersionList list = new ProductVersionList(); list.GetVersion(1); }
public void EmptyList() { ProductVersionList list = new ProductVersionList(); Product product = list.GetCurrentVersion(); Assert.IsNull(product); }
public void OneItemExists() { ProductVersionList list = new ProductVersionList { new ProductDefinition { Version = 42 } }; Product product = list.GetVersion(42); Assert.AreEqual(42, product.Version); }
/// <summary> /// Retrieves a workflow item for the work item. /// </summary> /// <param name="session">A secure session.</param> /// <param name="workItem">A work item.</param> /// <returns>An application workflow item (<see cref="ApplicationWorkflowItem"/>).</returns> private ApplicationWorkflowItem GetWorkflowItem(SecureSession session, UnitOfWork<ApplicationWorkItem> workItem) { ProductVersionList versionList = null; ProductDefinition currentVersion = null; foreach (var item in this.productCache) { if (item.Key == workItem.Item.Application.FormId) { versionList = item.Value; break; } } if (versionList == null) { versionList = new ProductVersionList(); this.productCache.Add(workItem.Item.Application.FormId, versionList); } // If current version is null, we have to load it and add it to the list. currentVersion = versionList.GetCurrentVersion(); if (currentVersion == null) { currentVersion = this.formServiceGateway.GetProduct(session, workItem.Item.Application.FormId, null); versionList.Add(currentVersion); } if (workItem.Item.Application.UseFormVersion && workItem.Item.Application.FormVersion != null && !versionList.HasVersion(workItem.Item.Application.FormVersion.Value)) { ProductDefinition specificVersion = this.formServiceGateway.GetProduct(session, workItem.Item.Application.FormId, workItem.Item.Application.FormVersion.Value); versionList.Add(specificVersion); } ProductDefinition linkedVersion = workItem.Item.Application.UseFormVersion && workItem.Item.Application.FormVersion != null ? versionList.GetVersion(workItem.Item.Application.FormVersion.Value) : currentVersion; ApplicationWorkflowItem workflowItem = new ApplicationWorkflowItem( workItem.Item.Application, workItem.Item.Application.ApplicationData, linkedVersion.FormDefinition.Pages.AllControls) { FormVersion = linkedVersion.Version }; return workflowItem; }