Пример #1
0
        public void CreateStructures_WhenSpecificIdGeneratorIsPassed_SpecificIdGeneratorIsConsumed()
        {
            var items = new[] { new GuidItem {
                                    Value = 42
                                }, new GuidItem {
                                    Value = 43
                                } };
            var schema      = StructureSchemaTestFactory.CreateRealFrom <GuidItem>();
            var idGenerator = new GuidStructureIdGeneratorProxy();

            Builder.StructureIdGenerator = idGenerator;

            var structures = Builder.CreateStructures(items, schema);

            Assert.AreEqual(2, idGenerator.CallsToGenerateSingle);
            Assert.AreEqual(0, idGenerator.CallsToGenerateMany);
        }
Пример #2
0
        public void CreateStructure_WhenSpecificIdGeneratorIsPassed_SpecificIdGeneratorIsNotConsumed()
        {
            var idValue = new Guid("A058FCDE-A3D9-4EAA-AA41-0CE9D4A3FB1E");
            var item    = new GuidItem {
                StructureId = idValue
            };
            var schema      = StructureSchemaTestFactory.CreateRealFrom <GuidItem>();
            var idGenerator = new GuidStructureIdGeneratorProxy();

            Builder.StructureIdGenerator = idGenerator;

            Builder.StructureIdGenerator = idGenerator;
            var structure = Builder.CreateStructure(item, schema);

            Assert.AreEqual(0, idGenerator.CallsToGenerateSingle);
            Assert.AreEqual(0, idGenerator.CallsToGenerateMany);
        }
        public void CreateStructures_inParallel_WhenNoIdAreAssigned_IdsAreGenerated()
        {
            var schema = StructureSchemaTestFactory.CreateRealFrom<GuidItem>();
            var initialIdValue = Guid.Empty;
            var items = CreateGuidItems(StructureBuilder.LimitForSerialStructureBuilding + 1);
            var idGenerator = new GuidStructureIdGeneratorProxy();
            Builder.StructureIdGenerator = idGenerator;

            var structures = Builder.CreateStructures(items, schema);

            Assert.AreEqual(items.Length, idGenerator.CallsToGenerateSingle);
            Assert.AreEqual(0, idGenerator.CallsToGenerateMany);
            for (var i = 0; i < items.Length; i++)
            {
                Assert.AreNotEqual(initialIdValue, structures[i].Id.Value);
                Assert.AreNotEqual(initialIdValue, items[i].StructureId);
            }
        }
Пример #4
0
        public void CreateStructures_inSerial_WhenIdsAreAssigned_IdsAreNotGenerated()
        {
            var schema      = StructureSchemaTestFactory.CreateRealFrom <GuidItem>();
            var items       = CreateGuidItems(StructureBuilder.LimitForSerialStructureBuilding, true);
            var idGenerator = new GuidStructureIdGeneratorProxy();

            Builder.StructureIdGenerator = idGenerator;

            var structures = Builder.CreateStructures(items, schema);

            Assert.AreEqual(0, idGenerator.CallsToGenerateSingle);
            Assert.AreEqual(0, idGenerator.CallsToGenerateMany);
            for (var i = 0; i < items.Length; i++)
            {
                Assert.AreNotEqual(Guid.Empty, structures[i].Id.Value);
                Assert.AreNotEqual(Guid.Empty, items[i].StructureId);
            }
        }
        public void CreateStructures_WhenSpecificIdGeneratorIsPassed_SpecificIdGeneratorIsConsumed()
        {
            var items = new[] { new GuidItem { Value = 42 }, new GuidItem { Value = 43 } };
            var schema = StructureSchemaTestFactory.CreateRealFrom<GuidItem>();
            var idGenerator = new GuidStructureIdGeneratorProxy();
            Builder.StructureIdGenerator = idGenerator;

            var structures = Builder.CreateStructures(items, schema);

            Assert.AreEqual(2, idGenerator.CallsToGenerateSingle);
            Assert.AreEqual(0, idGenerator.CallsToGenerateMany);
        }
        public void CreateStructure_WhenSpecificIdGeneratorIsPassed_SpecificIdGeneratorIsNotConsumed()
        {
            var idValue = new Guid("A058FCDE-A3D9-4EAA-AA41-0CE9D4A3FB1E");
            var item = new GuidItem { StructureId = idValue };
            var schema = StructureSchemaTestFactory.CreateRealFrom<GuidItem>();
            var idGenerator = new GuidStructureIdGeneratorProxy();
            Builder.StructureIdGenerator = idGenerator;

            Builder.StructureIdGenerator = idGenerator;
            var structure = Builder.CreateStructure(item, schema);

            Assert.AreEqual(0, idGenerator.CallsToGenerateSingle);
            Assert.AreEqual(0, idGenerator.CallsToGenerateMany);
        }