Skip to content

Commit

Permalink
Update packages and add test related to json store fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ttu committed Jan 30, 2019
1 parent ab00849 commit eec82dc
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* ADDED: Support for paging with page and per_page
* ADDED: User defined location for the static files (including SPAs)
* ADDED: Console parameter for help and version

* FIXED: Adding to the empty collection will use the value of the id-field if it is set

### [0.8.0] - 2018-10-14
* Release as a dotnet tool
* Use executable location as a base path for settings files
Expand Down
2 changes: 1 addition & 1 deletion FakeServer.Test/FakeServer.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="JsonFlatFileDataStore" Version="2.0.1" />
<PackageReference Include="JsonFlatFileDataStore" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="WebSocket4Net" Version="0.15.2" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
41 changes: 40 additions & 1 deletion FakeServer.Test/FakeServerSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,46 @@ public async Task PostAndDeleteItem_NewCollection()
{
using (var client = new HttpClient())
{
var newUser = new { id = 1, name = "Newton" };
var newUser = new { id = 256, name = "Newton" };

var result = await client.GetAsync($"{_fixture.BaseUrl}/api/");
result.EnsureSuccessStatusCode();
var collections = JsonConvert.DeserializeObject<IEnumerable<string>>(await result.Content.ReadAsStringAsync());
var originalAmount = collections.Count();

var content = new StringContent(JsonConvert.SerializeObject(newUser), Encoding.UTF8, "application/json");
result = await client.PostAsync($"{_fixture.BaseUrl}/api/hello", content);
result.EnsureSuccessStatusCode();

result = await client.GetAsync($"{_fixture.BaseUrl}/api");
result.EnsureSuccessStatusCode();
collections = JsonConvert.DeserializeObject<IEnumerable<string>>(await result.Content.ReadAsStringAsync());
Assert.Equal(originalAmount + 1, collections.Count());

result = await client.GetAsync($"{_fixture.BaseUrl}/api/hello/256");
result.EnsureSuccessStatusCode();
var item = JsonConvert.DeserializeObject<JObject>(await result.Content.ReadAsStringAsync());
Assert.Equal(newUser.name, item["name"].Value<string>());

result = await client.GetAsync($"{_fixture.BaseUrl}/api/hello");
result.EnsureSuccessStatusCode();
var items = JsonConvert.DeserializeObject<IEnumerable<JObject>>(await result.Content.ReadAsStringAsync());
Assert.Single(items);

result = await client.DeleteAsync($"{_fixture.BaseUrl}/api/hello/256");
result.EnsureSuccessStatusCode();

result = await client.GetAsync($"{_fixture.BaseUrl}/api/hello");
Assert.Equal(HttpStatusCode.NotFound, result.StatusCode);
}
}

[Fact]
public async Task PostAndDeleteItem_NewCollection_NoId()
{
using (var client = new HttpClient())
{
var newUser = new { name = "Newton" };

var result = await client.GetAsync($"{_fixture.BaseUrl}/api/");
result.EnsureSuccessStatusCode();
Expand Down
6 changes: 3 additions & 3 deletions FakeServer/FakeServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="JsonFlatFileDataStore" Version="2.0.1" />
<PackageReference Include="JsonFlatFileDataStore" Version="2.1.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.5.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
Expand All @@ -42,15 +42,15 @@
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.9" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.9.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ Headers:
Location=http://localhost:57602/api/users/6
```

If collection is empty and new item has an _id-field_ set, it will be used a first _id-value_. If _id-field_ is not set, _id-value_ will start from `0`.
#### Replace item

```
Expand Down

0 comments on commit eec82dc

Please sign in to comment.