コード例 #1
0
        public void ShouldResetRegistrations()
        {
            // Arrange
            const string       InputString          = "http://www.thomasgalliker.ch";
            int                numberOfConvertCalls = 0;
            IConverterRegistry converterRegistry    = new ConverterRegistry();
            var                converter            = new TestConverter(() => { numberOfConvertCalls++; });

            converterRegistry.RegisterConverter <string, Uri>(() => converter);

            // Act
            var convertedInputStringBeforeReset = converterRegistry.TryConvert <string, Uri>(InputString, null);

            converterRegistry.Reset();

            var convertedInputStringAfterReset = converterRegistry.TryConvert <string, Uri>(InputString, null);

            // Assert
            numberOfConvertCalls.Should().Be(1);
            convertedInputStringBeforeReset.Should().Be(InputString);
            convertedInputStringAfterReset.Should().BeNull();
        }