public void GetIndexes_WhenItemWithNullString_ReturnsNoIndex()
        {
            var item = new WithNoArray { StringValue = null };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithNoArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.IsNull(indexes.SingleOrDefault(i => i.Path == "StringValue"));
        }
        public void GetIndexes_WhenItemHasNulledGuidId_ReturnsNoIndex()
        {
            var item = new WithNullableGuidId { StructureId = null };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithNullableGuidId>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(0, indexes.Count);
        }
        public void GetIndexes_WhenItemWithAssignedString_ReturnsIndexWithStringValue()
        {
            var item = new WithNoArray { StringValue = "A" };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithNoArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual("A", indexes.Single(i => i.Path == "StringValue").Value);
        }
        public void GetIndexes_WhenItemHasGuidId_ReturnsId()
        {
            var id = Guid.Parse("1F0E8C1D-7AF5-418F-A6F6-A40B7F31CB00");
            var item = new WithGuidId { StructureId = id };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithGuidId>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(id, indexes.Single(i => i.Path == "StructureId").Value);
        }
        public void GetIndexes_WhenItemWithComplexEnumerable_ReturnsIndexWithDataTypeOfStringElement()
        {
            var item = new WithComplexArray { Items = new[] { new Complex {Name = "Foo", Value = 42} } };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithComplexArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(DataTypeCode.String, indexes.Single(i => i.Path == "Items.Name").DataTypeCode);
            Assert.AreEqual(DataTypeCode.IntegerNumber, indexes.Single(i => i.Path == "Items.Value").DataTypeCode);
        }
