private static IRestResponse <UserRegistration> testCreateUser(RestClient client, string uuid) { UserRegistration user = new UserRegistration(); user.Email = new Address(); user.Email.Value = "*****@*****.**"; user.Location = new Address(); user.Location.Value = "Kontor 15"; user.Person.Name = "Daniel"; user.Timestamp = DateTime.Now; user.UserId = "dto"; user.Uuid = uuid; BusinessLayer.DTO.V1_1.Position position = new BusinessLayer.DTO.V1_1.Position(); position.Name = "Udvikler"; position.OrgUnitUuid = Guid.NewGuid().ToString().ToLower(); user.Positions.Add(position); var request = new RestRequest("/api/v1_1/user/"); request.Method = Method.POST; request.AddJsonBody(user); request.RequestFormat = DataFormat.Json; return(client.Execute <UserRegistration>(request)); }
private static void testReadUser(RestClient client, string uuid) { UserRegistration user = new UserRegistration(); user.Email.Value = "*****@*****.**"; user.Location.Value = "Kontor 15"; user.Person.Name = "Daniel"; user.Timestamp = DateTime.Now; user.UserId = "dto"; user.Uuid = uuid; BusinessLayer.DTO.V1_1.Position position = new BusinessLayer.DTO.V1_1.Position(); position.Name = "Udvikler"; position.OrgUnitUuid = Guid.NewGuid().ToString().ToLower(); user.Positions.Add(position); // store directly, then use service to read UserService userService = new UserService(); userService.Update(user); var request = new RestRequest("/api/v1_1/user?uuid=" + uuid); request.Method = Method.GET; var response = client.Execute <UserRegistration>(request); UserRegistration responseRegistration = response.Data; if (!user.Email.Value.Equals(responseRegistration.Email.Value)) { throw new Exception("Email mismatch"); } if (!user.Location.Value.Equals(responseRegistration.Location.Value)) { throw new Exception("Location mismatch"); } if (!user.Person.Name.Equals(responseRegistration.Person.Name)) { throw new Exception("Person.Name mismatch"); } if (!user.UserId.Equals(responseRegistration.UserId)) { throw new Exception("UserId mismatch"); } }