public async void DepecateSpanStructureSpecificationTest()
        {
            // Setup
            var spec1 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø12", "Blue")
            {
                OuterDiameter = 12,
                InnerDiameter = 10
            };

            var spec2 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø50", "Orange")
            {
                OuterDiameter = 50,
                InnerDiameter = 45
            };

            // Act
            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(spec1));

            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(spec2));

            await _commandDispatcher.HandleAsync <DeprecateSpanStructureSpecification, Result>(new DeprecateSpanStructureSpecification(spec2.Id));

            var spanStructureSpecificationsQueryResult = await _queryDispatcher.HandleAsync <GetSpanStructureSpecifications, Result <LookupCollection <SpanStructureSpecification> > >(new GetSpanStructureSpecifications());

            // Assert
            spanStructureSpecificationsQueryResult.IsSuccess.Should().BeTrue();
            spanStructureSpecificationsQueryResult.Value[spec1.Id].Deprecated.Should().BeFalse();
            spanStructureSpecificationsQueryResult.Value[spec2.Id].Deprecated.Should().BeTrue();
        }
Exemple #2
0
        public async void AddInvalidSpanEquipmentSpecificationWithRootTemplateLevelDifferentFromOne_ShouldFail()
        {
            // Setup some span structure specifications to be used in the span equipment specification
            var outerConduitSpanStructureSpec1 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø50", "Orange")
            {
                OuterDiameter = 50,
                InnerDiameter = 45
            };
            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(outerConduitSpanStructureSpec1));


            // Setup a span equipment specification with level 0 in root span template.
            // Must fail, because we want the root template to always have level 1
            var spanEquipmentSpecification = new SpanEquipmentSpecification(Guid.NewGuid(), "Conduit", "Ø50 2x12",
                                                                            new SpanStructureTemplate(outerConduitSpanStructureSpec1.Id, 0, 1,
                                                                                                      new SpanStructureTemplate[] {
            }
                                                                                                      ));

            // Act
            var addSpanEquipmentSpecificationCommandResult = await _commandDispatcher.HandleAsync <AddSpanEquipmentSpecification, Result>(new AddSpanEquipmentSpecification(spanEquipmentSpecification));

            // Assert
            addSpanEquipmentSpecificationCommandResult.IsFailed.Should().BeTrue();
        }
        public async void AddSpanStructureSpecificationTest()
        {
            // Setup
            var spec1 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø12", "Red")
            {
                OuterDiameter = 12,
                InnerDiameter = 10
            };

            var spec2 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø50", "Red")
            {
                OuterDiameter = 50,
                InnerDiameter = 45
            };

            // Act
            var    cmd1       = new AddSpanStructureSpecification(spec1);
            Result cmd1Result = await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(cmd1);

            var    cmd2       = new AddSpanStructureSpecification(spec2);
            Result cmd2Result = await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(cmd2);

            var spanStructureSpecificationsQueryResult = await _queryDispatcher.HandleAsync <GetSpanStructureSpecifications, Result <LookupCollection <SpanStructureSpecification> > >(new GetSpanStructureSpecifications());

            // Assert
            cmd1Result.IsSuccess.Should().BeTrue();
            cmd2Result.IsSuccess.Should().BeTrue();

            spanStructureSpecificationsQueryResult.IsSuccess.Should().BeTrue();
            spanStructureSpecificationsQueryResult.Value[spec1.Id].Should().BeEquivalentTo(spec1);
            spanStructureSpecificationsQueryResult.Value[spec2.Id].Should().BeEquivalentTo(spec2);
        }
