public async Task SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            var things        = new List <Thing>();
            var sitedirectory = new CDP4Common.DTO.SiteDirectory(Guid.NewGuid(), 0);

            things.Add(sitedirectory);

            this.engineeringMdodelSetupGuid = Guid.NewGuid();
            this.engineeringMdodelGuid      = Guid.NewGuid();
            var engineeringmodelsetup = new EngineeringModelSetup(this.engineeringMdodelSetupGuid, 0);

            engineeringmodelsetup.ShortName           = "test_model";
            engineeringmodelsetup.Name                = "test model";
            engineeringmodelsetup.EngineeringModelIid = this.engineeringMdodelGuid;
            things.Add(engineeringmodelsetup);

            this.uri = "http://www.rheagroup.com/";
            var credentials = new Credentials("John", "Doe", new Uri(this.uri));

            this.mockedDal = new Mock <IDal>();

            this.session = new Session(this.mockedDal.Object, credentials);
            await this.session.Assembler.Synchronize(things);

            this.siteDirectory = this.session.Assembler.RetrieveSiteDirectory();

            this.viewModel = new SessionRowViewModel(this.siteDirectory, this.session, null);
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "files", "LOFT_ECSS-E-TM-10-25_AnnexC.zip");
            var migrationSourceFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\files", "migration.json");

            this.annexC3File   = Path.Combine(TestContext.CurrentContext.TestDirectory, "files", "AnnexC3.zip");
            this.migrationFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "files", "migration.json");

            if (!File.Exists(this.migrationFile))
            {
                File.Copy(migrationSourceFile, this.migrationFile);
            }

            this.cancelationTokenSource = new CancellationTokenSource();
            this.credentials            = new Credentials("admin", "pass", new Uri(path));
            this.session = new Mock <ISession>();

            this.dal = new JsonFileDal
            {
                Session = this.session.Object
            };

            this.siteDirectoryData = new SiteDirectory();
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectoryData);
            this.session.Setup(x => x.Credentials).Returns(this.credentials);
        }
Exemplo n.º 3
0
        public async Task SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            var things        = new List <Thing>();
            var sitedirectory = new CDP4Common.DTO.SiteDirectory(Guid.NewGuid(), 0);

            things.Add(sitedirectory);

            this.uri = "http://www.rheagroup.com/";
            var credentials = new Credentials("John", "Doe", new Uri(this.uri));

            this.mockedDal = new Mock <IDal>();
            this.session   = new Session(this.mockedDal.Object, credentials);
            this.cache     = this.session.Assembler.Cache;
            await this.session.Assembler.Synchronize(things);

            this.siteDirectory = this.session.Assembler.RetrieveSiteDirectory();
            this.siteRdl       = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null)
            {
                IsDeprecated = false, RequiredRdl = null, Name = "SiteRDL"
            };

            this.viewModel = new SiteReferenceDataLibraryRowViewModel(this.siteRdl, this.session, null);
        }
        public void SetUp()
        {
            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(new ServiceLocatorProvider(() => this.serviceLocator.Object));
            this.serviceLocator.Setup(x => x.GetInstance <IMetaDataProvider>()).Returns(new MetaDataProvider());

            var sourcePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\test.xlsx");
            var fileinfo   = new FileInfo(sourcePath);

            var targetPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\temporarytestfile.xlsx");
            var tempfile   = fileinfo.CopyTo(targetPath, true);

            this.testfilepath = tempfile.FullName;

            var siteDirectory = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), null, null);

            var engineeringModelSetup = new CDP4Common.SiteDirectoryData.EngineeringModelSetup(Guid.NewGuid(), null, null)
            {
                Name      = "test model",
                ShortName = "testmodel"
            };

            siteDirectory.Model.Add(engineeringModelSetup);

            var iterationSetup = new CDP4Common.SiteDirectoryData.IterationSetup(Guid.NewGuid(), null, null)
            {
                IterationIid = Guid.NewGuid()
            };

            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            var person = new CDP4Common.SiteDirectoryData.Person(Guid.NewGuid(), null, null)
            {
                GivenName = "test",
                Surname   = "user"
            };

            siteDirectory.Person.Add(person);

            var domainOfExpertise = new CDP4Common.SiteDirectoryData.DomainOfExpertise(Guid.NewGuid(), null, null);

            siteDirectory.Domain.Add(domainOfExpertise);

            this.workbookSession = new WorkbookSession(person, engineeringModelSetup, iterationSetup, domainOfExpertise);
            this.workbookSession.RebuildDateTime = DateTime.Now;
        }
