Exemplo n.º 1
0
        public void Add_Value_Not_Of_Given_Type_Should_Throw_ArgumentOutOfRangeException()
        {
            var    dic    = new TypeValueDictionary();
            Action action = () => dic.Add(typeof(string), 1);

            action.Should().Throw <ArgumentOutOfRangeException>();
        }
Exemplo n.º 2
0
        public void Add_NullValue_Should_Throw_ArgumentNullException()
        {
            var    dic    = new TypeValueDictionary();
            Action action = () => dic.Add(typeof(string), null);

            action.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 3
0
        public void Add_NullType_Should_Throw_ArgumentNullException()
        {
            var    dic    = new TypeValueDictionary();
            Action action = () => dic.Add(null, 1);

            action.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 4
0
        public void Add_NullFunc_Should_Throw_ArgumentNullException()
        {
            var        dic    = new TypeValueDictionary();
            Func <int> func   = null;
            Action     action = () => dic.Add(func);

            action.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 5
0
        public void TryGet_Should_Return_False_If_Destination_Type_Not_Defined()
        {
            var dic = new TypeValueDictionary();

            dic.TryGet(typeof(string), out var nullValue).Should().BeFalse();

            dic.Add(1);
            dic.TryGet(typeof(string), out nullValue).Should().BeFalse();
        }
Exemplo n.º 6
0
        public void Add_Should_Override_Prior_Definitions()
        {
            var dic = new TypeValueDictionary();

            dic.Add(1);
            dic.Add(2);

            dic.TryGet(typeof(int), out var nullValue).Should().BeTrue();
            nullValue.Should().Be(2);
        }
Exemplo n.º 7
0
        public void TryGet_Should_Return_The_Specified_Null_Value_If_Defined()
        {
            var dic = new TypeValueDictionary();

            dic.Add(1);
            dic.Add(typeof(string), ".null.");
            dic.Add(Get12Point3);

            dic.TryGet(typeof(int), out var nullValue).Should().BeTrue();
            nullValue.Should().Be(1);

            dic.TryGet(typeof(string), out nullValue).Should().BeTrue();
            nullValue.Should().Be(".null.");

            dic.TryGet(typeof(decimal), out nullValue).Should().BeTrue();
            nullValue.Should().Be(12.3m);
        }