static void Main(string[] args) { MethodsCollection methods = new MethodsCollection(); int result = methods.Add(1, 1); Console.WriteLine(result); }
public async Task <IAsyncEnumerable <object> > InvokeMethodStreamAsync(ClientRequestMessage clientMessage, CancellationToken cancellationToken) { var methodInformations = MethodsCollection.GetMethodInformations(clientMessage.Method); var authentication = new SignalARRRAuthentication(_serviceProvider); var result = await authentication.Authorize(ClientContext, clientMessage.Authorization, methodInformations.MethodInfo); if (!result.Succeeded) { throw new UnauthorizedException(); } object instance; if (methodInformations.MethodInfo.DeclaringType == HARRR.GetType()) { instance = ActivatorUtilities.CreateInstance(_serviceProvider, HARRR.GetType()); } else { instance = _serviceProvider.GetRequiredService(methodInformations.MethodInfo.ReflectedType); } return(await InvokeStreamMethodInfoAsync(instance, methodInformations.MethodInfo, clientMessage.Arguments, cancellationToken)); }
private async Task <object> InvokeMethodAsync(ServerRequestMessage serverRequestMessage) { var methodCallInfo = MethodsCollection.GetMethodInformations(serverRequestMessage.Method); var instance = methodCallInfo.Factory.DynamicInvoke(_harrrContext.GetHubConnection().GetServiceProvider()); return(InvokeMethodInfoAsync(instance, methodCallInfo.MethodInfo, serverRequestMessage.Arguments, serverRequestMessage.GenericArguments, serverRequestMessage.CancellationGuid)); }
public void TestAdd() { // Arrange - här skrivs kod som krävs för att utföra en handling MethodsCollection methods = new MethodsCollection(); // Act - tex anropar en metod int result = methods.Add(1, 2); // Assert - här ska vi evaluera resultatet av vår Act. Assert är en klass som innehåller massor med statiska metoder. Assert.Equal(3, result); }
public void TestAdd2(int a, int b, int expected) { // Arrange MethodsCollection methods = new MethodsCollection(); // Act int result = methods.Add(a, b); // Assert Assert.Equal(expected, result); }