Exemplo n.º 5
0
        public void Verify_that_OperationContainerFileVerification_throws_no_exception_when_data_is_complete()
        {
            var siteDirectory         = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), null, null);
            var engineeringModelSetup = new CDP4Common.SiteDirectoryData.EngineeringModelSetup(Guid.NewGuid(), null, null);
            var iterationSetup        = new CDP4Common.SiteDirectoryData.IterationSetup(Guid.NewGuid(), null, null);

            siteDirectory.Model.Add(engineeringModelSetup);
            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            var engineeringModel = new CDP4Common.EngineeringModelData.EngineeringModel(Guid.NewGuid(), null, null);

            engineeringModel.EngineeringModelSetup = engineeringModelSetup;

            var iteration = new CDP4Common.EngineeringModelData.Iteration(Guid.NewGuid(), null, null);

            iteration.IterationSetup = iterationSetup;

            var commonFileStore = new CDP4Common.EngineeringModelData.CommonFileStore(Guid.NewGuid(), null, null);

            engineeringModel.Iteration.Add(iteration);
            engineeringModel.CommonFileStore.Add(commonFileStore);

            var context     = TransactionContextResolver.ResolveContext(commonFileStore);
            var transaction = new ThingTransaction(context);

            var commonFileStoreClone = commonFileStore.Clone(false);

            var file         = new CDP4Common.EngineeringModelData.File(Guid.NewGuid(), null, null);
            var fileRevision = new CDP4Common.EngineeringModelData.FileRevision(Guid.NewGuid(), null, null);

            fileRevision.ContentHash = "1B686ADFA2CAE870A96E5885087337C032781BE6";

            transaction.Create(file, commonFileStoreClone);
            transaction.Create(fileRevision, file);

            var operationContainer = transaction.FinalizeTransaction();

            var files = new List <string> {
                this.filePath
            };

            var testDal = new TestDal(this.credentials);

            Assert.DoesNotThrow(() => testDal.TestOperationContainerFileVerification(operationContainer, files));
        }
        private void InstantiateThings()
        {
            var siteDirectory = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), null, null);

            var domain1 = new CDP4Common.SiteDirectoryData.DomainOfExpertise(Guid.NewGuid(), null, null);

            siteDirectory.Domain.Add(domain1);
            var domain2 = new CDP4Common.SiteDirectoryData.DomainOfExpertise(Guid.NewGuid(), null, null);

            siteDirectory.Domain.Add(domain2);

            var alias = new CDP4Common.CommonData.Alias(Guid.NewGuid(), null, null);

            domain1.Alias.Add(alias);

            var engineeringModelSetup = new CDP4Common.SiteDirectoryData.EngineeringModelSetup(Guid.NewGuid(), null, null);

            siteDirectory.Model.Add(engineeringModelSetup);
            var iterationSetup = new CDP4Common.SiteDirectoryData.IterationSetup(Guid.NewGuid(), null, null);

            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            var participantRole1 = new CDP4Common.SiteDirectoryData.ParticipantRole(Guid.NewGuid(), null, null);

            siteDirectory.ParticipantRole.Add(participantRole1);
            var participantRole2 = new CDP4Common.SiteDirectoryData.ParticipantRole(Guid.NewGuid(), null, null);

            siteDirectory.ParticipantRole.Add(participantRole2);

            var person1 = new CDP4Common.SiteDirectoryData.Person(Guid.NewGuid(), null, null);

            siteDirectory.Person.Add(person1);

            var personRole1 = new CDP4Common.SiteDirectoryData.PersonRole(Guid.NewGuid(), null, null);

            siteDirectory.PersonRole.Add(personRole1);

            var siteReferenceDataLibrary1 = new CDP4Common.SiteDirectoryData.SiteReferenceDataLibrary(Guid.NewGuid(), null, null);

            siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary1);

            var engineeringModel = new CDP4Common.EngineeringModelData.EngineeringModel(Guid.NewGuid(), null, null);

            engineeringModel.EngineeringModelSetup    = engineeringModelSetup;
            engineeringModelSetup.EngineeringModelIid = engineeringModel.Iid;

            this.iteration = new CDP4Common.EngineeringModelData.Iteration(Guid.NewGuid(), null, null);
            this.iteration.IterationSetup = iterationSetup;
            iterationSetup.IterationIid   = this.iteration.Iid;

            engineeringModel.Iteration.Add(this.iteration);

            var modelReferenceDataLibrary = new CDP4Common.SiteDirectoryData.ModelReferenceDataLibrary(Guid.NewGuid(), null, null);

            modelReferenceDataLibrary.RequiredRdl = siteReferenceDataLibrary1;

            engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);

            var participant = new CDP4Common.SiteDirectoryData.Participant(Guid.NewGuid(), null, null);

            participant.Person = person1;
            participant.Domain.Add(domain1);
            participant.Role = participantRole1;

            engineeringModelSetup.Participant.Add(participant);

            var elementDefinition1 = new CDP4Common.EngineeringModelData.ElementDefinition(Guid.NewGuid(), null, null);

            this.iteration.Element.Add(elementDefinition1);
            var elementDefinition2 = new CDP4Common.EngineeringModelData.ElementDefinition(Guid.NewGuid(), null, null);

            this.iteration.Element.Add(elementDefinition2);

            var elementUsage = new CDP4Common.EngineeringModelData.ElementUsage(Guid.NewGuid(), null, null);

            elementDefinition1.ContainedElement.Add(elementUsage);
            elementUsage.ElementDefinition = elementDefinition2;
        }
