示例#1
0
        public async Task VerifyThatParameterCanBeDropped()
        {
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.ParameterGroup.Add(parameterGroup);
            this.iteration.Element.Add(elementDefinition);

            var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null);

            var payload = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.Parameter.Add(payload);
            this.assembler.Cache.TryAdd(new CacheKey(payload.Iid, this.iteration.Iid), new Lazy <Thing>(() => payload));
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(payload);
            dropInfo.SetupProperty(x => x.Effects);

            row.DragOver(dropInfo.Object);
            await row.Drop(dropInfo.Object);

            this.session.Verify(x => x.Write(It.Is <OperationContainer>(op => ((CDP4Common.DTO.Parameter)op.Operations.Single().ModifiedThing).Group == parameterGroup.Iid)));
        }
示例#2
0
        public async Task VerifyThatGroupMayBeDropped()
        {
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.ParameterGroup.Add(parameterGroup);
            this.iteration.Element.Add(elementDefinition);

            var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null);

            var gr2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.assembler.Cache.TryAdd(new CacheKey(gr2.Iid, this.iteration.Iid), new Lazy <Thing>(() => gr2));

            elementDefinition.ParameterGroup.Add(gr2);

            var dropinfo = new Mock <IDropInfo>();

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

            row.DragOver(dropinfo.Object);

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

            await row.Drop(dropinfo.Object);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
        }
示例#3
0
        public async Task VerifyThatParameterGetsCreatedWhenParameterTypeIsDropped()
        {
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.ParameterGroup.Add(parameterGroup);

            var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null);

            row.ThingCreator = this.thingCreator.Object;

            var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ratioScale         = new RatioScale(Guid.NewGuid(), null, null);

            simpleQuantityKind.DefaultScale = ratioScale;

            var payload  = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale);
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(payload);
            dropInfo.SetupProperty(x => x.Effects);

            await row.Drop(dropInfo.Object);

            this.thingCreator.Verify(x => x.CreateParameter(elementDefinition, parameterGroup, simpleQuantityKind, ratioScale, domainOfExpertise, this.session.Object));
        }