Ejemplo n.º 1
0
        public void VerifyThatWriteExecutesOnTheSessionAndThatPropertiesAreSetFromViewModel()
        {
            var engineeringModelSetup = new EngineeringModelSetup
            {
                SourceEngineeringModelSetupIid = this.sourceEngineeringModelSetup.Iid
            };

            var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
            var transaction        = new ThingTransaction(transactionContext, this.siteDirClone);

            this.viewModel = new EngineeringModelSetupDialogViewModel(engineeringModelSetup, transaction, this.session.Object, true, ThingDialogKind.Create, null, this.siteDirClone);

            Assert.That(this.viewModel["Name"], Is.Not.Null.Or.Empty);

            Assert.IsFalse(this.viewModel.OkCommand.CanExecute(null));

            var newShortName  = "updatedshortname";
            var newName       = "updated name";
            var newStudyPhase = StudyPhaseKind.DESIGN_SESSION_PHASE;
            var newSourceId   = Guid.NewGuid();

            this.viewModel.ShortName  = newShortName;
            this.viewModel.Name       = newName;
            this.viewModel.StudyPhase = newStudyPhase;
            var newSourceModel = new EngineeringModelSetup(newSourceId, null, this.uri);

            this.viewModel.SourceEngineeringModelSetup = newSourceModel;

            this.viewModel.OkCommand.Execute(null);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
            Assert.IsNull(this.viewModel.WriteException);
            Assert.IsTrue(this.viewModel.DialogResult.Value);

            var clone = (EngineeringModelSetup)transaction.GetClone(engineeringModelSetup);

            Assert.AreEqual(newShortName, clone.ShortName);
            Assert.AreEqual(newName, clone.Name);
            Assert.AreEqual(newStudyPhase, clone.StudyPhase);
            Assert.AreEqual(newSourceId, clone.SourceEngineeringModelSetupIid);
        }
Ejemplo n.º 2
0
        public void VerifyOkCommandWithoutSourceModel()
        {
            var engineeringModelSetup = new EngineeringModelSetup();

            var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
            var transaction        = new ThingTransaction(transactionContext, this.siteDirClone);

            this.viewModel = new EngineeringModelSetupDialogViewModel(engineeringModelSetup, transaction, this.session.Object, true, ThingDialogKind.Create, null, this.siteDirClone);

            Assert.That(this.viewModel["Name"], Is.Not.Null.Or.Empty);
            Assert.IsFalse(this.viewModel.OkCommand.CanExecute(null));

            var newShortName = "EMShortname";
            var newName      = "EMName";

            this.viewModel.ShortName  = newShortName;
            this.viewModel.Name       = newName;
            this.viewModel.StudyPhase = StudyPhaseKind.DESIGN_SESSION_PHASE;
            this.viewModel.SourceEngineeringModelSetup = null;
            var srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null)
            {
                Name = "testRDL", ShortName = "test"
            };

            this.viewModel.SelectedSiteReferenceDataLibrary = srdl;

            this.viewModel.OkCommand.Execute(null);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
            Assert.IsNull(this.viewModel.WriteException);
            Assert.IsTrue(this.viewModel.DialogResult.Value);

            var clone = (EngineeringModelSetup)transaction.GetClone(engineeringModelSetup);

            Assert.AreEqual(newShortName, clone.ShortName);
            Assert.AreEqual(newName, clone.Name);
            Assert.AreEqual(StudyPhaseKind.DESIGN_SESSION_PHASE, clone.StudyPhase);
            Assert.IsNull(clone.SourceEngineeringModelSetupIid);
            Assert.AreEqual(1, clone.RequiredRdl.Count);
        }