Example #1
0
        public async Task TestGetUserAsync() // Q? does this not work as I am mocking the context?
        {
            // Arrange
            var mockSet     = new Mock <DbSet <User> >();
            var mockContext = new Mock <userContext>();

            //mockContext.Setup(options => options.UseSqlServer(Configuration.GetConnectionString("userContext")));
            mockContext.Setup(m => m.User).Returns(mockSet.Object);
            var service = new userController(mockContext.Object);

            //Act
            await service.Getuser(1);

            // Verify
            mockSet.Verify(m => m.Add(It.IsAny <User>()), Times.Once());
        }