Ejemplo n.º 1
0
        private static async Task InsertCapabilityAsync(CapabilityTable capabilityTable)
        {
            var capability = CapabilityEntityBuilder.Create()
                             .WithName(capabilityTable.CapabilityName)
                             .WithCapabilityRef(capabilityTable.CapabilityRef)
                             .WithVersion(capabilityTable.Version)
                             .WithDescription(capabilityTable.Description)
                             .WithSourceUrl(capabilityTable.SourceUrl)
                             .WithCategoryId(capabilityTable.CategoryId)
                             .Build();
            await capability.InsertAsync();

            await FrameworkCapabilitiesEntityBuilder.Create()
            .WithCapabilityId(capability.Id)
            .WithIsFoundation(capabilityTable.IsFoundation)
            .Build()
            .InsertAsync();
        }
        public async Task ShouldReadGPITFuturesCapabilitiesWithFrameworksCorrectlyOrderedByName()
        {
            var capabilityEntities = new List <CapabilityEntity>
            {
                CapabilityEntityBuilder.Create().WithName("Bravo").WithCategoryId(1).Build(),
                CapabilityEntityBuilder.Create().WithName("Alpha").WithCategoryId(1).Build(),
                CapabilityEntityBuilder.Create().WithName("Delta").WithCategoryId(1).Build(),
                CapabilityEntityBuilder.Create().WithName("Charlie").WithCategoryId(1).Build(),
            };

            foreach (var capabilityEntity in capabilityEntities)
            {
                await capabilityEntity.InsertAsync();
            }

            foreach (var entity in new List <CapabilityEntity>
            {
                CapabilityEntityBuilder.Create().WithName("Echo").WithCategoryId(3).Build(),
                CapabilityEntityBuilder.Create().WithName("FoxTrot").WithCategoryId(0).Build(),
                CapabilityEntityBuilder.Create().WithName("Golf").WithCategoryId(2).Build(),
            })
            {
                await entity.InsertAsync();
            }

            await FrameworkCapabilitiesEntityBuilder.Create()
            .WithCapabilityId(capabilityEntities.First(c => c.Name == "Charlie").Id)
            .WithIsFoundation(true)
            .Build()
            .InsertAsync();

            await FrameworkCapabilitiesEntityBuilder.Create()
            .WithCapabilityId(capabilityEntities.First(c => c.Name == "Delta").Id)
            .WithIsFoundation(true)
            .Build()
            .InsertAsync();

            var capabilities = (await capabilityRepository.ListAsync(CancellationToken.None)).ToList();

            Assert.That(capabilities[0].Name, Is.EqualTo("Alpha"));
            Assert.That(capabilities[1].Name, Is.EqualTo("Bravo"));
            Assert.That(capabilities[2].Name, Is.EqualTo("Charlie"));
            Assert.That(capabilities[3].Name, Is.EqualTo("Delta"));
        }
        public async Task ShouldReadCapabilitiesNoFrameworks()
        {
            var capabilityEntities = new List <CapabilityEntity>
            {
                CapabilityEntityBuilder.Create().WithName("Cap1").Build(),
                CapabilityEntityBuilder.Create().WithName("Cap2").Build()
            };

            foreach (var capabilityEntity in capabilityEntities)
            {
                await capabilityEntity.InsertAsync().ConfigureAwait(false);
            }

            var capabilities = await _capabilityRepository.ListAsync(new CancellationToken()).ConfigureAwait(false);

            capabilities.Should().BeEquivalentTo(capabilityEntities.Select(ce => new
            {
                ce.Id, ce.Name, IsFoundation = false
            }));
        }
        public async Task ShouldReadCapabilitiesWithFrameworks()
        {
            var capabilityEntities = new List <CapabilityEntity>
            {
                CapabilityEntityBuilder.Create().WithName("Cap1").WithCategoryId(1).Build(),
                CapabilityEntityBuilder.Create().WithName("Cap2").WithCategoryId(1).Build(),
                CapabilityEntityBuilder.Create().WithName("Cap3").WithCategoryId(1).Build(),
            };

            foreach (var capabilityEntity in capabilityEntities)
            {
                await capabilityEntity.InsertAsync();
            }

            await FrameworkCapabilitiesEntityBuilder.Create()
            .WithCapabilityId(capabilityEntities.First(c => c.Name == "Cap1").Id)
            .WithIsFoundation(false)
            .Build()
            .InsertAsync();

            await FrameworkCapabilitiesEntityBuilder.Create()
            .WithCapabilityId(capabilityEntities.First(c => c.Name == "Cap2").Id)
            .WithIsFoundation(true)
            .Build()
            .InsertAsync();

            var capabilities = await capabilityRepository.ListAsync(CancellationToken.None);

            capabilities.Should().BeEquivalentTo(capabilityEntities.Select(ce => new
            {
                CapabilityReference = ce.CapabilityRef,
                ce.Version,
                ce.Name,
                IsFoundation = ce.Name == "Cap2",
            }));
        }
