Exemplo n.º 1
0
        public async Task SayHelloUnaryTest()
        {
            // Arrange
            var service = new TesterService(NullLoggerFactory.Instance);

            // Act
            var response = await service.SayHelloUnary(new HelloRequest { Name = "Joe" }, TestServerCallContext.Create());

            // Assert
            Assert.AreEqual("Hello Joe", response.Message);
        }
Exemplo n.º 2
0
        public async Task SayHelloUnaryTest()
        {
            // Arrange
            var mockGreeter = CreateGreeterMock();
            var service     = new TesterService(mockGreeter.Object);

            // Act
            var response = await service.SayHelloUnary(new HelloRequest { Name = "Joe" }, TestServerCallContext.Create());

            // Assert
            mockGreeter.Verify(v => v.Greet("Joe"));
            Assert.AreEqual("Hello Joe", response.Message);
        }
Exemplo n.º 3
0
        public async Task SayHelloUnaryTest()
        {
            // Arrange
            var mockGreeter = new Mock <IGreeter>();

            mockGreeter.Setup(
                m => m.Greet(It.IsAny <string>())).Returns((string s) => $"Hello {s}");
            var service = new TesterService(mockGreeter.Object);

            // Act
            var response = await service.SayHelloUnary(
                new HelloRequest { Name = "Joe" }, TestServerCallContext.Create());

            // Assert
            mockGreeter.Verify(v => v.Greet("Joe"));
            Assert.Equal("Hello Joe", response.Message);
        }