public GetUserMock StartServer() { Server = FluentMockServer.Start(new FluentMockServerSettings { Urls = new[] { this._host }, StartAdminInterface = true }); Server.Reset(); ExpectedResponse = new GetUser.Response { UserId = "06e4e0c9-f244-4526-b3fb-01301b9cc4bb", FirstName = "John", LastName = "Smith", Email = "*****@*****.**", SSN = 123121234, Address = "123 Main Street", City = "Atlanta", StateId = 10, Zip = 90024 }; Server.Given(Request.Create().UsingPost().WithPath(this._getUrl()).WithBody(new JsonMatcher( new { UserId = _userId, AccountId = _accountId }))).RespondWith(Response.Create().WithBodyAsJson(ExpectedResponse)); return(this); }
public async Task <ActionResult <GetUser.Response> > GetUser(string id) { GetUser.Request request = new GetUser.Request { SearchOperator = Application.User.GetUser.ISearchOperator.ID, SearchQuery = id }; GetUser.Response response = await new GetUser(_userManager).DoModelAsync(request); if (response.isSucceeded) { return(Ok(response)); } else { return(NoContent()); } }
public async Task <Response> DoModelAsync(Request request) { Response response = new Response(); GetUser.Response userResponse = await new GetUser(_userManager).DoModelAsync(new GetUser.Request { SearchOperator = GetUser.ISearchOperator.ID, SearchQuery = request.UserId }); if (userResponse.isSucceeded) { response.Error = "Email allready exist."; } Database.Entities.Profile.CreatorProfile creator = new Database.Entities.Profile.CreatorProfile { Name = request.CreatorName, OwnerId = request.UserId, Owner = userResponse.User, Description = request.Description }; _context.CreatorProfiles.Add(creator); try { await _context.SaveChangesAsync(); } catch (Exception ex) { response.isSucceeded = false; switch (ex.InnerException.ToString()) { case nameof(DbUpdateException): response.Error = "Database update exception"; break; case nameof(DbUpdateConcurrencyException): response.Error = "Db update concurrency exception"; break; default: response.Error = ex.Message; break; } } return(response); }
public async Task <GetUser.Response> GetUser(GetUser.Request request) { var response = new GetUser.Response { UserId = "06e4e0c9-f244-4526-b3fb-01301b9cc4bb", FirstName = "John", LastName = "Smith", Email = "*****@*****.**", SSN = 123121234, Address = "123 Main Street", City = "Atlanta", StateId = 10, Zip = 90024 }; return(await Task.Run(() => response)); }
public void ShouldBeDeepCompare() { var response = new GetUser.Response { UserId = "06e4e0c9-f244-4526-b3fb-01301b9cc4bb", FirstName = "John", LastName = "Smith", Email = "*****@*****.**", SSN = 123121234, Address = "123 Main Street", City = "Atlanta", StateId = 10, Zip = 90024 }; var user = GetUserMock.WithHost(host); user.WithUserId("06e4e0c9-f244-4526-b3fb-01301b9cc4bb"); user.WithAccountId(1234); user.StartServer(); user.ExpectedResponse.Should().BeEquivalentTo(response); user.StopServer(); }