示例#1
0
        public void WhenAskingForInvalidOrgNumber_ThrowNotFound()
        {
            var organizationNumber = 971998011;

            var controller = new BrregControllerBuilder()
                             .AddExpectedHttpResponse($"underenheter/{organizationNumber}", "", HttpStatusCode.NotFound)
                             .AddExpectedHttpResponse($"enheter/{organizationNumber}", "", HttpStatusCode.NotFound)
                             .Build();

            var ex = Assert.ThrowsAsync <shared.NotFoundException>(async() => await controller.GetBrregEntity(organizationNumber, true));

            Assert.AreEqual("Organisasjonen ble ikke funnet", ex.Message);
        }
示例#2
0
        public async Task WhenAskingForParentWithNoChildren_ParentOrgIsReturned()
        {
            var organizationNumber = 934228391;

            var controller = new BrregControllerBuilder()
                             .AddExpectedHttpResponse($"enheter/{organizationNumber}", SticosEntityJson, HttpStatusCode.OK)
                             .Build();

            var ret = await controller.GetBrregEntity(organizationNumber, false);

            Assert.AreEqual(organizationNumber, ret.Value.OrganizationNumber);
            Assert.AreEqual("STICOS AS", ret.Value.Name);
            Assert.AreEqual(Contracts.BrregEntityType.Parent, ret.Value.Type);
            Assert.AreEqual(0, ret.Value.Children.Count);
        }
示例#3
0
        public async Task WhenAskingForChild_ChildLookupIsCalled()
        {
            var organizationNumber = 971998016;

            var controller = new BrregControllerBuilder()
                             .AddExpectedHttpResponse($"underenheter/{organizationNumber}", SticosChildentityJson, HttpStatusCode.OK)
                             .AddExpectedHttpResponse($"enheter/{organizationNumber}", "", HttpStatusCode.NotFound)
                             .Build();

            var ret = await controller.GetBrregEntity(organizationNumber, true);

            Assert.AreEqual(organizationNumber, ret.Value.OrganizationNumber);
            Assert.AreEqual("STICOS AS", ret.Value.Name);
            Assert.AreEqual(Contracts.BrregEntityType.Child, ret.Value.Type);
            Assert.AreEqual(0, ret.Value.Children.Count);
        }
示例#4
0
        public async Task WhenAskingForParentWithChildren_ParentOrgHasChildren()
        {
            var organizationNumber = 934228391;

            var controller = new BrregControllerBuilder()
                             .AddExpectedHttpResponse($"enheter/{organizationNumber}", SticosEntityJson, HttpStatusCode.OK)
                             .AddExpectedHttpResponse($"underenheter?overordnetEnhet={organizationNumber}&page={0}", SticosEntityWithChildentities, HttpStatusCode.OK)
                             .Build();

            var ret = await controller.GetBrregEntity(organizationNumber, true);

            Assert.AreEqual(organizationNumber, ret.Value.OrganizationNumber);
            Assert.AreEqual("STICOS AS", ret.Value.Name);
            Assert.AreEqual(Contracts.BrregEntityType.Parent, ret.Value.Type);
            Assert.AreEqual(1, ret.Value.Children.Count);
        }