public async Task F05_02_Update_User_Redis_failed() { // Arrange var fakeRedisRepo = Substitute.For <IRedisUserRepository>(); fakeRedisRepo.Update(null).ReturnsForAnyArgs(_ => throw new Exception()); var serviceImpl = GetServiceImpl(fakeRedisRepo: fakeRedisRepo); var createMessage = CreateUserMessage(); var createdUser = await serviceImpl.Create(createMessage, null); var newEmail = createdUser.Email + ".test"; var newName = createdUser.Name + ".test"; var updateMessage = new UpdateUserMessage { Id = createdUser.Id, Email = newEmail, Name = newName }; // Action var actualResponseCode = (await serviceImpl.Update(updateMessage, null)).Code; var actualUserResponse = await serviceImpl.Get(new QueryUserMessage { Id = createdUser.Id }, null); // Assert Assert.AreEqual(ResponseCode.GeneralError, actualResponseCode); Assert.AreEqual(createMessage.Name, actualUserResponse.Data.Name); Assert.AreEqual(createMessage.Email, actualUserResponse.Data.Email); Assert.IsEmpty(actualUserResponse.Message); await fakeRedisRepo.ReceivedWithAnyArgs(1).Update(null); }
public async Task F05_01_Update_User_Db_failed() { // Arrange var fakeRedisRepo = Substitute.For <IRedisUserRepository>(); var serviceImpl = GetServiceImpl(fakeRedisRepo: fakeRedisRepo); var createMessage = CreateUserMessage(); var createdUser = await serviceImpl.Create(createMessage, null); var newEmail = createdUser.Email + ".test"; var newName = "12345678901234567890123456789012345678901234567890"; // over the field size 40 chars var updateMessage = new UpdateUserMessage { Id = createdUser.Id, Email = newEmail, Name = newName }; // Action var actualResponseCode = (await serviceImpl.Update(updateMessage, null)).Code; var actualUserResponse = await serviceImpl.Get(new QueryUserMessage { Id = createdUser.Id }, null); // Assert Assert.AreEqual(ResponseCode.GeneralError, actualResponseCode); Assert.AreEqual(createMessage.Name, actualUserResponse.Data.Name); Assert.AreEqual(createMessage.Email, actualUserResponse.Data.Email); Assert.IsEmpty(actualUserResponse.Message); await fakeRedisRepo.DidNotReceiveWithAnyArgs().Update(null); }
public async Task F05_00_Update_User() { // Arrange var serviceImpl = GetServiceImpl(); var createMessage = CreateUserMessage(); var createdUser = await serviceImpl.Create(createMessage, null); var newEmail = createdUser.Email + ".test"; var newName = createdUser.Name + ".test"; var updateMessage = new UpdateUserMessage { Id = createdUser.Id, Email = newEmail, Name = newName }; // Action var actualResponseCode = (await serviceImpl.Update(updateMessage, null)).Code; var actualUserResponse = await serviceImpl.Get(new QueryUserMessage { Id = createdUser.Id }, null); // Assert Assert.AreEqual(ResponseCode.Success, actualResponseCode); Assert.AreEqual(newName, actualUserResponse.Data.Name); Assert.AreEqual(newEmail, actualUserResponse.Data.Email); Assert.IsEmpty(actualUserResponse.Message); }
public async Task Test_Update_User() { // Arrange var targetUser = (await GetServiceImpl().GetAll(new Empty(), null)).Value.First(); var newEmail = targetUser.Email + ".test"; var newName = targetUser.Name + ".test"; var updateMessage = new UpdateUserMessage { Id = targetUser.Id, Email = newEmail, Name = newName }; // Action var actualResponseCode = default(ResponseCode); var actualUser = default(User); await RollBackTransactionScope(async (connection, transaction) => { var serviceImpl = GetServiceImpl(connection, transaction); actualResponseCode = (await serviceImpl.Update(updateMessage, null)).Code; actualUser = await serviceImpl.Get(new QueryUserMessage { Id = targetUser.Id }, null); }); // Assert Assert.AreEqual(ResponseCode.Success, actualResponseCode); Assert.AreEqual(newName, actualUser.Name); Assert.AreEqual(newEmail, actualUser.Email); }
// PUT api/values/5 public Dictionary <String, Boolean> Put([FromBody] string guid) { Dictionary <String, Boolean> result = this.GetSimpleSuccessResponse(); try { UpdateUserMessage msg = new UpdateUserMessage(); msg.guid = guid; msg.EnqueueSelfAsMessage(BaseApiController.protectedQueue); } catch (Exception e) { result["success"] = false; // we should be logging these } return(result); }
// GET api/update /* * public IEnumerable<string> Get() * { * return new string[] { "value1", "value2" }; * } * * // GET api/values/5 * public string Get(int id) * { * return "value"; * } */ // PUT api/updateuser public Dictionary <String, String> Post(Dictionary <String, dynamic> dict) { Dictionary <String, String> result = new Dictionary <String, String>(); try { UpdateUserMessage msg = new UpdateUserMessage(); msg.guid = dict["guid"]; msg.EnqueueSelfAsMessage(BaseApiController.protectedQueue); result["success"] = "true"; } catch (Exception e) { result["success"] = "false"; // We should be logging these } return(result); }
/// <summary> /// サーバーのキャラクター情報を更新する /// </summary> void updateServerUser() { // 3フレームごとに座標を同期 if (frameCount_ % 3 == 0) { var msg = new UpdateUserMessage(); var c = FindUser(Player.Niwatori.UserId); c.X = Player.Niwatori.transform.position.x; c.Y = Player.Niwatori.transform.position.z; c.Angle = Player.Niwatori.transform.eulerAngles.y; c.Hp = Player.Niwatori.Hp; c.Power = Player.Niwatori.Power; c.IsDash = Player.Niwatori.IsDash; msg.User = c; Send(Message.UpdateUser, msg); } frameCount_++; }
public override async Task <BaseResponse> Update(UpdateUserMessage message, ServerCallContext context) { var result = new BaseResponse(); try { await _coreService.Update(new UserDto { Id = message.Id, Name = message.Name, Email = message.Email }); result.Code = ResponseCode.Success; } catch (Exception) { result.Code = ResponseCode.GeneralError; } return(result); }
public override void HandleMessage(BrokeredMessage msg) { this.payload = msg.GetBody <UpdateUserMessage>(); DebugLog.Log(String.Format("Got an UpdateUser message, guid: {0}", this.payload.guid)); msg.Complete(); }
public async Task <ResponseBaseModel <string> > UpdateUser([FromBody] UpdateUserMessage request) { var result = await _serviceClient.UpdateAsync(request); return(new ResponseBaseModel <string>((ResponseCode)result.Code, null)); }