Skip to content

Commit

Permalink
Adding end-to-end test
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolins16 committed Dec 4, 2021
1 parent cd55038 commit 20f6981
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand Down Expand Up @@ -106,4 +106,18 @@ public async Task CanUseNonNullableReferenceType_WithController_SubmitData_NoErr
// Redirect means there were no validation errors.
await response.AssertStatusCodeAsync(HttpStatusCode.Redirect);
}

[Fact]
public async Task CanUseNonNullableReferenceType_WithController_DefaultValueParameter_NoError()
{
// Act 1
var response = await Client.GetAsync("http://localhost/api/NonNullable");

// Assert 1
_ = await response.AssertStatusCodeAsync(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();

// Assert 2
Assert.NotNull(content);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable
using Microsoft.AspNetCore.Mvc;

namespace BasicWebSite.Controllers;

#nullable enable

[ApiController]
[Route("api/NonNullable")]
public class NonNullableApiController : ControllerBase
{
// GET: api/<controller>
[HttpGet]
public ActionResult<string> Get(string language = "pt-br")
{
return language;
}
}

#nullable restore

0 comments on commit 20f6981

Please sign in to comment.