public void CreateUser_Test() { var user = new User { UserName = "******", DisplayName = "Testuser", EmploymentDate = DateTime.Now }; var userRepositoryMock = new Mock <IRepository <User> >(); userRepositoryMock.Setup(m => m.Insert(user)).Verifiable(); var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(m => m.UserRepository).Returns(userRepositoryMock.Object); IUserSystem sut = new UserSystem(unitOfWorkMock.Object); //Act sut.CreateUser(user); //Assert userRepositoryMock.Verify(r => r.Insert(user), Times.Once); unitOfWorkMock.Verify(u => u.SaveChanges(), Times.Once); }