public void Add(UserExtendedProxy extendedProxy) { ModelDatabase.Users.Add(new User { Login = extendedProxy.Login, Password = extendedProxy.Password, AccessType = extendedProxy.AccessType }); ModelDatabase.SaveChanges(); }
public void Edit(UserExtendedProxy oldExtendedProxy, UserExtendedProxy newExtendedProxy) { var foundUser = ModelDatabase.GetUser(oldExtendedProxy); foundUser.Login = newExtendedProxy.Login; foundUser.Password = newExtendedProxy.Password; foundUser.AccessType = newExtendedProxy.AccessType; ModelDatabase.SaveChanges(); }
public void AddUserFunctionTest_ShouldBeSuccess() { var user = new UserExtendedProxy { Login = "******" }; RunServer(new AddUserFunction(DatabaseAuthorizer, databaseUserEditor)); SendRequest("AddUser", GetDefaultParameters(), user.ToJson()); A.CallTo(() => databaseUserEditor.Add(user)).MustHaveHappened(Repeated.Exactly.Once); }
public void EditUserFunctionTest_ShouldBeSuccess() { var firstUser = new UserExtendedProxy { Login = "******" }; var secondUser = new UserExtendedProxy { Login = "******" }; RunServer(new EditUserFunction(DatabaseAuthorizer, databaseUserEditor)); SendRequest("EditUser", GetDefaultParameters(), Tuple.Create(firstUser, secondUser).ToJson()); A.CallTo(() => databaseUserEditor.Edit(firstUser, secondUser)).MustHaveHappened(Repeated.Exactly.Once); }
public void GetExtendedUserFunctionTest_ShouldBeSuccess() { var inputBasedUser = new UserBasedProxy { Login = "******" }; var inputExtendedUser = new UserExtendedProxy { Login = "******" }; A.CallTo(() => databaseUserReader.GetExtendedProxy(inputBasedUser)).Returns(inputExtendedUser); RunServer(new GetExtendedUserFunction(DatabaseAuthorizer, databaseUserReader)); var receivedUser = SendRequest <UserExtendedProxy>("GetExtendedUser", GetDefaultParameters(), inputBasedUser.ToJson()); A.CallTo(() => databaseUserReader.GetExtendedProxy(inputBasedUser)).MustHaveHappened(Repeated.Exactly.Once); Assert.That(receivedUser, Is.EqualTo(inputExtendedUser)); }
public static bool IsHaveAccess(this UserExtendedProxy user, AccessType accessType) { return((user.AccessType & (int)accessType) != 0); }
public static void AddAccess(this UserExtendedProxy user, AccessType accessType) { user.AccessType |= (int)accessType; }
public void Edit(UserExtendedProxy oldExtendedProxy, UserExtendedProxy newExtendedProxy) { SendRequest("EditUser", GetDefaultParameters(), Tuple.Create(oldExtendedProxy, newExtendedProxy).ToJson()); }
public void Add(UserExtendedProxy extendedProxy) { SendRequest("AddUser", GetDefaultParameters(), extendedProxy.ToJson()); }