Ejemplo n.º 1
0
        public async Task GetExternalDataWithoutWorkRelation()
        {
            var entityType       = (int)ExternalDataEnum.Employee;
            var externalSystemId = 2;
            var unit             = ExternalSystemSetup.ValidSticosUnit;

            var client = new ExternalSystemSetup()
                         .WithSticosUnit(unit)
                         .WithExternalEmployees(unit.BusinessOrganizationNumber, new List <Employee> {
                ExternalSystemSetup.ValidEmployee1
            })
                         .WithExternalEmployments(new List <Employment> {
                ExternalSystemSetup.ValidEmployment1
            })
                         .WithExternalWorkers(new List <Worker> {
                ExternalSystemSetup.ValidWorker1
            })
                         //.WithExternalWorkerRelations(new List<WorkRelation> { ExternalSystemSetup.ValidWorkRelation1 })
                         .BuildClient();

            var url = GetUrl(externalSystemId, entityType, unit.Id);
            var externalDataResult = await client.GetAsyncAndDeserialize <IList <ExternalData> >(url);

            Assert.AreEqual("WorkRelation is not found", externalDataResult[0].NotValidReasons[0]);
            Assert.NotNull(externalDataResult);
        }
Ejemplo n.º 2
0
        public async Task WhenQueryExternalDataAndAllDataIsValid_ThenItShouldBeReturnedWithIdentifiers()
        {
            var entityType       = (int)ExternalDataEnum.Employee;
            var externalSystemId = 2;
            var unit             = ExternalSystemSetup.ValidSticosUnit;

            var client = new ExternalSystemSetup()
                         .WithSticosUnit(unit)
                         .WithExternalEmployees(unit.BusinessOrganizationNumber, new List <Employee> {
                ExternalSystemSetup.ValidEmployee1
            })
                         .WithExternalEmployments(new List <Employment> {
                ExternalSystemSetup.ValidEmployment1
            })
                         .WithExternalWorkers(new List <Worker> {
                ExternalSystemSetup.ValidWorker1
            })
                         .WithExternalWorkerRelations(new List <WorkRelation> {
                ExternalSystemSetup.ValidWorkRelation1
            })
                         .BuildClient();

            var url = GetUrl(externalSystemId, entityType, unit.Id);
            var externalDataResult = await client.GetAsyncAndDeserialize <IList <ExternalData> >(url);

            Assert.NotNull(externalDataResult);
            Assert.AreEqual(1, externalDataResult.Count);
            Assert.AreEqual(4, externalDataResult[0].Identifiers.Count);
        }
Ejemplo n.º 3
0
        public async Task WhenQueryingExternalDataWithMissingCustomerId_ThenNotFoundShouldBeReturned()
        {
            var client        = new ExternalSystemSetup().BuildClient();
            var exportAbsence = await client.GetAsync($"/externaldata");

            Assert.NotNull(exportAbsence);
            Assert.AreEqual(HttpStatusCode.NotFound, exportAbsence.StatusCode);
        }
Ejemplo n.º 4
0
        public async Task WhenQueryingExternalDataIncorrectUrl_ThenNotFoundShouldBeReturned()
        {
            var externalSystemId   = 2;
            var client             = new ExternalSystemSetup().BuildClient();
            var externalDataResult = await client.GetAsync($"{externalSystemId}/externaldata");

            Assert.NotNull(externalDataResult);
            Assert.AreEqual(HttpStatusCode.NotFound, externalDataResult.StatusCode);
        }
Ejemplo n.º 5
0
        public async Task WhenGettingAnExistingExternalystem_AllPropertiesShouldBeMapped()
        {
            var economySystemIdThatDoesNotExist = 999999;

            var client          = new ExternalSystemSetup().BuildClient();
            var externalSystems = await client.GetAsyncAndDeserialize <Timereg.Api.Contracts.ExternalSystem>($"{ExternalSystemSetup.CustomerId}/externalsystems/{economySystemIdThatDoesNotExist}");

            Assert.IsNull(externalSystems);
        }
Ejemplo n.º 6
0
        public async Task WhenAnExistingGettingExternalystem_ThenResponseShouldNotBeNull()
        {
            var economySystemId = 2; //unimicro

            var client          = new ExternalSystemSetup().BuildClient();
            var externalSystems = await client.GetAsyncAndDeserialize <Timereg.Api.Contracts.ExternalSystem>($"{ExternalSystemSetup.CustomerId}/externalsystems/{economySystemId}");

            Assert.NotNull(externalSystems);
        }
Ejemplo n.º 7
0
        public async Task WhenQueryExternalDataWithUnknownCustomerId_ThenForbiddenShouldBeReturned()
        {
            var unknownCustomerId = 1234567;
            var client            = new ExternalSystemSetup().BuildClient();
            var exportAbsence     = await client.GetAsync($"{unknownCustomerId}/externalsystems/1/externaldata");

            Assert.NotNull(exportAbsence);
            Assert.AreEqual(HttpStatusCode.Forbidden, exportAbsence.StatusCode);
        }
Ejemplo n.º 8
0
        public async Task WhenQueryExternalDataAndNoDataExist_ThenEmptyListShouldBeReturned()
        {
            var externalSystemId = 2;
            var entityType       = (int)ExternalDataEnum.Employee;
            var unit             = ExternalSystemSetup.ValidSticosUnit;
            var url    = GetUrl(externalSystemId, entityType, unit.Id);
            var client = new ExternalSystemSetup().BuildClient();

            var externalDataResult = await client.GetAsyncAndDeserialize <IList <ExternalData> >(url);

            Assert.AreEqual(0, externalDataResult.Count);
        }