Exemplo n.º 1
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);
        }
        public async Task Verify_that_person_can_be_Posted()
        {
            var wspdal = new WspDal();
            var dtos   = await wspdal.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 wspdal.Write(operationContainer);

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

            Assert.NotNull(resultPerson);
        }
Exemplo n.º 3
0
        public async Task VerifyThatIfNotHttpOrHttpsExceptionIsThrown()
        {
            var uri = new Uri("file://somefile");
            var invalidCredentials = new Credentials("John", "a password", uri);

            var dal = new WspDal();

            Assert.That(async() => await dal.Open(invalidCredentials, new CancellationToken()), Throws.TypeOf <ArgumentException>());
        }
Exemplo n.º 4
0
        public async Task VerifThatAClosedDalCannotBeClosedAgain()
        {
            var dal = new WspDal();
            await dal.Open(this.credentials, new CancellationToken());

            dal.Close();

            Assert.Throws <InvalidOperationException>(() => dal.Close());
        }
Exemplo n.º 5
0
        public async Task Verify_that_opens_returns_expected_result()
        {
            var uri = new Uri("http://ocdt-dev.rheagroup.com");

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

            var wspdal = new WspDal();
            var result = await wspdal.Open(this.credentials, new CancellationToken());

            Assert.NotNull(result);
        }
Exemplo n.º 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 WspDal();
            var result = await dal.Open(this.credentials, new CancellationToken());

            var amountOfDtos = result.ToList().Count;

            Assert.AreEqual(60, amountOfDtos);
        }
Exemplo n.º 7
0
        public async Task Verify_that_person_can_be_Posted()
        {
            var uri         = new Uri("http://ocdt-dev.rheagroup.com");
            var credentials = new Credentials("admin", "pass", uri);

            var wspdal = new WspDal();
            var dtos   = await wspdal.Open(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, Guid.Parse("eb77f3e1-a0f3-412d-8ed6-b8ce881c0145"));

            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 wspdal.Write(operationContainer);

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

            Assert.NotNull(resultPerson);
        }
Exemplo n.º 8
0
        public async Task VerifyThatIfCredentialsAreNullExceptionIsThrown()
        {
            var dal = new WspDal();

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