public void AddConverterNullException()
        {
            var ex = Assert.Throws <ArgumentNullException>(() =>
            {
                converters.Add(null, typeof(string));
            });

            Assert.Equal("converter", ex.ParamName);
        }
Beispiel #2
0
    public static void Main()
    {
        ConverterCollection <string> c = new ConverterCollection <string>(
            delegate(string s) { return(s.ToUpper()); });

        c.Add("Hello");
        c.Add("World!");

        foreach (string s in c)
        {
            Console.WriteLine(s);
        }
    }
        public void Add_GoodValues_Succeeds()
        {
            //Arrange
            var converterCollection = new ConverterCollection();

            //Act
            converterCollection.Add<string, string>((string source, TypeMappingContext context) => null);

            //Assert
            Assert.IsNotNull(converterCollection.Get(typeof(string), typeof(string)));
        }
        public void Get_GoodValues_ReturnsConverter()
        {
            //Arrange
            var converterCollection = new ConverterCollection();
            converterCollection.Add<string, string>((string source, TypeMappingContext context) => null);

            //Act
            var value = converterCollection.Get(typeof(string), typeof(string));

            //Assert
            Assert.IsNotNull(value);
        }
        public void AddFindConverter()
        {
            converters.Add(new StringConverter(), typeof(string), typeof(int));
            var found = converters.Find(typeof(string), typeof(int));

            Assert.NotNull(found);
            Assert.IsType <StringConverter>(found);
        }