Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }