Esempio n. 1
0
        public async Task TestPostUserAsync()
        {
            // 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);
            var model   = new User
            {
                Id       = 1,
                Username = "******",
                Password = "******"
            };

            //Act
            await service.Postuser(model);

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