Ejemplo n.º 5
0
        public async Task Setup()
        {
            await Database.ClearAsync().ConfigureAwait(false);

            await OrganisationEntityBuilder.Create()
            .WithName(_orgName)
            .WithId(_org1Id)
            .Build()
            .InsertAsync().ConfigureAwait(false);

            await SupplierEntityBuilder.Create()
            .WithId(_supplierId)
            .WithOrganisation(_org1Id)
            .Build()
            .InsertAsync().ConfigureAwait(false);

            await CapabilityEntityBuilder.Create().WithName("Cap1").WithId(_cap1Id).WithDescription("Cap1Desc").Build().InsertAsync().ConfigureAwait(false);

            await CapabilityEntityBuilder.Create().WithName("Cap2").WithId(_cap2Id).WithDescription("Cap2Desc").Build().InsertAsync().ConfigureAwait(false);

            TestContext testContext = new TestContext();

            _solutionListRepository = testContext.SolutionListRepository;
        }
Ejemplo n.º 6
0
        public async Task ShouldHaveMultipleCapabilities()
        {
            const string cap1Name = "Cap1";
            const string cap1Desc = "Desc1";

            const string cap2Name = "Cap2";
            const string cap2Desc = "Desc2";

            const string cap3Name = "Cap3";
            const string cap3Desc = "Desc3";

            await CapabilityEntityBuilder.Create()
            .WithId(_cap1Id)
            .WithName(cap1Name)
            .WithDescription(cap1Desc)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await CapabilityEntityBuilder.Create()
            .WithId(_cap2Id)
            .WithName(cap2Name)
            .WithDescription(cap2Desc)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await CapabilityEntityBuilder.Create()
            .WithId(_cap3Id)
            .WithName(cap3Name)
            .WithDescription(cap3Desc)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await SolutionCapabilityEntityBuilder.Create()
            .WithCapabilityId(_cap1Id)
            .WithSolutionId(Solution1Id)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await SolutionCapabilityEntityBuilder.Create()
            .WithCapabilityId(_cap2Id)
            .WithSolutionId(Solution1Id)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await SolutionCapabilityEntityBuilder.Create()
            .WithCapabilityId(_cap3Id)
            .WithSolutionId(Solution1Id)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            var solutionCapabilityResponse =
                await _solutionCapabilityRepository.ListSolutionCapabilities(Solution1Id, CancellationToken.None)
                .ConfigureAwait(false);

            solutionCapabilityResponse.Count().Should().Be(3);
        }
Ejemplo n.º 7
0
        public async Task HasMultipleSolutions()
        {
            const string cap1Name = "Cap1";
            const string cap1Desc = "Desc1";

            const string cap2Name = "Cap2";
            const string cap2Desc = "Desc2";

            await SolutionEntityBuilder.Create()
            .WithId(Solution2Id)
            .WithOrganisationId(_org1Id)
            .WithSupplierId(SupplierId)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await CapabilityEntityBuilder.Create()
            .WithId(_cap1Id)
            .WithName(cap1Name)
            .WithDescription(cap1Desc)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await CapabilityEntityBuilder.Create()
            .WithId(_cap2Id)
            .WithName(cap2Name)
            .WithDescription(cap2Desc)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await SolutionCapabilityEntityBuilder.Create()
            .WithCapabilityId(_cap1Id)
            .WithSolutionId(Solution1Id)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            await SolutionCapabilityEntityBuilder.Create()
            .WithCapabilityId(_cap2Id)
            .WithSolutionId(Solution2Id)
            .Build()
            .InsertAsync()
            .ConfigureAwait(false);

            var solutionCapabilityResponseSolution1 =
                await _solutionCapabilityRepository.ListSolutionCapabilities(Solution1Id, CancellationToken.None)
                .ConfigureAwait(false);

            var solutionCapabilityResponseSolution2 =
                await _solutionCapabilityRepository.ListSolutionCapabilities(Solution2Id, CancellationToken.None)
                .ConfigureAwait(false);


            var solutionCapability1 = solutionCapabilityResponseSolution1.Should().ContainSingle().Subject;

            solutionCapability1.CapabilityId.Should().Be(_cap1Id);
            solutionCapability1.CapabilityName.Should().Be(cap1Name);
            solutionCapability1.CapabilityDescription.Should().Be(cap1Desc);

            var solutionCapability2 = solutionCapabilityResponseSolution2.Should().ContainSingle().Subject;

            solutionCapability2.CapabilityId.Should().Be(_cap2Id);
            solutionCapability2.CapabilityName.Should().Be(cap2Name);
            solutionCapability2.CapabilityDescription.Should().Be(cap2Desc);
        }