public void Convert_ToK_WhenF_And_ConverterForKAndFExists_Calls_FConverterToC_Then_KConverterFromC()
        {
            var temperatureF = new Temperature(1, TemperatureUnit.F);
            var temperatureC = new Temperature(2, TemperatureUnit.C);

            var fahrenheitConverterConverter = new Mock <ITemperatureConverter>();

            fahrenheitConverterConverter
            .SetupGet(c => c.Unit)
            .Returns(TemperatureUnit.F);

            fahrenheitConverterConverter
            .Setup(c => c.ToC(temperatureF))
            .Returns(temperatureC);

            var kelvinConverter = new Mock <ITemperatureConverter>();

            kelvinConverter
            .SetupGet(c => c.Unit)
            .Returns(TemperatureUnit.K);

            var converters = new[] { kelvinConverter.Object, fahrenheitConverterConverter.Object };

            var converter = new ComposableTemperatureConverter(converters);


            converter.Convert(temperatureF, TemperatureUnit.K);

            fahrenheitConverterConverter.Verify(c => c.ToC(temperatureF));
            kelvinConverter.Verify(c => c.FromC(temperatureC));
        }
        public void Convert_When_SameUnit_Returns_TheSameTemperature()
        {
            var converters  = new ITemperatureConverter[] { new FahrenheitConverter(), new CelsiusConverter() };
            var converter   = new ComposableTemperatureConverter(converters);
            var temperature = new Temperature(1, TemperatureUnit.C);

            var convertedTemperature = converter.Convert(temperature, TemperatureUnit.C);

            Assert.AreSame(temperature, convertedTemperature);
        }
        public void Convert_ToC_WhenK_And_ConverterForKExists_CallsKConverterToC()
        {
            var kelvinConverter = new Mock <ITemperatureConverter>();

            kelvinConverter
            .SetupGet(c => c.Unit)
            .Returns(TemperatureUnit.K);

            var converters = new[] { kelvinConverter.Object, new CelsiusConverter() };

            var converter   = new ComposableTemperatureConverter(converters);
            var temperature = new Temperature(1, TemperatureUnit.K);

            converter.Convert(temperature, TemperatureUnit.C);

            kelvinConverter.Verify(c => c.ToC(temperature));
        }