コード例 #1
0
        public async Task Verify_that_person_can_be_Posted()
        {
            var cdpServicesDal = new CdpServicesDal();
            var dtos           = await cdpServicesDal.Open(this.credentials, this.cancelationTokenSource.Token);

            var siteDirectory = (CDP4Common.DTO.SiteDirectory)dtos.Single(x => x.ClassKind == ClassKind.SiteDirectory);

            var context            = siteDirectory.Route;
            var operationContainer = new OperationContainer(context, siteDirectory.RevisionNumber);

            var person = new CDP4Common.DTO.Person(Guid.NewGuid(), 1);

            person.ShortName = Guid.NewGuid().ToString();
            person.Surname   = Guid.NewGuid().ToString();
            person.GivenName = Guid.NewGuid().ToString();
            person.AddContainer(ClassKind.SiteDirectory, siteDirectory.Iid);

            var operation1 = new Operation(null, person, OperationKind.Create);

            operationContainer.AddOperation(operation1);

            var siteDirectoryClone = siteDirectory.DeepClone <CDP4Common.DTO.SiteDirectory>();

            siteDirectoryClone.Person.Add(person.Iid);
            var operation2 = new Operation(siteDirectory, siteDirectoryClone, OperationKind.Update);

            operationContainer.AddOperation(operation2);

            var result = await cdpServicesDal.Write(operationContainer);

            var resultPerson = (CDP4Common.DTO.Person)result.Single(x => x.Iid == person.Iid);

            Assert.NotNull(resultPerson);
        }
コード例 #2
0
        public async Task VerifyThatReadIterationWorks()
        {
            var dal = new CdpServicesDal {
                Session = this.session
            };
            var credentials = new Credentials("admin", "pass", new Uri("https://cdp4services-public.cdp4.org"));
            var session     = new Session(dal, credentials);

            var returned = await dal.Open(credentials, this.cancelationTokenSource.Token);

            await session.Assembler.Synchronize(returned);

            var siteDir        = session.Assembler.RetrieveSiteDirectory();
            var modelSetup     = siteDir.Model.Single(x => x.ShortName == "LOFT");
            var iterationSetup = modelSetup.IterationSetup.First();

            var openCount = session.Assembler.Cache.Count;

            var model     = new EngineeringModel(modelSetup.EngineeringModelIid, null, null);
            var iteration = new Iteration(iterationSetup.IterationIid, null, null);

            iteration.Container = model;

            var modelDtos = await dal.Read((CDP4Common.DTO.Iteration) iteration.ToDto(), this.cancelationTokenSource.Token);

            await session.Assembler.Synchronize(modelDtos);

            var readCount = session.Assembler.Cache.Count;

            Assert.IsTrue(readCount > openCount);
        }
コード例 #3
0
        public async Task VerifyThatIfNotHttpOrHttpsExceptionIsThrown()
        {
            var uri = new Uri("https://cdp4services-test.cdp4.org");
            var invalidCredentials = new Credentials("John", "a password", uri);

            Assert.That(async() => await dal.Open(invalidCredentials, new CancellationToken()), Throws.TypeOf <DalReadException>());
        }
コード例 #4
0
        public async Task VerifThatAClosedDalCannotBeClosedAgain()
        {
            var dal = new CdpServicesDal();
            await dal.Open(this.credentials, new CancellationToken());

            dal.Close();

            Assert.Throws <InvalidOperationException>(() => dal.Close());
        }
コード例 #5
0
        public async Task Verify_that_opens_returns_expected_result()
        {
            var uri = new Uri("https://cdp4services-test.cdp4.org");

            this.credentials = new Credentials("admin", "pass", uri);

            var dal    = new CdpServicesDal();
            var result = await dal.Open(this.credentials, new CancellationToken());

            Assert.NotNull(result);
        }
コード例 #6
0
        public async Task VerifyThatOpenReturnsDTOs()
        {
            var uriBuilder = new UriBuilder(this.credentials.Uri)
            {
                Path = "/Data/Restore"
            };
            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes($"{credentials.UserName}:{credentials.Password}")));
            await httpClient.PostAsync(uriBuilder.Uri, null);

            var dal    = new CdpServicesDal();
            var result = await dal.Open(this.credentials, new CancellationToken());

            var amountOfDtos = result.ToList().Count;

            Assert.AreEqual(86, amountOfDtos);
        }
コード例 #7
0
        public async Task Verify_that_multiple_read_requests_can_be_made_in_parallel()
        {
            var uri         = new Uri("https://cdp4services-test.cdp4.org");
            var credentials = new Credentials("admin", "pass", uri);
            var assembler   = new Assembler(this.uri);

            var dal     = new CdpServicesDal();
            var session = new Session(dal, credentials);

            var result = await dal.Open(credentials, new CancellationToken());

            var siteDirectory = result.OfType <CDP4Common.DTO.SiteDirectory>().Single();

            var queryAttributes = new QueryAttributes {
                Extent = ExtentQueryAttribute.deep
            };

            for (int i = 0; i < 9; i++)
            {
                dal.Read(siteDirectory, new CancellationToken(), queryAttributes);
            }

            var readresult = await dal.Read(siteDirectory, new CancellationToken());
        }
コード例 #8
0
        public async Task VerifyThatIfCredentialsAreNullExceptionIsThrown()
        {
            var dal = new CdpServicesDal();

            Assert.That(async() => await dal.Open(null, new CancellationToken()), Throws.TypeOf <ArgumentNullException>());
        }