public void GivenAnAuthorizedRequestForAnUnderwtiter() { _role = new Role() { Name = "Underwriter" }; var client = new HttpRequestWrapper("http://*****:*****@test.com", BirthDate = DateTime.Now, Role = _role.Name }; client = new HttpRequestWrapper("http://localhost:55112/Users/CreateUserRole", Method.POST); client.Execute(_user); }
public void GivenICreateANewProperty(int principal, int percentageRate, int years) { var _header = new Dictionary <string, string>(); _header.Add("ApiKey", "100"); _property = new CalculationProperty() { Principal = principal, PercentageRate = percentageRate, Years = years }; var _request = new HttpRequestWrapper() .AddHeaders(_header) .SetMethod(Method.POST) .SetResourse("/api/calculations/calculateTotalAmount") .AddJsonContent(_property); _restResponse = new RestResponse(); _restResponse = _request.Execute(); _statusCode = _restResponse.StatusCode; ScenarioContext.Current.Add("StatusCode", _statusCode); ScenarioContext.Current.Add("Content", _restResponse.Content); ScenarioContext.Current.Add("Prop", _property); }
public void GivenICreateCalculationPropertyWithUnathorizedApiKey() { var _header = new Dictionary <string, string>(); _header.Add("ApiKey", "99"); _property = new CalculationProperty() { Principal = 1000, PercentageRate = 2, Years = 5 }; var _request = new HttpRequestWrapper() .AddHeaders(_header) .SetMethod(Method.POST) .SetResourse("/api/calculations/calculateTotalAmount") .AddJsonContent(_property); _restResponse = new RestResponse(); _restResponse = _request.Execute(); _statusCode = _restResponse.StatusCode; ScenarioContext.Current.Add("StatusCode", _statusCode); }
public void WhenISearchWithNotExistingBookWithTerm(string param, string searchTerm) { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResource("api/books?").AddParameter($"{param}=", searchTerm); _restResponse = request.Execute(); }
public void WhenIRequestToViewAllLoans() { var resourceServer = ConfigurationManager.AppSettings["ResourceServer"]; _wrapper = new HttpRequestWrapper(_restSharpComponent, string.Format("{0}api/loans", resourceServer), Method.GET); _loans = _wrapper.Execute <List <Loan> >(); }
public void UpdateProperty(Property property) { var request = new HttpRequestWrapper() .SetMethod(Method.PUT) .SetResourse("/api/properties/") .AddJsonContent(property); var response = request.Execute(); }
public void DeleteProperty(int id) { var request = new HttpRequestWrapper() .SetMethod(Method.DELETE) .SetResourse("/api/properties/") .AddParameter("id", id); var response = request.Execute(); }
public void WhenIRequestTheSameProperty() { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResourse("/api/properties/") .AddParameter("id", _property.Id); _properties = new List <Property>(); _properties = request.Execute <List <Property> >(); }
public void WhenTheLoginRequestSend() { var request = new HttpRequestWrapper() .SetMethod(Method.POST) .SetResourse("/Login") .AddJsonContent(user); _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; }
public void WhenIDeleteAProperty() { _property = ScenarioContext.Current.Get <Property>("Pro"); var request = new HttpRequestWrapper() .SetMethod(Method.DELETE) .SetResourse("/api/properties/") .AddParameter("id", _property.Id); var response = request.Execute(); }
public IRestResponse PostAssignmentProvider(AssignmentProvider provider) { var accept_request = new HttpRequestWrapper(_baseUrlAssignmentApi, _useLocalProxy, _bearerToken) .SetMethod(Method.POST) .SetResourse($"/providers") .AddJsonContent(new List <AssignmentProvider>() { provider }); return(accept_request.Execute()); }
public void GivenICreateANewProperty() { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResourse("/api/health"); _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; ScenarioContext.Current.Add("StatusCode", _statusCode); }
public void WhenINeedAllVotersList() { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResourse("/elections/getvoters"); _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; _voters = JsonConvert.DeserializeObject <List <Voters> >(_restResponse.Content); }
public void WhenIAddAVoter() { var request = new HttpRequestWrapper() .SetMethod(Method.POST) .SetResourse("/elections/AddVoter") .AddJsonContent(_voter); _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; }
public void WhenITryToAccessTheBookBy(string p0) { var bookToAcc = ScenarioContext.Current.Get <Book>("Book"); var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResource("api/books").AddParameter("id", bookToAcc.Id); _restResponse = request.Execute(); ScenarioContext.Current.Remove("srvResponse"); ScenarioContext.Current.Add("srvResponse", _restResponse); }
public void WhenIUpdateAnExistingProperty(string newAddress, decimal newPrice) { _property.Address = newAddress; _property.Price = newPrice; var request = new HttpRequestWrapper() .SetMethod(Method.PUT) .SetResourse("/api/properties/") .AddJsonContent(_property); //_restResponse = new RestResponse(); var response = request.Execute(); }
public void WhenISearchForABookWith(string param, string searchTerm) { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResource("api/books?").AddParameter($"{param}=", searchTerm); _restResponse = request.Execute(); if (_restResponse.Content.Length > 0) { ScenarioContext.Current.Add("NotEmpty", _restResponse.Content); } }
public void WhenTheLoginRequestSend() { var request = new HttpRequestWrapper() .SetMethod(Method.POST) .SetResourse("/Login") .AddParameterWithoutObject(user) ; _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; userResponse = JsonConvert.DeserializeObject <LoginUserDto>(_restResponse.Content); }
public void GivenAVoterId(long id) { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResourse("/elections/GetVoter") .AddParameter("id", id); _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; _voter = JsonConvert.DeserializeObject <Voters>(_restResponse.Content); }
public void GivenIDeleteABookWith() { var bookDel = ScenarioContext.Current.Get <Book>("Book"); var request = new HttpRequestWrapper() .SetMethod(Method.DELETE) .SetResource("api/books").AddParameter("id", bookDel.Id); _restResponse = request.Execute(); ScenarioContext.Current.Remove("srvResponse"); ScenarioContext.Current.Add("srvResponse", _restResponse); }
public void WhenTheStudentOfThatIdGetAndRequestToDeleteRecordMade() { Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("Authorization", "bearer " + _Token); var Request = new HttpRequestWrapper() .SetMethod(Method.DELETE) .AddHeaders(header) .SetResourse("/api/Student/?id=" + _id); _restResponse = new RestResponse(); _restResponse = Request.Execute(); }
public void WhenTheRequestToEditRecordMade() { Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("Authorization", "bearer " + _Token); var Request = new HttpRequestWrapper() .SetMethod(Method.PUT) .AddHeaders(header) .SetResourse("/api/Student") .AddJsonContent(model); _restResponse = new RestResponse(); _restResponse = Request.Execute(); }
public IList <Property> GetPaginatedProperties(int page, int pageSize) { var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResourse("/api/properties/") .AddParameters(new Dictionary <string, object>() { { "page", page }, { "pageSize", pageSize } }); var properties = request.Execute <List <Property> >(); return(properties); }
public void GivenTheUserIsLogin() { user.Add("username", "b761"); user.Add("password", "761"); user.Add("grant_type", "password"); var request = new HttpRequestWrapper() .SetMethod(Method.POST) .SetResourse("/Login") .AddParameterWithoutObject(user); _restResponse = new RestResponse(); _restResponse = request.Execute(); _userResponseDto = JsonConvert.DeserializeObject <LoginUserDto>(_restResponse.Content); _Token = _userResponseDto.access_token; Assert.AreEqual(_userResponseDto.token_type, "bearer"); }
public Account CreateCustomer(Customer customer) { //username & password will be both retrieved by login process _restSharpComponent.TokenizeRequest(new User() { username="******", password ="******", grant_type ="password" }); _wrapper = new HttpRequestWrapper(_restSharpComponent, "http://localhost:51313/api/customers", Method.POST); var serializedRequest = JsonConvert.SerializeObject(customer); _wrapper.Post(serializedRequest); var account = _wrapper.Execute<Account>(); return account; }
public void GivenICreateANewBookWithParameters(int Id, string Author, string Title, string Description, bool iterate) { var book = new Book() { Id = Id, Author = Author, Title = Title, Description = Description }; var request = new HttpRequestWrapper() .SetMethod(Method.POST) .SetResource("api/books") .AddJsonContent(book); _restResponse = request.Execute(); }
public void GivenAnAuthorizedRequest() { _user = new ApplicationUser() { Username = "******", Password = "******", FirstName = "Oscar", LastName = "Maddison", Email = "*****@*****.**", BirthDate = DateTime.Now }; var client = new HttpRequestWrapper("http://localhost:55112/Users/CreateAsync", Method.POST); client.Execute(_user); }
public void GivenWillAddNewStudentDetailsCallToAddStudent(string name) { var obj = new { username = "******", password = "******", grant_type = "password" }; var request = new HttpRequestWrapper() .SetMethod(Method.POST) .SetResourse("/Login") .AddJsonContent(obj); _restResponse = new RestResponse(); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; _userResponseDto = JsonConvert.DeserializeObject <LoginUserDto>(_restResponse.Content); _Token = _userResponseDto.access_token; Assert.AreEqual(_userResponseDto.token_type, "bearer"); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("Authorization", "bearer " + _Token); AddEditStudentDto student = new AddEditStudentDto(); student.Name = name; student.FName = "testfather"; student.Email = "*****@*****.**"; student.Dob = "11/11/1995"; List <int> courses = new List <int>(); courses.Add(1); courses.Add(2); courses.Add(3); student.Courses = courses; var Request = new HttpRequestWrapper() .SetMethod(Method.POST) .AddHeaders(header) .SetResourse("/api/Student") .AddJsonContent(student); _restResponse = new RestResponse(); _restResponse = Request.Execute(); _statusCode = _restResponse.StatusCode; _studentDtoResp = JsonConvert.DeserializeObject <StudentDtoResponse>(_restResponse.Content); Assert.AreEqual(_studentDtoResp.result, true); }
public void WhenIRequestToViewProperties() { var header = _restResponse.Headers.Where(x => x.Name == "ETag").First().Value; var request = new HttpRequestWrapper() .SetMethod(Method.GET) .SetResourse("/api/properties/") .AddEtagHeader(header.ToString()) .AddParameters(new Dictionary <string, object>() { { "page", 1 }, { "pageSize", 11 } }); _restResponse = request.Execute(); _statusCode = _restResponse.StatusCode; _properties = JsonConvert.DeserializeObject <List <Property> >(_restResponse.Content); }
public void GivenTheIdOfStudentToDeleteIs(int Id) { Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("Authorization", "bearer " + _Token); _id = Id; var Request = new HttpRequestWrapper() .SetMethod(Method.GET) .AddHeaders(header) .SetResourse("/api/Student/?id=" + _id); _restResponse = new RestResponse(); _restResponse = Request.Execute(); model = JsonConvert.DeserializeObject <AddEditStudentDto>(_restResponse.Content); Assert.AreEqual(HttpStatusCode.OK, _restResponse.StatusCode); Assert.AreNotEqual(model, null, "This Record Does Not exist in Database Change Id Please And Try Again This Test"); }
public void CleanUp() { //Delete user var client = new HttpRequestWrapper("http://localhost:55112/Users/Get", Method.GET).AddParameter("email", _user.Email); _response = client.Execute(null); var user = JsonConvert.DeserializeObject <ApplicationUser>(_response.Content); client = new HttpRequestWrapper("http://localhost:55112/Users/Delete", Method.DELETE).AddParameter("id", user.Id); client.Execute(null); //Delete Role client = new HttpRequestWrapper("http://localhost:55112/Roles/Get", Method.GET).AddParameter("id", _role.Id); _response = client.Execute(null); var role = JsonConvert.DeserializeObject <Role>(_response.Content); client = new HttpRequestWrapper("http://localhost:55112/Roles/Delete", Method.DELETE).AddParameter("id", role.Id); client.Execute(null); }
public void WhenIRequestToViewAllLoans() { var resourceServer = ConfigurationManager.AppSettings["ResourceServer"]; _wrapper = new HttpRequestWrapper(_restSharpComponent, string.Format("{0}api/loans", resourceServer), Method.GET); _loans = _wrapper.Execute<List<Loan>>(); }