Exemplo n.º 1
0
        public void VerifyThatGroupsCanBeAddedOrRemoved()
        {
            var row = new RequirementsSpecificationRowViewModel(this.spec2, this.session.Object, this.requirementBrowserViewModel);

            row.IsParametricConstraintDisplayed  = true;
            row.IsSimpleParameterValuesDisplayed = true;

            var groups = row.ContainedRows.Where(x => x.Thing is RequirementsGroup);

            Assert.AreEqual(3, groups.Count());

            var grp1Row = row.ContainedRows.Single(x => x.Thing.Iid == this.grp1.Iid);

            Assert.AreEqual(5, grp1Row.ContainedRows.Count);

            var newgrp = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.grp1.Group.Add(newgrp);

            this.revision.SetValue(this.grp1, 2);
            this.revision.SetValue(this.spec2, 2);
            CDPMessageBus.Current.SendObjectChangeEvent(this.grp1, EventKind.Updated);
            CDPMessageBus.Current.SendObjectChangeEvent(this.spec2, EventKind.Updated);

            Assert.AreEqual(6, grp1Row.ContainedRows.Count);

            this.spec2.Group.Remove(this.grp2);
            this.revision.SetValue(this.spec2, 3);
            CDPMessageBus.Current.SendObjectChangeEvent(this.spec2, EventKind.Updated);

            groups = row.ContainedRows.Where(x => x.Thing is RequirementsGroup);
            Assert.AreEqual(2, groups.Count());
        }
Exemplo n.º 2
0
        public void VerifyThatWhenSpecIsDeprecatedTheRowIsDeprecatedAsWell()
        {
            this.spec1.IsDeprecated = true;
            var row = new RequirementsSpecificationRowViewModel(this.spec1, this.session.Object, this.requirementBrowserViewModel);

            Assert.IsTrue(row.IsDeprecated);
        }
