Exemplo n.º 1
0
        public void VerifyParticipantsAreInitialized()
        {
            Mock <ISession> session = new Mock <ISession>();
            var             thing   = new DomainOfExpertise();

            var viewModel = new DomainOfExpertiseRowViewModel(thing, session.Object, null);

            var initialParticipants = new[]
            {
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        thing
                    }
                },
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        thing
                    }
                },
            };

            viewModel.UpdateParticipants(initialParticipants);

            CollectionAssert.AreEquivalent(viewModel.ContainedRows.Select(r => r.Thing), initialParticipants);
        }
        public void VerifyThatViewModelPropertiesAreSetByConstructor()
        {
            var vm = new DomainOfExpertiseRowViewModel(this.domainOfExpertise, this.session.Object, null);

            Assert.AreEqual(this.name, vm.Name);
            Assert.AreEqual(this.shortName, vm.ShortName);
            Assert.AreEqual(this.isDeprecated, vm.IsDeprecated);
        }
        public void VerifyThatUpdateMessagesAreProcessedByTheRowViewModel()
        {
            var vm = new DomainOfExpertiseRowViewModel(this.domainOfExpertise, this.session.Object, null);

            var newName         = "new name";
            var newShortname    = "newshortname";
            var newIsDeprecated = false;

            this.domainOfExpertise.Name         = newName;
            this.domainOfExpertise.ShortName    = newShortname;
            this.domainOfExpertise.IsDeprecated = newIsDeprecated;
            // workaround to modify a read-only field
            var type = domainOfExpertise.GetType();

            type.GetProperty("RevisionNumber").SetValue(domainOfExpertise, 50);

            CDPMessageBus.Current.SendObjectChangeEvent(domainOfExpertise, EventKind.Updated);

            Assert.AreEqual(newName, vm.Name);
            Assert.AreEqual(newShortname, vm.ShortName);
            Assert.AreEqual(newIsDeprecated, vm.IsDeprecated);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add a new row that represents a <see cref="DomainOfExpertise"/> to the list of <see cref="DomainOfExpertise"/>.
        /// </summary>
        /// <param name="domainOfExpertise">
        /// The <see cref="DomainOfExpertise"/> that is to be added.
        /// </param>
        private void AddDomainOfExpertise(DomainOfExpertise domainOfExpertise)
        {
            var vm = new DomainOfExpertiseRowViewModel(domainOfExpertise, this.Session, this);

            this.DomainOfExpertises.Add(vm);
        }
Exemplo n.º 5
0
        public void VerifyParticipantsAreUpdated()
        {
            Mock <ISession> session        = new Mock <ISession>();
            var             expertise      = new DomainOfExpertise();
            var             otherExpertise = new DomainOfExpertise();

            var viewModel = new DomainOfExpertiseRowViewModel(expertise, session.Object, null);

            var participants = new[]
            {
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        expertise
                    }
                },
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        expertise
                    }
                },
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        expertise
                    }
                },
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        expertise
                    }
                },
                new Participant()
                {
                    Domain = new List <DomainOfExpertise> {
                        expertise
                    }
                },
            };

            var participantWithOtherExpertise = new Participant()
            {
                Domain = new List <DomainOfExpertise> {
                    otherExpertise
                }
            };

            //Add top 3
            viewModel.UpdateParticipants(participants.Take(3));

            //Add all with first replaced by non-matching expertise
            var participantsUpdate = participants.ToList();

            participantsUpdate[0] = participantWithOtherExpertise;

            viewModel.UpdateParticipants(participantsUpdate);

            //Should contain all but the first.
            CollectionAssert.AreEquivalent(viewModel.ContainedRows.Select(r => r.Thing), participants.Skip(1));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add the <see cref="DomainOfExpertise"/>
        /// </summary>
        /// <param name="domain">
        /// the <see cref="DomainOfExpertise"/> object to add
        /// </param>
        private void AddDomain(DomainOfExpertise domain)
        {
            var row = new DomainOfExpertiseRowViewModel(domain, this.Session, this);

            this.activeDomainFolderRow.ContainedRows.Add(row);
        }