Found 23 packages
.NET Standard library with some HTTP related functionality.
Simplified RESTful API proxies with built-in secondary proxy. Simplified logging, enabled/disabled during runtime. HTTP methods. Media types. Extensions.
Package Description
Generic Clients, Status Codes and Validators Class
Нужна для удобного возврата результата выполнения методов без использования исключений.
Libary with additional statuscode objects.
use for C# asp.net core web api. include 1.process to standard format result like {statusCode:200,msg:"success",data:"anydatas"} 2.deal with exception to standard result too like {statusCode:500,msg:'object reference of null..etc',data:null} 3.TextJsonConvert,for use System.Text.Json,like "2017" from front-end to back-end int property "Year"
Simple response status code management using FluentResults errors as validation.
Permet de catcher les exceptions non gérées dans les controllers API. Log l'erreur, et retourne un json pré-formatté avec un StatusCode 500.
Moksy is an open source .Net library for stubbing, mocking and simulating web services. Intended to be driven from MsTest (or your favorite testing framework), Moksy will create a real HTTP Server end-point that your system under test or other services can hit. For example: Moksy.Common.Proxy proxy = new Moksy.Common.Proxy(10011); proxy.Start(); var simulation = SimulationFactory.When.I.Get().From("/TheEndpoint").Then.Return.Body("Hello World!").And.StatusCode(System.Net.HttpStatusCode.OK); proxy.Add(simulation); Navigating to http://localhost:10011/TheEndpoint in your browser or hitting that Url from another service will return "Hello World!". This release has a strong focus on testing JSON-based web services.
Microsoft.AspNetCore.Mvc.NewtonsoftJson services.AddControllers().AddNewtonsoftJson(o => o.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); Dotnet controller [FromQuery] ?sort=asc using var transaction = Context.Database.BeginTransaction(); bike.Id = id; var c = await Context.Bikes.FindAsync(id); Context.Bikes.Remove(c); Context.Bikes.Add(bike); await Context.SaveChangesAsync(); await transaction.CommitAsync(); var startedRental = await Context.Rentals.FirstAsync(); startedRental.End = System.DateTime.Now; startedRental.TotalCosts = CostCalculation.CalculateTotalCost(startedRental); startedRental.Customer = await Context.Customers.FindAsync(rental.CustomerID); startedRental.Bike = await Context.Bikes.FindAsync(rental.BikeID); Context.Rentals.Update(startedRental); await Context.SaveChangesAsync(); var result=await unpaid .Include(c => c.Customer) .Select(item => new { item.CustomerID, item.Customer.LastName, item.Customer.FirstName, item.Id, item.Begin, item.End }) .ToListAsync(); return (await dataContext.Deposits.Include("Membership.Member").ToArrayAsync()) .GroupBy(d => new { d.Membership.Begin.Year, d.Membership.Member }) .Select(i => new DepositStatistics { Year = i.Key.Year, Member = i.Key.Member, TotalAmount = i.Sum(d => d.Amount) }); using var transaction = Database.BeginTransaction(); await Database.ExecuteSqlRawAsync("DELETE FROM Taxis"); await Database.ExecuteSqlRawAsync("DELETE FROM Drivers"); await Database.ExecuteSqlRawAsync("DELETE FROM Rides"); await transaction.CommitAsync(); var result = await Rides.Where(e => e.Start.Year == year and e.Start.Month == month).ToListAsync(); var drivers=result.GroupBy(d => d.Driver); var ret=drivers.Select(b => new DriverStatistics { DriverName = b.Key.Name, TotalCharge = b.Sum(d => d.Charge) ?? 0 }); public async Task T> GetFromServiceAsync T>(string path) { var response = await client.GetStringAsync(BASE_URL + path); return JsonSerializer.Deserialize T>(response, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); } public async Task HttpResponseMessage> PostToServiceAsync T>(string path, T payload ) { var body = new StringContent(JsonSerializer.Serialize T>(payload), Encoding.UTF8, "application/json"); var response = await client.PostAsync(BASE_URL + path,body); return response; } WPF GUI BindableBase Customers customers = new Customers(Customer, client); customers.Show(); MainWindow.Close.Execute(); ComboBox ItemsSource="{Binding Taxis}" DisplayMemberPath="LicensePlate" SelectedItem="{Binding SelectedTaxi}" /> UpdateSourceTrigger=PropertyChanged DataGrid Name="TaskTable" ItemsSource="{Binding Tasks}" RowEditEnding="TaskTable_RowEditEnding" AutoGenerateColumns="False" > DataGrid.Columns> DataGridTextColumn Header="TaskId" Binding="{Binding TaskId, UpdateSourceTrigger=LostFocus}"/> public async void TaskTable_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { var task = e.Row.Item as Task; await GetTasks(); if (task != null and task.Name == String.Empty) { var result = await client.DeleteToServiceAsync("Tasks/" + task.TaskId); MessageBox.Show("DELETE" + result.StatusCode.ToString()); } else if (Tasks.Any(b => b.TaskId == task.TaskId)) { var result = await client.PutToServiceAsync("Tasks/" +task.TaskId, task); MessageBox.Show("EDIT" + result.StatusCode.ToString()); } else { var result = await client.PostToServiceAsync("Tasks" , task); MessageBox.Show("ADD" + result.StatusCode.ToString()); } await GetTasks(); }
Staus code filter for Application Insights to record as success instead of failure for Umbraco 8
SMS DLR status code translator - maps operator-specific codes to standardized internal categories with in-memory cache and MongoDB-backed configuration.
*TestBase* gives you a flying start with - fluent assertions that are simple to extend - sharp error messages - tools to help you test with “heavyweight” dependencies on - AspNetCore.Mvc, AspNet.Mvc 3-5, or WebApi Contexts - HttpClient - Ado.Net - Streams & Logging - Mix & match with your favourite test runners & assertions. # TestBase.HttpClient.Fake ``` //Arrange var httpClient = new FakeHttpClient() .SetupGetUrl("https://host.*/").Returns(request=> "Got:" + request.RequestUri) .SetupGetPath("/uri[Pp]attern/").Returns("stringcontent") .SetupPost(".*").Returns(response) .SetupPost(".*", new byte[]{1,2,3}).Returns(otherResponse) .SetupPost(".*", "a=1&b=2") .Returns( request => "You said : " + request.Content.ReadAsStringAsync().ConfigureFalseGetResult(), HttpStatusCode.Accepted) .Setup(x=>x.RequestUri.PathAndQuery.StartsWith("/this")).Returns(response) .Setup(x=>x.Method ==HttpMethod.Put) .Returns(new HttpResponseMessage(HttpStatusCode.Accepted)); // Act var putResponse = await httpClient.PutAsync("http://localhost/thing", new StringContent("{a=1,b=2}")); var postResponse= await httpClient.PostAsync("http://[::1]/", new StringContent("a=1&b=2")); //Debug httpClient.Invocations .ForEach(async i =>Console.WriteLine("{0} {1}",i.RequestUri, await i.Content.ReadAsStringAsync())); //Assert putResponse.StatusCode.ShouldBe(HttpStatusCode.Accepted); postResponse.ShouldBe(response); // ==> SetupPost(".*").Returns(response) was the first // matched setup. Setups are tried in first-to-last order. httpClient.Verify(x=>x.Method ==HttpMethod.Put, "Expected Put, but no matching invocations."); httpClient.Verify( x=>x.Method ==HttpMethod.Post && x.Content.ReadAsStringAsync().ConfigureFalseGetResult()=="a=1&b=2", "Expected Post a=1&b=2"); httpClient.VerifyAll(); // ==> "Exception : 4 unmatched expectations" ``` ### TestBase Chainable fluent assertions get you to the point concisely. ``` UnitUnderTest.Action() .ShouldNotBeNull() .ShouldEqualByValueExceptFor(new {Id=1, Descr=expected}, ignoreList ) .Payload .ShouldMatchIgnoringCase("I expected this") .Should(someOtherPredicate); .ShouldEqualByValue().ShouldEqualByValueExceptFor(...).ShouldEqualByValueOnMembers() work with all kinds of object and collections, and report what differed. string.ShouldMatch(pattern).ShouldNotMatch().ShouldBeEmpty().ShouldNotBeEmpty() .ShouldNotBeNullOrEmptyOrWhiteSpace().ShouldEqualIgnoringCase() .ShouldContain().ShouldStartWith().ShouldEndWith().ShouldBeContainedIn().ShouldBeOneOf().ShouldNotBeOneOf() numeric.ShouldBeBetween().ShouldEqualWithTolerance()....GreaterThan....LessThan...GreaterOrEqualTo ... ienumerable.ShouldAll().ShouldContain().ShouldNotContain().ShouldBeEmpty().ShouldNotBeEmpty() ... stream.ShouldHaveSameStreamContentAs().ShouldContain() value.ShouldBe().ShouldNotBe().ShouldBeOfType().ShouldBeAssignableTo()... .ShouldAll(predicate), .SingleOrAssertFail()... ``` See also - [TestBase](https://www.nuget.org/packages/TestBase) - [TestBase.AspNetCore.Mvc](https://www.nuget.org/packages/TestBase.AspNetCore.Mvc) - [TestBase-Mvc](https://www.nuget.org/packages/TestBase-Mvc) - [TestBase.AdoNet](https://www.nuget.org/packages/TestBase.AdoNet) - [Serilog.Sinks.ListOfString](https://www.nuget.org/packages/Serilog.Sinks.Listofstring) - [Extensions.Logging.ListOfString](https://www.nuget.org/packages/Extensions.Logging.ListOfString)
Provides a centralized and consistent set of core constants for the RA Utilities ecosystem. This includes common response types, HTTP status codes, and default messages to streamline development and reduce magic strings.
This package provides a robust and extensible framework for centralized exception handling in .NET Web APIs. It standardizes error responses using ProblemDetails, supports custom exceptions and includes a flexible status code mapping system. The package integrates seamlessly via middleware and service configuration, making global error handling clean and maintainable.