コード例 #1
0
        public async Task VerifyThatReadReturnsCorrectDTO()
        {
            this.dal = new WspDal();

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

            Assert.NotNull(returned);
            Assert.IsNotEmpty(returned);

            var sd = returned.First();

            var attributes = new QueryAttributes();
            var readResult = await dal.Read(sd, this.cancelationTokenSource.Token, attributes);

            // General assertions for any kind of Thing we read
            Assert.NotNull(readResult);
            Assert.IsTrue(readResult.Count() == 1);
            var sd1 = readResult.Single();

            Assert.IsTrue(sd.ClassKind == sd1.ClassKind);
            Assert.IsTrue(sd.Iid == sd1.Iid);
            Assert.IsTrue(sd.Route == sd1.Route);

            // Specific assertions for Sitedirectory ClassKind
            var castedSd  = sd as CDP4Common.DTO.SiteDirectory;
            var castedSd1 = sd as CDP4Common.DTO.SiteDirectory;

            Assert.NotNull(castedSd);
            Assert.NotNull(castedSd1);
            Assert.IsTrue(castedSd.Name == castedSd1.Name);
            Assert.IsTrue(castedSd.Domain.Count == castedSd1.Domain.Count);
            Assert.IsTrue(castedSd.SiteReferenceDataLibrary == castedSd1.SiteReferenceDataLibrary);
            Assert.IsTrue(castedSd.Model == castedSd1.Model);
        }
コード例 #2
0
        public async Task VerifyThatReadIterationWorks()
        {
            var dal = new WspDal {
                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 VerifyThatIfCredentialsAreNullOnReadExceptionIsThrown()
        {
            var organizationIid = Guid.Parse("44d1ff16-8195-47d0-abfa-163bbba9bf39");
            var organizationDto = new CDP4Common.DTO.Organization(organizationIid, 0);

            organizationDto.AddContainer(ClassKind.SiteDirectory, Guid.Parse("eb77f3e1-a0f3-412d-8ed6-b8ce881c0145"));

            var dal = new WspDal();

            Assert.That(async() => await dal.Read(organizationDto, new CancellationToken()), Throws.TypeOf <InvalidOperationException>());
        }