public void CreateStructure_WhenEnumerableIntsOnFirstLevelAreNull_ReturnsNoIndex() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { IntArray = null }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.SingleOrDefault(si => si.Path.StartsWith("IntArray")); Assert.IsNull(actual); }
public void CreateStructure_WhenUIntOnFirstLevel_ReturnsSimpleValue() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { UIntValue = 42 }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.Single(si => si.Path == "UIntValue").Value; actual.Should().Be((uint)42); }
public void CreateStructure_WhenIntOnFirstLevel_ReturnsSimpleValue() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { IntValue = 42 }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.Single(si => si.Path == "IntValue").Value; Assert.AreEqual(42, actual); }
public void CreateStructure_WhenUIntOnFirstLevel_ReturnsSimpleValue() { var schema = StructureSchemaTestFactory.CreateRealFrom <TestItemForFirstLevel>(); var item = new TestItemForFirstLevel { UIntValue = 42 }; var structure = Builder.CreateStructure(item, schema); var actual = structure.Indexes.Single(si => si.Path == "UIntValue").Value; Assert.AreEqual(42, actual); }
public void CreateStructure_WhenEnumerableIntsOnFirstLevelAreNull_ReturnsNoIndex() { var schema = StructureSchemaTestFactory.CreateRealFrom <TestItemForFirstLevel>(); var item = new TestItemForFirstLevel { IntArray = null }; var structure = Builder.CreateStructure(item, schema); var actual = structure.Indexes.SingleOrDefault(si => si.Path.StartsWith("IntArray")); Assert.IsNull(actual); Assert.AreEqual(2, structure.Indexes.Count); }
public void CreateStructure_WhenEnumerableIntsOnFirstLevel_ReturnsOneIndexPerElementInCorrectOrder() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { IntArray = new[] { 5, 6, 7 } }; var structure = Builder.CreateStructure(item); var indices = structure.Indexes.Where(i => i.Path.StartsWith("IntArray[")).ToList(); Assert.AreEqual(5, indices[0].Value); Assert.AreEqual(6, indices[1].Value); Assert.AreEqual(7, indices[2].Value); }
public void CreateStructure_WhenEnumerableIntsOnFirstLevel_ReturnsOneIndexPerElementInCorrectOrder() { var schema = StructureSchemaTestFactory.CreateRealFrom <TestItemForFirstLevel>(); var item = new TestItemForFirstLevel { IntArray = new[] { 5, 6, 7 } }; var structure = Builder.CreateStructure(item, schema); var indices = structure.Indexes.Where(i => i.Path == "IntArray").ToList(); Assert.AreEqual(5, indices[0].Value); Assert.AreEqual(6, indices[1].Value); Assert.AreEqual(7, indices[2].Value); }
public void CreateStructure_WhenSpecificIdGeneratorIsPassed_SpecificIdGeneratorIsConsumed() { var idValue = new Guid("A058FCDE-A3D9-4EAA-AA41-0CE9D4A3FB1E"); var idGeneratorMock = new Mock <IStructureIdGenerator>(); idGeneratorMock.Setup(m => m.Generate(It.IsAny <IStructureSchema>())).Returns(StructureId.Create(idValue)); var item = new TestItemForFirstLevel { IntValue = 42 }; var schema = StructureSchemaTestFactory.CreateRealFrom <TestItemForFirstLevel>(); Builder.StructureIdGenerator = idGeneratorMock.Object; var structure = Builder.CreateStructure(item, schema); idGeneratorMock.Verify(m => m.Generate(schema), Times.Once()); }
public void CreateStructure_WhenUIntOnFirstLevel_ReturnsSimpleValue() { var schema = StructureSchemaTestFactory.CreateRealFrom<TestItemForFirstLevel>(); var item = new TestItemForFirstLevel { UIntValue = 42 }; var structure = Builder.CreateStructure(item, schema); var actual = structure.Indexes.Single(si => si.Path == "UIntValue").Value; Assert.AreEqual(42, actual); }
public void CreateStructure_WhenSpecificIdGeneratorIsPassed_SpecificIdGeneratorIsConsumed() { var idValue = new Guid("A058FCDE-A3D9-4EAA-AA41-0CE9D4A3FB1E"); var idGeneratorMock = new Mock<IStructureIdGenerator>(); idGeneratorMock.Setup(m => m.Generate(It.IsAny<IStructureSchema>())).Returns(StructureId.Create(idValue)); var item = new TestItemForFirstLevel { IntValue = 42 }; var schema = StructureSchemaTestFactory.CreateRealFrom<TestItemForFirstLevel>(); Builder.StructureIdGenerator = idGeneratorMock.Object; var structure = Builder.CreateStructure(item, schema); idGeneratorMock.Verify(m => m.Generate(schema), Times.Once()); }