public void AddUser_Return_DATA_BASE_ERROR() { // Arrange var mockDb = new Mock <IDataBaseManager>(); var mockLogger = new Mock <ILogger>(); var mockSessionManager = new Mock <ISessionStateManager>(); var mockMapper = new Mock <IMapper>(); RegisterUserRequest registerUserRequest = new RegisterUserRequest() { Login = "******", Email = "ghjknnb@gf@vb", Password = "******" }; UserData userData = new UserData() { Login = "******", Email = "ghjknnb1@gf@vb", Password = "******" }; mockMapper.Setup(mp => mp.Map <RegisterUserRequest, UserData>(It.IsAny <RegisterUserRequest>())).Returns(userData); mockDb.Setup(db => db.isExistUser(It.Is <UserData>(ud => userData.Equals(ud)))).Throws(new Exception()); mockDb.Setup(db => db.AddUser(It.Is <UserData>(ud => userData.Equals(ud)))).Throws(new Exception()); mockLogger.Setup(db => db.Error(It.IsAny <string>())); var manager = new AuthenticationManager(mockDb.Object, mockLogger.Object, mockSessionManager.Object, mockMapper.Object); // Act var result = manager.AddUser(registerUserRequest); // Assert Assert.AreEqual(Errors.DATA_BASE_ERROR, result); }
public void CreateUser() { var mockLogger = new Mock <TraceWriter>(); mockLogger.Setup(x => x.Info(It.IsAny <string>(), null)); var dataStore = new Mock <IDataStore>(); var appSettings = new Mock <IAppSettings>(); AuthenticationManager auth = new AuthenticationManager(dataStore.Object, mockLogger.Object, appSettings.Object); auth.AddUser() }