Exemple #1
0
        public void VerifyThatWhenAIBuiltInRuleMetaDataIsDroppedARuleVerificationIsCreated()
        {
            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);
            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            listRowViewModel.ThingCreator = this.thingCreator.Object;

            var metaData = new Mock <IBuiltInRuleMetaData>();

            metaData.Setup(x => x.Name).Returns("test");

            var dropInfo = new Mock <IDropInfo>();

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

            listRowViewModel.Drop(dropInfo.Object);

            this.thingCreator.Verify(x => x.CreateBuiltInRuleVerification(ruleVerificationList, "test", this.session.Object));
        }
Exemple #2
0
        public void VerifyThatIfRuleIsNotInChainOfRdlOfRuleVerificationListDraggedDropEffectIsNone()
        {
            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);
            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            var binaryRelationshipRule = new BinaryRelationshipRule(Guid.NewGuid(), this.cache, this.uri);
            var siteRDL = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);

            siteRDL.Rule.Add(binaryRelationshipRule);
            this.sitedir.SiteReferenceDataLibrary.Add(siteRDL);

            var dropInfo = new Mock <IDropInfo>();

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

            listRowViewModel.DragOver(dropInfo.Object);

            Assert.AreEqual(DragDropEffects.None, dropInfo.Object.Effects);
        }
Exemple #3
0
        public void VerifytThatWhenNotARuleIsDraggedDropEffectIsNone()
        {
            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);
            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            var payload  = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            var dropInfo = new Mock <IDropInfo>();

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

            listRowViewModel.DragOver(dropInfo.Object);

            Assert.AreEqual(DragDropEffects.None, dropInfo.Object.Effects);
        }
Exemple #4
0
        public void VerifyThatWhenARuleIsDroppedARuleVerificationIsCreated()
        {
            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);
            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            listRowViewModel.ThingCreator = this.thingCreator.Object;

            var payload  = new BinaryRelationshipRule(Guid.NewGuid(), this.cache, this.uri);
            var dropInfo = new Mock <IDropInfo>();

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

            listRowViewModel.Drop(dropInfo.Object);

            this.thingCreator.Verify(x => x.CreateUserRuleVerification(ruleVerificationList, payload, this.session.Object));
        }
Exemple #5
0
        public void VerifyThatWhenIBuiltInRuleMetaDataIsDraggedDropEffectIsCopy()
        {
            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);
            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            var metaData = new Mock <IBuiltInRuleMetaData>();

            metaData.Setup(x => x.Name).Returns("test");

            var dropInfo = new Mock <IDropInfo>();

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

            listRowViewModel.DragOver(dropInfo.Object);

            Assert.AreEqual(DragDropEffects.Copy, dropInfo.Object.Effects);
        }
Exemple #6
0
        public void VerifyThatViolationAreAddedRemoved()
        {
            var decompositionRule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "decomposition"
            };

            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);

            // add a rule verification
            var builtInRuleVerification = new BuiltInRuleVerification(Guid.NewGuid(), this.cache, this.uri)
            {
                Name     = "BuiltIn",
                Status   = RuleVerificationStatusKind.INCONCLUSIVE,
                IsActive = true,
            };

            var userRuleVerification = new UserRuleVerification(Guid.NewGuid(), this.cache, this.uri)
            {
                IsActive = true,
                Rule     = decompositionRule
            };

            ruleVerificationList.RuleVerification.Add(userRuleVerification);
            ruleVerificationList.RuleVerification.Add(builtInRuleVerification);

            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            var violation = new RuleViolation(Guid.NewGuid(), this.cache, this.uri)
            {
                Description = "violation",
            };

            var builtinRow =
                listRowViewModel.ContainedRows.Single(x => x.Thing.ClassKind == ClassKind.BuiltInRuleVerification);
            var userRow = listRowViewModel.ContainedRows.Single(x => x.Thing.ClassKind == ClassKind.UserRuleVerification);

            Assert.IsEmpty(builtinRow.ContainedRows);
            Assert.IsEmpty(userRow.ContainedRows);

            builtInRuleVerification.Violation.Add(violation);
            this.revision.SetValue(builtInRuleVerification, 10);
            CDPMessageBus.Current.SendObjectChangeEvent(builtInRuleVerification, EventKind.Updated);
            Assert.IsNotEmpty(builtinRow.ContainedRows);

            builtInRuleVerification.Violation.Clear();
            this.revision.SetValue(builtInRuleVerification, 20);
            CDPMessageBus.Current.SendObjectChangeEvent(builtInRuleVerification, EventKind.Updated);
            Assert.IsEmpty(builtinRow.ContainedRows);

            userRuleVerification.Violation.Add(violation);
            this.revision.SetValue(userRuleVerification, 10);
            CDPMessageBus.Current.SendObjectChangeEvent(userRuleVerification, EventKind.Updated);
            Assert.IsNotEmpty(userRow.ContainedRows);

            userRuleVerification.Violation.Clear();
            this.revision.SetValue(userRuleVerification, 20);
            CDPMessageBus.Current.SendObjectChangeEvent(userRuleVerification, EventKind.Updated);
            Assert.IsEmpty(userRow.ContainedRows);
        }
Exemple #7
0
        public void VerifyThatPropertiesAreSetAndContainRowsArePopulated()
        {
            var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.iteration.RuleVerificationList.Add(ruleVerificationList);

            var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null);

            Assert.IsEmpty(listRowViewModel.ContainedRows);

            // add a rule verification
            var builtInRuleVerification = new BuiltInRuleVerification(Guid.NewGuid(), this.cache, this.uri)
            {
                Name     = "BuiltIn",
                Status   = RuleVerificationStatusKind.INCONCLUSIVE,
                IsActive = true
            };

            ruleVerificationList.RuleVerification.Add(builtInRuleVerification);
            this.revision.SetValue(ruleVerificationList, 2);
            CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated);

            var builtInRuleVerificationRow = listRowViewModel.ContainedRows.Single(x => x.Thing == builtInRuleVerification);

            Assert.AreEqual(builtInRuleVerification, builtInRuleVerificationRow.Thing);
            Assert.AreEqual("BuiltIn", ((RuleVerification)builtInRuleVerificationRow.Thing).Name);

            // add a rule verification
            var parameterizedCategoryRule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "Parameterized Category Rule"
            };

            var userRuleVerification = new UserRuleVerification(Guid.NewGuid(), this.cache, this.uri)
            {
                Status   = RuleVerificationStatusKind.INCONCLUSIVE,
                IsActive = true,
                Rule     = parameterizedCategoryRule
            };

            ruleVerificationList.RuleVerification.Add(userRuleVerification);
            this.revision.SetValue(ruleVerificationList, 3);
            CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated);

            var userRuleVerificationRow = listRowViewModel.ContainedRows.Single(x => x.Thing == userRuleVerification);

            Assert.AreEqual(userRuleVerification, userRuleVerificationRow.Thing);
            Assert.AreEqual("Parameterized Category Rule", ((RuleVerification)userRuleVerificationRow.Thing).Name);

            // Remove a rule verification
            ruleVerificationList.RuleVerification.Remove(builtInRuleVerification);
            this.revision.SetValue(ruleVerificationList, 4);
            CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated);
            Assert.AreEqual(1, listRowViewModel.ContainedRows.Count);

            // Remove a rule verification
            ruleVerificationList.RuleVerification.Remove(userRuleVerification);
            this.revision.SetValue(ruleVerificationList, 5);
            CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated);
            Assert.AreEqual(0, listRowViewModel.ContainedRows.Count);
        }