public async Task VerifyDropElementDefExceptionCaught()
        {
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.sitedir.Domain.Add(domainOfExpertise);
            this.engineeringModelSetup.ActiveDomain.Add(domainOfExpertise);

            var model2 = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var modelsetup2 = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelIid = model2.Iid
            };

            model2.EngineeringModelSetup = modelsetup2;
            modelsetup2.ActiveDomain.Add(domainOfExpertise);

            this.sitedir.Model.Add(modelsetup2);

            var model2Iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var def = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = domainOfExpertise
            };

            model2.Iteration.Add(model2Iteration);
            model2Iteration.Element.Add(def);

            this.assembler.Cache.TryAdd(new CacheKey(model2.Iid, null), new Lazy <Thing>(() => model2));
            this.assembler.Cache.TryAdd(new CacheKey(model2Iteration.Iid, null), new Lazy <Thing>(() => model2Iteration));
            this.assembler.Cache.TryAdd(new CacheKey(def.Iid, model2Iteration.Iid), new Lazy <Thing>(() => def));

            var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null);

            var dropinfo = new Mock <IDropInfo>();

            this.session.Setup(x => x.OpenIterations)
            .Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >
            {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(domainOfExpertise, null) },
                { model2Iteration, new Tuple <DomainOfExpertise, Participant>(domainOfExpertise, null) }
            });

            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);

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

            dropinfo.SetupProperty(x => x.Effects);
            dropinfo.Object.Effects = DragDropEffects.All;
            dropinfo.Setup(x => x.KeyStates).Returns(DragDropKeyStates.LeftMouseButton);

            this.session.Setup(x => x.Write(It.IsAny <OperationContainer>())).Throws(new Exception("test"));

            await vm.Drop(dropinfo.Object);

            Assert.AreEqual("test", vm.Feedback);
        }
Exemple #2
0
        public void VerifyThatDropsWorkIfNoDomain()
        {
            var vm         = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null);
            var dropinfo   = new Mock <IDropInfo>();
            var droptarget = new Mock <IDropTarget>();

            dropinfo.Setup(x => x.TargetItem).Returns(droptarget.Object);

            vm.Drop(dropinfo.Object);
            droptarget.Verify(x => x.Drop(dropinfo.Object), Times.Once);
        }
Exemple #3
0
        public void VerifyThatDropsWorkDomain()
        {
            var vm         = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null);
            var dropinfo   = new Mock <IDropInfo>();
            var droptarget = new Mock <IDropTarget>();

            dropinfo.Setup(x => x.TargetItem).Returns(droptarget.Object);
            droptarget.Setup(x => x.Drop(It.IsAny <IDropInfo>())).Throws(new Exception("ex"));

            vm.Drop(dropinfo.Object);
            droptarget.Verify(x => x.Drop(dropinfo.Object));

            Assert.AreEqual("ex", vm.Feedback);
        }