Exemplo n.º 7
0
        private void InitSessionThings()
        {
            // Site Directory
            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                   this.session.Object.Credentials.Uri);

            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                this.session.Object.Credentials.Uri)
            {
                Name = "domain"
            };
            this.siteDirectory.Domain.Add(this.domain);

            this.person = new Person(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                     this.session.Object.Credentials.Uri)
            {
                ShortName     = this.credentials.UserName,
                GivenName     = this.credentials.UserName,
                Password      = this.credentials.Password,
                DefaultDomain = this.domain,
                IsActive      = true
            };
            this.siteDirectory.Person.Add(this.person);

            this.participant =
                new Participant(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                this.session.Object.Credentials.Uri)
            {
                Person = this.person
            };
            this.participant.Domain.Add(this.domain);

            // Site Rld
            this.siteReferenceDataLibrary =
                new SiteReferenceDataLibrary(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                             this.session.Object.Credentials.Uri)
            {
                ShortName = "Generic_RDL"
            };
            this.quantityKindParamType = new SimpleQuantityKind(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                                this.session.Object.Credentials.Uri)
            {
                Name      = "m",
                ShortName = "m"
            };
            this.siteReferenceDataLibrary.ParameterType.Add(this.quantityKindParamType);

            // Model Rdl
            this.modelReferenceDataLibrary =
                new ModelReferenceDataLibrary(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                              this.session.Object.Credentials.Uri)
            {
                RequiredRdl = this.siteReferenceDataLibrary
            };
            this.siteDirectory.SiteReferenceDataLibrary.Add(this.siteReferenceDataLibrary);

            // Iteration
            this.iteration = new Iteration(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                           this.session.Object.Credentials.Uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                     this.session.Object.Credentials.Uri)
            {
                IterationIid = this.iteration.Iid
            };

            // Engineering Model & Setup
            this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                         this.session.Object.Credentials.Uri)
            {
                EngineeringModelSetup = this.engineeringModelSetup
            };
            this.engineeringModel.Iteration.Add(this.iteration);

            var ed1    = new ElementDefinition(Guid.NewGuid(), null, null);
            var param1 = new Parameter(Guid.NewGuid(), null, null)
            {
                ParameterType = this.quantityKindParamType
            };

            ed1.Parameter.Add(param1);
            this.iteration.Element.Add(ed1);

            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                                   this.session.Object.Credentials.Uri)
            {
                EngineeringModelIid = this.engineeringModel.Iid
            };
            this.engineeringModelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary);
            this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup);
            this.engineeringModelSetup.Participant.Add(this.participant);
            this.siteDirectory.Model.Add(this.engineeringModelSetup);

            this.sessionThings = new Dictionary <Guid, Thing>
            {
                { this.siteDirectory.Iid, this.siteDirectory.ToDto() },
                { this.domain.Iid, this.domain.ToDto() },
                { this.person.Iid, this.person.ToDto() },
                { this.participant.Iid, this.participant.ToDto() },
                { this.siteReferenceDataLibrary.Iid, this.siteReferenceDataLibrary.ToDto() },
                { this.quantityKindParamType.Iid, this.quantityKindParamType.ToDto() },
                { this.modelReferenceDataLibrary.Iid, this.modelReferenceDataLibrary.ToDto() },
                { this.engineeringModelSetup.Iid, this.engineeringModelSetup.ToDto() },
                { this.iteration.Iid, this.iteration.ToDto() },
                { this.iterationSetup.Iid, this.iterationSetup.ToDto() },
                { this.engineeringModel.Iid, this.engineeringModel.ToDto() }
            };

            this.session = new Mock <ISession>();
            this.session.Setup(s => s.Assembler).Returns(this.assembler);
            this.session.Setup(s => s.Credentials).Returns(this.credentials);
            this.session.Setup(s => s.ActivePerson).Returns(this.person);
            this.session.Setup(s => s.RetrieveSiteDirectory()).Returns(this.siteDirectory);

            this.session.Setup(x => x.Write(It.IsAny <OperationContainer>(), It.IsAny <IEnumerable <string> >()))
            .Returns <OperationContainer, IEnumerable <string> >((operationContainer, files) =>
            {
                foreach (var operation in operationContainer.Operations)
                {
                    var operationThing = operation.ModifiedThing;

                    switch (operation.OperationKind)
                    {
                    case OperationKind.Create:
                        if (!this.generatedThings.ContainsKey(operationThing.Iid))
                        {
                            this.generatedThings[operationThing.Iid] = operationThing;
                        }

                        break;

                    case OperationKind.Update:
                        if (!this.modifiedThings.ContainsKey(operationThing.Iid))
                        {
                            this.modifiedThings[operationThing.Iid] = operationThing;
                        }

                        break;
                    }
                }

                return(Task.FromResult((IEnumerable <Thing>) new List <Thing>()));
            });
        }