Exemple #4
0
        public async void AddInvalidSpanEquipmentSpecificationWithNonUniqueLevelAndPosition_ShouldFail()
        {
            // Setup some span structure specifications to be used in the span equipment specification
            var outerConduitSpanStructureSpec1 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø50", "Orange")
            {
                OuterDiameter = 50,
                InnerDiameter = 45
            };
            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(outerConduitSpanStructureSpec1));

            // Add span equipment specification with two child template having same level and position
            var spanEquipmentSpecification = new SpanEquipmentSpecification(Guid.NewGuid(), "Conduit", "Ø50 2x12",
                                                                            new SpanStructureTemplate(outerConduitSpanStructureSpec1.Id, 1, 1,
                                                                                                      new SpanStructureTemplate[] {
                new SpanStructureTemplate(outerConduitSpanStructureSpec1.Id, 2, 1, Array.Empty <SpanStructureTemplate>()),
                new SpanStructureTemplate(outerConduitSpanStructureSpec1.Id, 2, 1, Array.Empty <SpanStructureTemplate>())
            }
                                                                                                      ));

            // Act
            var addSpanEquipmentSpecificationCommandResult = await _commandDispatcher.HandleAsync <AddSpanEquipmentSpecification, Result>(new AddSpanEquipmentSpecification(spanEquipmentSpecification));

            // Assert
            addSpanEquipmentSpecificationCommandResult.IsFailed.Should().BeTrue();
        }
        private async Task AddSpecification(SpanStructureSpecification spec)
        {
            var cmd       = new AddSpanStructureSpecification(Guid.NewGuid(), new UserContext("test", Guid.Empty), spec);
            var cmdResult = await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(cmd);

            if (cmdResult.IsFailed)
            {
                throw new ApplicationException(cmdResult.Errors.First().Message);
            }
        }
        private async void AddSpecification(SpanStructureSpecification spec)
        {
            var cmd       = new AddSpanStructureSpecification(spec);
            var cmdResult = await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(cmd);

            if (cmdResult.IsFailed)
            {
                throw new ApplicationException(cmdResult.Errors.First().Message);
            }
        }
Exemple #7
0
        public async void AddValidMultiLevelSpanEquipmentSpecification_ShouldSucceed()
        {
            // Create manufacturer
            var manufacturer = new Manufacturer(Guid.NewGuid(), "Super Manufacturer");
            await _commandDispatcher.HandleAsync <AddManufacturer, Result>(new AddManufacturer(manufacturer));


            // Setup some span structure specifications to be used in the span equipment specification
            var outerConduitSpanStructureSpec1 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø50", "Orange")
            {
                OuterDiameter = 50,
                InnerDiameter = 45
            };
            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(outerConduitSpanStructureSpec1));

            var innerConduitSpanStructureSpec1 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø12/10", "Red")
            {
                OuterDiameter = 12,
                InnerDiameter = 10
            };
            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(innerConduitSpanStructureSpec1));

            var innerConduitSpanStructureSpec2 = new SpanStructureSpecification(Guid.NewGuid(), "Conduit", "Ø12/10", "Blue")
            {
                OuterDiameter = 12,
                InnerDiameter = 10
            };
            await _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(new AddSpanStructureSpecification(innerConduitSpanStructureSpec2));


            // Setup a span equipment specification with 2 levels
            var spanEquipmentSpecification = new SpanEquipmentSpecification(Guid.NewGuid(), "Conduit", "Ø50 2x12",
                                                                            new SpanStructureTemplate(outerConduitSpanStructureSpec1.Id, 1, 1,
                                                                                                      new SpanStructureTemplate[] {
                new SpanStructureTemplate(innerConduitSpanStructureSpec1.Id, 2, 1, Array.Empty <SpanStructureTemplate>()),
                new SpanStructureTemplate(innerConduitSpanStructureSpec2.Id, 2, 2, Array.Empty <SpanStructureTemplate>())
            }
                                                                                                      )
                                                                            )
            {
                Description      = "Ø50 2x12/10",
                ManufacturerRefs = new Guid[] { manufacturer.Id }
            };

            // Act
            var addSpanEquipmentSpecificationCommandResult = await _commandDispatcher.HandleAsync <AddSpanEquipmentSpecification, Result>(new AddSpanEquipmentSpecification(spanEquipmentSpecification));

            var spanEqipmentSpecificationsQueryResult = await _queryDispatcher.HandleAsync <GetSpanEquipmentSpecifications, Result <LookupCollection <SpanEquipmentSpecification> > >(new GetSpanEquipmentSpecifications());


            // Assert
            addSpanEquipmentSpecificationCommandResult.IsSuccess.Should().BeTrue();
            spanEqipmentSpecificationsQueryResult.IsSuccess.Should().BeTrue();
        }
Exemple #8
0
        private void AddSpecification(SpanStructureSpecification spec)
        {
            var cmd = new AddSpanStructureSpecification(Guid.NewGuid(), new UserContext("specification seeder", _specSeederId), spec);

            var cmdResult = _commandDispatcher.HandleAsync <AddSpanStructureSpecification, Result>(cmd).Result;

            if (cmdResult.IsFailed)
            {
                throw new ApplicationException(cmdResult.Errors.First().Message);
            }
        }