Exemplo n.º 1
0
        public void NamedParameterTest()
        {
            var intParameter = new NamedParameter <int> {
                Value = 23, Name = "name1"
            };
            var stringParameter = new NamedParameter <string> {
                Value = "qwerty1234", Name = "name2"
            };
            var dynamicParameter = new NamedParameter <Task> {
                Value = Task.CompletedTask, Name = "name3"
            };
            var objectParameter = new NamedParameter <object> {
                Value = CancellationToken.None, Name = "name4"
            };

            intParameter.GetParamType().Should().BeAssignableTo <int>();
            stringParameter.GetParamType().Should().BeAssignableTo <string>();
            dynamicParameter.GetParamType().Should().BeAssignableTo <Task>();
            objectParameter.GetParamType().Should().BeAssignableTo <object>();

            intParameter.GetValue().Should().BeAssignableTo <int>();
            stringParameter.GetValue().Should().BeAssignableTo <string>();
            dynamicParameter.GetValue().Should().BeAssignableTo <Task>();
            objectParameter.GetValue().Should().BeAssignableTo <object>();

            intParameter.GetValue().Should().Be(23);
            stringParameter.GetValue().Should().Be("qwerty1234");
            dynamicParameter.GetValue().Should().Be(Task.CompletedTask);
            objectParameter.GetValue().Should().Be(CancellationToken.None);

            intParameter.Name.Should().Be("name1");
            stringParameter.Name.Should().Be("name2");
            dynamicParameter.Name.Should().Be("name3");
            objectParameter.Name.Should().Be("name4");
        }