Exemplo n.º 1
0
        /// <summary>
        /// Performs the drop operation for a <see cref="Requirement"/> payload
        /// </summary>
        /// <param name="requirement">
        /// The <see cref="Requirement"/> that was dropped into this <see cref="RequirementsGroup"/>
        /// </param>
        private async Task OnRequirementDrop(Requirement requirement)
        {
            var firstRow = this.ContainedRows.OfType <RequirementRowViewModel>().FirstOrDefault();

            if (firstRow == null)
            {
                await this.ChangeRequirementGroup(requirement);
            }
            else
            {
                // insert before first
                var model   = (EngineeringModel)this.Thing.TopContainer;
                var orderPt = OrderHandlerService.GetOrderParameterType(model);

                if (orderPt == null)
                {
                    await this.ChangeRequirementGroup(requirement);

                    return;
                }

                var orderService = new RequirementOrderHandlerService(this.Session, orderPt);
                var transaction  = orderService.Insert(requirement, firstRow.Thing, InsertKind.InsertBefore);
                await this.Session.Write(transaction.FinalizeTransaction());
            }
        }
Exemplo n.º 2
0
        public void TestInsertLast()
        {
            var service = new RequirementOrderHandlerService(this.session.Object, this.orderType);

            var transaction = service.Insert(this.req4, this.req3, InsertKind.InsertAfter);
            var updatedPair = transaction.UpdatedThing.Single(x => x.Key.Iid == this.value4.Iid);
            var original    = (SimpleParameterValue)updatedPair.Key;
            var updated     = (SimpleParameterValue)updatedPair.Value;

            Assert.IsTrue(original.Value[0] != updated.Value[0]);
            Assert.IsTrue(int.Parse(updated.Value[0]) > int.Parse(this.value3.Value[0]));
        }
Exemplo n.º 3
0
        public void TestInsertBeforeWithMissing()
        {
            var service = new RequirementOrderHandlerService(this.session.Object, this.orderType);

            var transaction = service.Insert(this.req23, this.req22, InsertKind.InsertBefore);

            var added   = transaction.AddedThing.ToList();
            var updated = transaction.UpdatedThing.ToList();

            Assert.AreEqual(3, added.Count);
            Assert.AreEqual(3, updated.Count);

            var req23Clone = (Requirement)updated.Single(x => x.Key.Iid == this.req23.Iid).Value;
            var orderReq23 = (SimpleParameterValue)added.Single(x => req23Clone.ParameterValue.Contains(x));

            var req22Clone = (Requirement)updated.Single(x => x.Key.Iid == this.req22.Iid).Value;
            var orderReq22 = (SimpleParameterValue)added.Single(x => req22Clone.ParameterValue.Contains(x));

            var req21Clone = (Requirement)updated.Single(x => x.Key.Iid == this.req21.Iid).Value;
            var orderReq21 = (SimpleParameterValue)added.Single(x => req21Clone.ParameterValue.Contains(x));

            Assert.IsTrue(int.Parse(orderReq23.Value[0]) > int.Parse(orderReq21.Value[0]));
            Assert.IsTrue(int.Parse(orderReq22.Value[0]) > int.Parse(orderReq23.Value[0]));
        }