Exemplo n.º 1
0
        public void MethodDescription_CreateSetsHasCancellationTokenToTrue_WhenMethodHasTokenAsArgument()
        {
            // Arrange
            MethodInfo methodInfo = typeof(ITestActor).GetMethod("MethodWithToken");

            // Act
            var description = MethodDescription.Create("actor", methodInfo, false);

            // Assert
            description.HasCancellationToken.Should().BeTrue();
        }
Exemplo n.º 2
0
        public void MethodDescription_CreateCrcId_WhenUseCrcIdGenerationIsSet()
        {
            // Arrange
            MethodInfo methodInfo = typeof(ITestActor).GetMethod("GetString");

            // Act
            var description = MethodDescription.Create("actor", methodInfo, true);

            // Assert
            description.Id.Should().Be(70257263);
        }
Exemplo n.º 3
0
        public void MethodDescription_CreateThrowsArgumentException_WhenMethodHasTokenAsNonLastArgument()
        {
            // Arrange
            Type       type       = typeof(ITestActor);
            MethodInfo methodInfo = type.GetMethod("MethodWithTokenNotLast");

            // Act
            Action action = () => MethodDescription.Create("actor", methodInfo, false);

            // Assert
            action.Should().ThrowExactly <ArgumentException>()
            .WithMessage("Method 'MethodWithTokenNotLast' of actor interface '*+ITestActor' has a '*.CancellationToken' parameter that is not the last parameter. If an actor method accepts a '*.CancellationToken' parameter, it must be the last parameter.*")
            .And.ParamName.Should().Be("actorInterfaceType");
        }
Exemplo n.º 4
0
        private static MethodDescription[] GetMethodDescriptions(
            string remotedInterfaceKindName,
            Type remotedInterfaceType,
            MethodReturnCheck methodReturnCheck,
            bool useCRCIdGeneration)
        {
            EnsureValidMethods(remotedInterfaceKindName, remotedInterfaceType, methodReturnCheck);
            var methods            = remotedInterfaceType.GetMethods();
            var methodDescriptions = new MethodDescription[methods.Length];

            for (var i = 0; i < methods.Length; i++)
            {
                methodDescriptions[i] = MethodDescription.Create(remotedInterfaceKindName, methods[i], useCRCIdGeneration);
            }

            return(methodDescriptions);
        }
Exemplo n.º 5
0
        public void MethodDescription_CreateGeneratesArgumentDescriptions_WhenMethodHasArguments()
        {
            // Arrange
            MethodInfo methodInfo = typeof(ITestActor).GetMethod("MethodWithArguments");

            // Act
            var description = MethodDescription.Create("actor", methodInfo, false);

            // Assert
            using var _ = new AssertionScope();
            description.Arguments.Should().NotContainNulls();
            description.Arguments.Should().AllBeOfType <MethodArgumentDescription>();
            description.Arguments.Should().BeEquivalentTo(
                new { Name = "number" },
                new { Name = "choice" },
                new { Name = "information" });
        }
Exemplo n.º 6
0
        public void MethodDescription_CreatMethodDescription()
        {
            // Arrange
            MethodInfo methodInfo = typeof(ITestActor).GetMethod("GetString");

            // Act
            var description = MethodDescription.Create("actor", methodInfo, false);

            // Assert
            description.Should().NotBeNull();

            using var _ = new AssertionScope();
            description.MethodInfo.Should().BeSameAs(methodInfo);
            description.Name.Should().Be("GetString");
            description.ReturnType.Should().Be <Task <string> >();
            description.Id.Should().NotBe(0);
            description.Arguments.Should().BeEmpty();
            description.HasCancellationToken.Should().BeFalse();
        }