public void Returns_false_when_converter_fails()
            {
                var failingConverter = new FuncFieldConverter(
                    _ => FieldConverterResult.Failed,
                    converterName: "Test");

                var dummyField = new KeyValuePair <string, object>("foo", "bar");

                var result = failingConverter.TryConvertField(dummyField, typeof(IAccount));

                result.Success.ShouldBeFalse();
                result.Value.ShouldBeNull();
            }
            public void Returns_value_when_expected_type_matches()
            {
                var fakeAccountFieldConverter = new FuncFieldConverter(
                    appliesToTargetType: typeof(IAccount),
                    convertAction: _ => new FieldConverterResult(true, "good!"),
                    converterName: "Test");

                var dummyField = new KeyValuePair<string, object>("foo", "bar");

                var result = fakeAccountFieldConverter.TryConvertField(dummyField, typeof(IAccount));

                result.Success.ShouldBeTrue();
                result.Value.ShouldBe("good!");
            }
            public void Returns_value_when_any_type_is_supported()
            {
                var stringFieldConverter = new FuncFieldConverter(
                    t => new FieldConverterResult(true, t.Value.ToString()),
                    converterName: "Test");

                var dummyField = new KeyValuePair<string, object>("foo", "bar");
                var applicationTarget = Type.GetType(nameof(IApplication));

                var result = stringFieldConverter.TryConvertField(dummyField, applicationTarget);

                result.Success.ShouldBeTrue();
                result.Value.ShouldBe("bar");
            }
            public void Returns_null_and_false_when_expected_type_does_not_match()
            {
                var fakeAccountFieldConverter = new FuncFieldConverter(
                    appliesToTargetType: typeof(IAccount),
                    convertAction: _ => new FieldConverterResult(true, new object()),
                    converterName: "Test");

                var dummyField = new KeyValuePair<string, object>("foo", "bar");

                var result = fakeAccountFieldConverter.TryConvertField(dummyField, typeof(IApplication));

                result.Success.ShouldBeFalse();
                result.Value.ShouldBeNull();
            }
            public void Returns_value_when_expected_type_matches_inside_collection_type()
            {
                var fakeAccountFieldConverter = new FuncFieldConverter(
                    appliesToTargetType: typeof(IAccount),
                    convertAction: _ => new FieldConverterResult(true, "good!"),
                    converterName: "Test");

                var dummyField = new KeyValuePair <string, object>("foo", "bar");

                var result = fakeAccountFieldConverter.TryConvertField(dummyField, typeof(CollectionResponsePage <IAccount>));

                result.Success.ShouldBeTrue();
                result.Value.ShouldBe("good!");
            }
            public void Returns_value_when_any_type_is_supported()
            {
                var stringFieldConverter = new FuncFieldConverter(
                    t => new FieldConverterResult(true, t.Value.ToString()),
                    converterName: "Test");

                var dummyField        = new KeyValuePair <string, object>("foo", "bar");
                var applicationTarget = Type.GetType(nameof(IApplication));

                var result = stringFieldConverter.TryConvertField(dummyField, applicationTarget);

                result.Success.ShouldBeTrue();
                result.Value.ShouldBe("bar");
            }
            public void Returns_null_and_false_when_expected_type_does_not_match()
            {
                var fakeAccountFieldConverter = new FuncFieldConverter(
                    appliesToTargetType: typeof(IAccount),
                    convertAction: _ => new FieldConverterResult(true, new object()),
                    converterName: "Test");

                var dummyField = new KeyValuePair <string, object>("foo", "bar");

                var result = fakeAccountFieldConverter.TryConvertField(dummyField, typeof(IApplication));

                result.Success.ShouldBeFalse();
                result.Value.ShouldBeNull();
            }
            public void Returns_value_when_expected_type_exists_in_list()
            {
                var fakeAccountFieldConverter = new FuncFieldConverter(
                    _ => new FieldConverterResult(true, "good!"),
                    "Test",
                    typeof(IApplication),
                    typeof(IAccount));

                var dummyField = new KeyValuePair <string, object>("foo", "bar");

                var result = fakeAccountFieldConverter.TryConvertField(dummyField, typeof(IAccount));

                result.Success.ShouldBeTrue();
                result.Value.ShouldBe("good!");
            }
            public void Returns_value_when_expected_type_exists_in_list()
            {
                var fakeAccountFieldConverter = new FuncFieldConverter(
                    _ => new FieldConverterResult(true, "good!"),
                    "Test",
                    typeof(IApplication),
                    typeof(IAccount));

                var dummyField = new KeyValuePair<string, object>("foo", "bar");

                var result = fakeAccountFieldConverter.TryConvertField(dummyField, typeof(IAccount));

                result.Success.ShouldBeTrue();
                result.Value.ShouldBe("good!");
            }
            public void Returns_false_when_converter_fails()
            {
                var failingConverter = new FuncFieldConverter(
                    _ => FieldConverterResult.Failed,
                    converterName: "Test");

                var dummyField = new KeyValuePair<string, object>("foo", "bar");

                var result = failingConverter.TryConvertField(dummyField, typeof(IAccount));

                result.Success.ShouldBeFalse();
                result.Value.ShouldBeNull();
            }