Exemplo n.º 1
0
        public void Assign_should_override_a_field_instance_within_a_schema_when_invoked()
        {
            // Arrange
            var sut = new Schema<Message>();

            // Act

            /// case 1: The property is one level down the member tree.
            sut.Assign(x => x.Text, DataType.FullName);
            var newTextType = sut[0].Type;

            /// case 2: The property is two levels down the member tree.
            sut.Assign(x => x.Writer.Name, DataType.FullName);
            var newNameType = sut[2].Type;

            /// case 3: The property is a list of objects.
            sut.Assign(x => x.Tags, DataType.AppName);
            var newTagType = sut[5].Type;

            /// case 4: The property is a list of objects.
            sut.Assign(x => x.Writer.Reviews.Item().Rating, DataType.RowNumber);
            var newRatingType = sut[4].Type;

            // Assert
            newTextType.ShouldBe(DataType.FullName);
            newNameType.ShouldBe(DataType.FullName);
            newTagType.ShouldBe(DataType.AppName);
            newRatingType.ShouldBe(DataType.RowNumber);
        }