public void GivenSubClassesValues_WhenDeserialize_ShouldPass() { var keyValues = new Dictionary <string, string> { ["IntValue"] = "52", ["StrValue"] = "string3", ["ClassType"] = "Second", ["SubClass1:ClassName"] = "ClassName1", ["SubClass1:SubValue"] = "10", ["SubClass2:ClassName"] = "ClassName2", ["SubClass2:SubValue"] = "100", }; IConfiguration configuration = new ConfigurationBuilder() .AddInMemoryCollection(keyValues) .Build(); Main subject = new Main(); configuration.Bind(subject); subject.IntValue.Should().Be(keyValues[nameof(subject.IntValue)].ConvertToType <int>()); subject.StrValue.Should().Be(keyValues[nameof(subject.StrValue)].ConvertToType <string>()); subject.ClassType.Should().Be(keyValues[nameof(subject.ClassType)].ConvertToType <ClassType>()); subject.SubClass1.Should().NotBeNull(); subject.SubClass1 !.ClassName.Should().Be(keyValues["SubClass1:ClassName"].ConvertToType <string>()); subject.SubClass1 !.SubValue.Should().Be(keyValues["SubClass1:SubValue"].ConvertToType <int>()); subject.SubClass2.Should().NotBeNull(); subject.SubClass2 !.ClassName.Should().Be(keyValues["SubClass2:ClassName"].ConvertToType <string>()); subject.SubClass2 !.SubValue.Should().Be(keyValues["SubClass2:SubValue"].ConvertToType <int>()); }