示例#6
0
        public void GetIndexes_WhenItemWithEnumerableWithOneString_ReturnsIndexWithDataTypeOfStringElement()
        {
            var item = new WithArray {
                StringValues = new[] { "A" }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(DataTypeCode.String, indexes.Single(i => i.Path == "StringValues").DataTypeCode);
        }
示例#7
0
        public void GetIndexes_WhenItemWithEnumerableWithOneNullInt_ReturnsNullIndex()
        {
            var item = new WithArray {
                NullableIntValues = new int?[] { null }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.IsNull(indexes.SingleOrDefault(i => i.Path == "NullableIntValues"));
        }
示例#8
0
        public void GetIndexes_WhenItemWithAssignedString_ReturnsIndexWithStringValue()
        {
            var item = new WithNoArray {
                StringValue = "A"
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithNoArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            Assert.AreEqual("A", indexes.Single(i => i.Path == "StringValue").Value);
        }
示例#9
0
        public void GetIndexes_WhenItemWithEnumerableWithOneInt_ReturnsIndexWithInt()
        {
            var item = new WithArray {
                IntValues = new[] { 42 }
            };
            var schema = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schema, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(42, indexes.Single(i => i.Path == "IntValues").Value);
        }
示例#10
0
        public void GetIndexes_WhenItemHasNulledGuidId_ReturnsNoIndex()
        {
            var item = new WithNullableGuidId {
                StructureId = null
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithNullableGuidId>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(0, indexes.Count);
        }
示例#11
0
        public void GetIndexes_WhenItemWithEnumerableWithOneString_ReturnsIndexWithString()
        {
            var item = new WithArray {
                StringValues = new[] { "A" }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            Assert.AreEqual("A", indexes.Single(i => i.Path == "StringValues[0]").Value);
        }
示例#12
0
        public void GetIndexes_WhenItemWithAssignedInt_ReturnsIndexWithIntValue()
        {
            var item = new WithNoArray {
                IntValue = 42
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithNoArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(42, indexes.Single(i => i.Path == "IntValue").Value);
        }
示例#13
0
        public void GetIndexes_WhenItemWithNullString_ReturnsNoIndex()
        {
            var item = new WithNoArray {
                StringValue = null
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithNoArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.IsNull(indexes.SingleOrDefault(i => i.Path == "StringValue"));
        }
示例#14
0
        public void GetIndexes_WhenItemWithEnumerableWithTwoEqualElements_ReturnsTwoStringIndexes()
        {
            var item = new WithArray {
                StringValues = new[] { "A", "A" }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            Assert.AreEqual("A", indexes[0].Value);
            Assert.AreEqual("A", indexes[1].Value);
        }
示例#15
0
        public void GetIndexes_WhenNullableGuidIdHasValue_ReturnsId()
        {
            var value = Guid.Parse("1F0E8C1D-7AF5-418F-A6F6-A40B7F31CB00");
            var item  = new WithNullableGuid {
                GuidValue = value
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithNullableGuid>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            Assert.AreEqual(value, indexes.Single(i => i.Path == "GuidValue").Value);
        }
示例#16
0
        public void GetIndexes_WhenNullableGuidIdHasValue_ReturnsId()
        {
            var id   = Guid.Parse("1F0E8C1D-7AF5-418F-A6F6-A40B7F31CB00");
            var item = new WithNullableGuidId {
                StructureId = id
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithNullableGuidId>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(id, indexes.Single(i => i.Path == "StructureId").Value);
        }
示例#17
0
        public void GetIndexes_WhenItemWithEnumerableWithTwoDifferentInts_ReturnsTwoIntIndexes()
        {
            var item = new WithArray {
                IntValues = new[] { 42, 43 }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            Assert.AreEqual(42, indexes[0].Value);
            Assert.AreEqual(43, indexes[1].Value);
        }
示例#18
0
        public void GetIndexes_WhenItemWithEnumerableWithTwoEqualElements_ReturnsTwoIntIndexes()
        {
            var item = new WithArray {
                IntValues = new[] { 42, 42 }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(42, indexes[1].Value);
            Assert.AreEqual(42, indexes[2].Value);
        }
示例#19
0
        public void GetIndexes_WhenItemWithEnumerableWithTwoDifferentStrings_ReturnsTwoStringIndexes()
        {
            var item = new WithArray {
                StringValues = new[] { "A", "B" }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual("A", indexes[1].Value);
            Assert.AreEqual("B", indexes[2].Value);
        }
示例#20
0
        public void GetIndexes_WhenItemWithComplexEnumerable_ReturnsIndexWithDataTypeOfStringElement()
        {
            var item = new WithComplexArray {
                Items = new[] { new Complex {
                                    Name = "Foo", Value = 42
                                } }
            };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithComplexArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(DataTypeCode.String, indexes.Single(i => i.Path == "Items.Name").DataTypeCode);
            Assert.AreEqual(DataTypeCode.IntegerNumber, indexes.Single(i => i.Path == "Items.Value").DataTypeCode);
        }
示例#21
0
        public void GetIndexes_WhenItemWithArraysBeingNull_ReturnesNoIndexes()
        {
            var item = new WithArray
            {
                IntValues         = null,
                NullableIntValues = null,
                StringValues      = null
            };

            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            indexes.Should().BeEmpty();
        }
示例#22
0
        public void GetIndexes_WhenArrayOfComplexWithChildBeingNull_ReturnesNoIndexes()
        {
            var item = new WithComplexArray
            {
                Items = new[] { new Complex {
                                    Name = null, Value = 42
                                } }
            };

            var schemaStub = StructureSchemaTestFactory.CreateRealFrom <WithComplexArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item).ToList();

            indexes.Count.Should().Be(1);
            indexes[0].Value.Should().Be(42);
        }
        public void GetIndexes_WhenItemWithEnumerableWithOneNullInt_ReturnsNullIndex()
        {
            var item = new WithArray { NullableIntValues = new int?[] { null } };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.IsNull(indexes.SingleOrDefault(i => i.Path == "NullableIntValues"));
        }
        public void GetIndexes_WhenItemWithEnumerableWithOneInt_ReturnsIndexWithInt()
        {
            var item = new WithArray { IntValues = new[] { 42 } };
            var schema = StructureSchemaTestFactory.CreateRealFrom<WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schema, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(42, indexes.Single(i => i.Path == "IntValues").Value);
        }
        public void GetIndexes_WhenItemWithEnumerableWithTwoEqualElements_ReturnsTwoStringIndexes()
        {
            var item = new WithArray { StringValues = new[] { "A", "A" } };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual("A", indexes[1].Value);
            Assert.AreEqual("A", indexes[2].Value);
        }
        public void GetIndexes_WhenItemWithEnumerableWithTwoDifferentInts_ReturnsTwoIntIndexes()
        {
            var item = new WithArray { IntValues = new[] { 42, 43 } };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(42, indexes[1].Value);
            Assert.AreEqual(43, indexes[2].Value);
        }
        public void GetIndexes_WhenItemWithEnumerableWithOneString_ReturnsIndexWithDataTypeOfStringElement()
        {
            var item = new WithArray { StringValues = new[] { "A" } };
            var schemaStub = StructureSchemaTestFactory.CreateRealFrom<WithArray>();

            var factory = new StructureIndexesFactory();
            var indexes = factory.CreateIndexes(schemaStub, item, _structureIdGenerator.Invoke()).ToList();

            Assert.AreEqual(DataTypeCode.String, indexes.Single(i => i.Path == "StringValues").DataTypeCode);
        }