Exemplo n.º 3
0
        public void VerifyThatDragOverParameterWorks()
        {
            var containerRow = new RequirementsSpecificationRowViewModel(this.spec1, this.session.Object, null);
            var param        = new BooleanParameterType();
            var tuple        = new Tuple <ParameterType, MeasurementScale>(param, null);
            var dropinfo     = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(tuple);
            dropinfo.SetupProperty(x => x.Effects);

            this.permissionService.Setup(x => x.CanWrite(ClassKind.RequirementsContainerParameterValue, It.IsAny <RequirementsSpecification>())).Returns(false);

            containerRow.DragOver(dropinfo.Object);
            Assert.AreEqual(DragDropEffects.None, dropinfo.Object.Effects);

            this.permissionService.Setup(x => x.CanWrite(ClassKind.RequirementsContainerParameterValue, It.IsAny <RequirementsSpecification>())).Returns(true);
            containerRow.DragOver(dropinfo.Object);
            Assert.AreEqual(DragDropEffects.Copy, dropinfo.Object.Effects);

            this.spec1.ParameterValue.Add(new RequirementsContainerParameterValue {
                ParameterType = param
            });
            containerRow.DragOver(dropinfo.Object);
            Assert.AreEqual(DragDropEffects.None, dropinfo.Object.Effects);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RequirementContainerRowViewModel{T}"/> class
 /// </summary>
 /// <param name="reqContainer">The <see cref="RequirementsSpecification"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
 /// <param name="topNode">The top level node for this row</param>
 protected RequirementContainerRowViewModel(T reqContainer, ISession session, IViewModelBase <Thing> containerViewModel, RequirementsSpecificationRowViewModel topNode = null)
     : base(reqContainer, session, containerViewModel)
 {
     this.simpleParameters = new CDP4Composition.FolderRowViewModel("Simple Parameter Values", "Simple Parameter Values", this.Session, this);
     this.ContainedRows.Add(this.simpleParameters);
     this.TopParentRow = topNode ?? this as RequirementsSpecificationRowViewModel;
 }
Exemplo n.º 5
0
        public void VerifyThatAddingRequirementGroupUpdatesRequirementsSpecificationContainedRows()
        {
            var row = new RequirementsSpecificationRowViewModel(this.reqSpec, this.session.Object, this.requirementBrowserViewModel);

            var groups = row.ContainedRows.Where(x => x.Thing is RequirementsGroup);

            Assert.AreEqual(2, groups.Count());

            var grp1Row = row.ContainedRows.Single(x => x.Thing.Iid == this.grp1.Iid);

            Assert.AreEqual(2, grp1Row.ContainedRows.Count);

            var newgrp = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.grp1.Group.Add(newgrp);

            this.revision.SetValue(this.grp1, 2);
            this.revision.SetValue(this.reqSpec, 2);
            CDPMessageBus.Current.SendObjectChangeEvent(this.grp1, EventKind.Updated);
            CDPMessageBus.Current.SendObjectChangeEvent(this.reqSpec, EventKind.Updated);

            Assert.AreEqual(3, grp1Row.ContainedRows.Count);

            this.reqSpec.Group.Remove(this.grp2);
            this.revision.SetValue(this.reqSpec, 3);
            CDPMessageBus.Current.SendObjectChangeEvent(this.reqSpec, EventKind.Updated);

            groups = row.ContainedRows.Where(x => x.Thing is RequirementsGroup);
            Assert.AreEqual(1, groups.Count());
        }
Exemplo n.º 6
0
 /// <summary>
 /// Add a row representing a <see cref="RequirementsSpecification"/>
 /// </summary>
 /// <param name="spec">The <see cref="RequirementsSpecification"/></param>
 private void AddSpecificationRow(RequirementsSpecification spec)
 {
     if (!this.ReqSpecificationRows.Select(x => x.Thing).Contains(spec))
     {
         var row = new RequirementsSpecificationRowViewModel(spec, this.Session, this);
         this.ReqSpecificationRows.Add(row);
     }
 }
Exemplo n.º 7
0
        public void VerifyThatPropertiesAreSet()
        {
            var row = new RequirementsSpecificationRowViewModel(this.spec1, this.session.Object, this.requirementBrowserViewModel);

            Assert.AreEqual("spec1", row.Name);
            Assert.AreEqual("spec1", row.ShortName);
            Assert.AreSame(this.domain, row.Owner);
            Assert.That(row.Definition, Is.Null.Or.Empty);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RequirementsGroupRowViewModel" /> class
 /// </summary>
 /// <param name="group">The <see cref="RequirementsGroup" /></param>
 /// <param name="session">The <see cref="ISession" /></param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}" /></param>
 /// <param name="topNode">The top level node for this row</param>
 public RequirementsGroupRowViewModel(
     RequirementsGroup group,
     ISession session,
     IViewModelBase <Thing> containerViewModel,
     RequirementsSpecificationRowViewModel topNode)
     : base(group, session, containerViewModel, topNode)
 {
     this.UpdateProperties();
 }
Exemplo n.º 9
0
        public void VerifyThatDropParameterTypeWorks()
        {
            var containerRow = new RequirementsSpecificationRowViewModel(this.spec1, this.session.Object, null);

            var param    = new BooleanParameterType();
            var tuple    = new Tuple <ParameterType, MeasurementScale>(param, null);
            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(tuple);

            containerRow.Drop(dropinfo.Object);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
        }
Exemplo n.º 10
0
        public void VerifyThatRequirementCanBeAddedOrRemoved()
        {
            var spec2Row = new RequirementsSpecificationRowViewModel(this.spec2, this.session.Object, this.requirementBrowserViewModel);

            var reqRows = spec2Row.ContainedRows.Where(x => x.Thing is Requirement).ToList();

            Assert.AreEqual(0, reqRows.Count);

            this.req21.Group = null;
            this.revision.SetValue(this.req21, 2);

            CDPMessageBus.Current.SendObjectChangeEvent(this.req21, EventKind.Updated);
            reqRows = spec2Row.ContainedRows.Where(x => x.Thing is Requirement).ToList();
            Assert.AreEqual(1, reqRows.Count);


            var grp1Row = spec2Row.ContainedRows.Single(x => x.Thing.Iid == this.grp1.Iid);

            Assert.IsFalse(grp1Row.ContainedRows.Any(x => x.Thing.Iid == this.req21.Iid));
            this.req21.Group = this.grp4;
            this.revision.SetValue(this.req21, 3);

            CDPMessageBus.Current.SendObjectChangeEvent(this.req21, EventKind.Updated);
            Assert.IsFalse(grp1Row.ContainedRows.Any(x => x.Thing.Iid == this.req21.Iid));

            var grp11Row = grp1Row.ContainedRows.Single(x => x.Thing.Iid == this.grp4.Iid);

            Assert.IsTrue(grp11Row.ContainedRows.Any(x => x.Thing.Iid == this.req21.Iid));
            this.req21.Group = null;
            this.revision.SetValue(this.req21, 4);

            CDPMessageBus.Current.SendObjectChangeEvent(this.req21, EventKind.Updated);
            Assert.IsFalse(grp11Row.ContainedRows.Any(x => x.Thing.Iid == this.req21.Iid));
            Assert.IsTrue(spec2Row.ContainedRows.Any(x => x.Thing.Iid == this.req21.Iid));

            var newreq = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.spec2.Requirement.Add(newreq);
            this.revision.SetValue(this.spec2, 5);

            CDPMessageBus.Current.SendObjectChangeEvent(this.spec2, EventKind.Updated);
            reqRows = spec2Row.ContainedRows.Where(x => x.Thing is Requirement).ToList();
            Assert.AreEqual(2, reqRows.Count);

            this.spec2.Requirement.Remove(newreq);
            this.revision.SetValue(this.spec2, 6);

            CDPMessageBus.Current.SendObjectChangeEvent(this.spec2, EventKind.Updated);
            reqRows = spec2Row.ContainedRows.Where(x => x.Thing is Requirement).ToList();
            Assert.AreEqual(1, reqRows.Count);
        }
Exemplo n.º 11
0
        public void VerifyRequirementDrop()
        {
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(this.req);
            dropInfo.Setup(x => x.Effects).Returns(DragDropEffects.Move);
            var row = new RequirementsSpecificationRowViewModel(this.reqSpec, this.session.Object, null);

            Assert.AreEqual(1, this.reqSpec.Requirement.Count);

            row.Drop(dropInfo.Object);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Exactly(1));
        }
Exemplo n.º 12
0
        /// <summary>
        /// The populate requirement specification rows.
        /// </summary>
        private void PopulateRows()
        {
            foreach (var map in this.thingFactory.SpecificationMap)
            {
                var row = new RequirementsSpecificationRowViewModel(map.Value, this.Session, null);
                this.PreviewRows.Add(row);
            }

            foreach (var keyValuePair in this.thingFactory.RelationGroupMap)
            {
                var row = new BinaryRelationshipRowViewModel(keyValuePair.Value, this.Session, null);
                this.PreviewRows.Add(row);
            }

            foreach (var keyValuePair in this.thingFactory.SpecRelationMap)
            {
                var row = new BinaryRelationshipRowViewModel(keyValuePair.Value, this.Session, null);
                this.PreviewRows.Add(row);
            }
        }
Exemplo n.º 13
0
        public void VerifyRequirementGroupDrop()
        {
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(this.grp1);
            dropInfo.Setup(x => x.Effects).Returns(DragDropEffects.Move);
            dropInfo.Setup(x => x.KeyStates).Returns(DragDropKeyStates.LeftMouseButton);

            var row = new RequirementsSpecificationRowViewModel(this.spec1, this.session.Object, this.requirementBrowserViewModel);

            row.IsParametricConstraintDisplayed  = true;
            row.IsSimpleParameterValuesDisplayed = true;

            Assert.AreEqual(0, this.spec1.Group.Count);
            Assert.AreEqual(5, row.ContainedRows.Count);

            row.Drop(dropInfo.Object);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Exactly(1));
        }
Exemplo n.º 14
0
        public void VerifyDragOver()
        {
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
            var row = new RequirementsSpecificationRowViewModel(this.spec1, this.session.Object, null);

            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Effects).Returns(DragDropEffects.Move);
            dropinfo.Setup(x => x.Payload).Returns(this.req1);

            row.DragOver(dropinfo.Object);
            Assert.AreEqual(DragDropEffects.Move, dropinfo.Object.Effects);

            dropinfo.Setup(x => x.Payload).Returns(this.grp1);
            row.DragOver(dropinfo.Object);
            Assert.AreEqual(DragDropEffects.Move, dropinfo.Object.Effects);

            dropinfo.Setup(x => x.Payload).Returns(this.iteration);
            row.DragOver(dropinfo.Object);
            dropinfo.VerifySet(x => x.Effects = DragDropEffects.None);
        }