Natty
Natty
CC#
Created by Natty on 5/10/2024 in #help
Blazor HubConnectionBuilder Timeouts
This does not seem right to me...
5 replies
CC#
Created by Natty on 5/10/2024 in #help
Blazor HubConnectionBuilder Timeouts
So, intentionally setting the KeepAliveInterval to be longer than the ServerTimeout. If i don't specify the KeepAliveInterval at all, then the server NEVER times out.
5 replies
CC#
Created by Natty on 5/10/2024 in #help
Blazor HubConnectionBuilder Timeouts
Only way I could find to resolve this was by setting in Program.cs
builder.Services.AddSignalR().AddHubOptions<ChatRoomHub>(options =>
{
options.KeepAliveInterval = TimeSpan.FromSeconds(60);
});
builder.Services.AddSignalR().AddHubOptions<ChatRoomHub>(options =>
{
options.KeepAliveInterval = TimeSpan.FromSeconds(60);
});
And in the Hub
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri($"/chatroomhub"))
.WithServerTimeout(TimeSpan.FromSeconds(30))
.Build();
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri($"/chatroomhub"))
.WithServerTimeout(TimeSpan.FromSeconds(30))
.Build();
5 replies
CC#
Created by Natty on 5/10/2024 in #help
Blazor HubConnectionBuilder Timeouts
All I want is for the server to time out, after X seconds of inactivity.
5 replies
CC#
Created by Natty on 12/9/2023 in #help
HTTPS vs HTTP
damn spent all day on this. Got it:
dotnet server.dll --urls "https://localhost:5001"
dotnet server.dll --urls "https://localhost:5001"
4 replies
CC#
Created by Natty on 12/9/2023 in #help
HTTPS vs HTTP
Even specifying with: dotnet server.dll --launch-profile https doesn't change it.
4 replies
CC#
Created by Natty on 12/9/2023 in #help
HTTPS vs HTTP
I don't understand why i go from https and port 5001 in visual studio, to http and port 5000 via publish folder. How can I resolve this?
4 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
I can do more reading on my own, but just if you're interested and still around. No worries.
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Frost, additionally, since you already know my set up, I don't think my Unit tests make sense. For example I am doing:
[Fact]
public async Task GetCitiesAsync_ShouldReturnNull_WhenCityDoesNotExist()
{
// Arrange
var listOfFacilities = new List<Facility>
{
new() { City = "Houston", Name = "Your Safety", PhoneNumber = "360-555-1234", WebsiteUrl = "www.mycool.com"},
new() { City = "Atlanta", Name = "Big Measures", PhoneNumber = "320-555-1111", WebsiteUrl = "www.bigmeasure.com"},
new() { City = "NYC", Name = "Test1", PhoneNumber = "Test1", WebsiteUrl = "Test1" },
new() { City = "NYC", Name = "Test2", PhoneNumber = "Test2", WebsiteUrl = "Test2" }
};

_facilityRepository.GetCitiesAsync(Arg.Is<string>(x => x == "NotACity")).ReturnsForAnyArgs((List<Facility>?)null);

// Act
var result = await _facilityController.GetCitiesAsync("NotACity");

// Assert
Assert.IsType<NotFoundResult>(result);

var notFoundResult = (NotFoundResult)result;
Assert.Equal(404, notFoundResult.StatusCode);
}
[Fact]
public async Task GetCitiesAsync_ShouldReturnNull_WhenCityDoesNotExist()
{
// Arrange
var listOfFacilities = new List<Facility>
{
new() { City = "Houston", Name = "Your Safety", PhoneNumber = "360-555-1234", WebsiteUrl = "www.mycool.com"},
new() { City = "Atlanta", Name = "Big Measures", PhoneNumber = "320-555-1111", WebsiteUrl = "www.bigmeasure.com"},
new() { City = "NYC", Name = "Test1", PhoneNumber = "Test1", WebsiteUrl = "Test1" },
new() { City = "NYC", Name = "Test2", PhoneNumber = "Test2", WebsiteUrl = "Test2" }
};

_facilityRepository.GetCitiesAsync(Arg.Is<string>(x => x == "NotACity")).ReturnsForAnyArgs((List<Facility>?)null);

// Act
var result = await _facilityController.GetCitiesAsync("NotACity");

// Assert
Assert.IsType<NotFoundResult>(result);

var notFoundResult = (NotFoundResult)result;
Assert.Equal(404, notFoundResult.StatusCode);
}
but if i changed this line to: var result = await _facilityController.GetCitiesAsync("NYC"); it still passes, when I would think it shouldn't...
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Cool thanks i think this is good, ill read the link 🙂
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Gotcha, ok. So like an actual "service".
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Will do, thank you!
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Yeah i was quite confused lol. So in a web api project, let's say what I have is the repository layer, what would be an example of service?
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Ok I'll go and rename it all to Repository.
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Ah ok thank you that is helpful.
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Maybe i'm interpreting it wrong then.
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
ok yeah so what that post says
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
But idk
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
This post on SO makes it seem like what I have service is more correct: https://stackoverflow.com/questions/1440096/difference-between-repository-and-service
36 replies
CC#
Created by Natty on 11/25/2023 in #help
Code Review (Web Api)
Ok thank you! Why do some projects have both though? A service layer and a repository layer?
36 replies