Shady nagy/net6 (#614)

* udated to .net6

* used the .net6 version RC2

* added editconfig.

* App core new Scoped Namespaces style.

* BlazorAdmin new Scoped Namespaces style.

* Blazor Shared new Scoped Namespaces style.

* Infra new Scoped Namespaces style.

* public api new Scoped Namespaces style.

* web new Scoped Namespaces style.

* FunctionalTests new Scoped Namespaces style.

* Integrational tests new Scoped Namespaces style.

* unit tests new Scoped Namespaces style.

* update github action.

* update github action.

* change the global.
This commit is contained in:
Shady Nagy
2021-11-06 01:55:48 +02:00
committed by GitHub
parent 64f150dc07
commit 9db2feb930
252 changed files with 6307 additions and 6413 deletions

View File

@@ -1,70 +1,69 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.eShopWeb.FunctionalTests.Web;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.eShopWeb.FunctionalTests.Web;
using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages
namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages;
[Collection("Sequential")]
public class BasketPageCheckout : IClassFixture<WebTestFixture>
{
[Collection("Sequential")]
public class BasketPageCheckout : IClassFixture<WebTestFixture>
public BasketPageCheckout(WebTestFixture factory)
{
public BasketPageCheckout(WebTestFixture factory)
Client = factory.CreateClient(new WebApplicationFactoryClientOptions
{
Client = factory.CreateClient(new WebApplicationFactoryClientOptions
{
AllowAutoRedirect = true
});
}
AllowAutoRedirect = true
});
}
public HttpClient Client { get; }
public HttpClient Client { get; }
private string GetRequestVerificationToken(string input)
{
string regexpression = @"name=""__RequestVerificationToken"" type=""hidden"" value=""([-A-Za-z0-9+=/\\_]+?)""";
var regex = new Regex(regexpression);
var match = regex.Match(input);
return match.Groups.Values.LastOrDefault().Value;
}
private string GetRequestVerificationToken(string input)
{
string regexpression = @"name=""__RequestVerificationToken"" type=""hidden"" value=""([-A-Za-z0-9+=/\\_]+?)""";
var regex = new Regex(regexpression);
var match = regex.Match(input);
return match.Groups.Values.LastOrDefault().Value;
}
[Fact]
public async Task RedirectsToLoginIfNotAuthenticated()
{
// Arrange & Act
[Fact]
public async Task RedirectsToLoginIfNotAuthenticated()
{
// Arrange & Act
// Load Home Page
var response = await Client.GetAsync("/");
response.EnsureSuccessStatusCode();
var stringResponse1 = await response.Content.ReadAsStringAsync();
// Load Home Page
var response = await Client.GetAsync("/");
response.EnsureSuccessStatusCode();
var stringResponse1 = await response.Content.ReadAsStringAsync();
string token = GetRequestVerificationToken(stringResponse1);
string token = GetRequestVerificationToken(stringResponse1);
// Add Item to Cart
var keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add(new KeyValuePair<string, string>("id", "2"));
keyValues.Add(new KeyValuePair<string, string>("name", "shirt"));
// Add Item to Cart
var keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add(new KeyValuePair<string, string>("id", "2"));
keyValues.Add(new KeyValuePair<string, string>("name", "shirt"));
keyValues.Add(new KeyValuePair<string, string>("price", "19.49"));
keyValues.Add(new KeyValuePair<string, string>("__RequestVerificationToken", token));
keyValues.Add(new KeyValuePair<string, string>("price", "19.49"));
keyValues.Add(new KeyValuePair<string, string>("__RequestVerificationToken", token));
var formContent = new FormUrlEncodedContent(keyValues);
var formContent = new FormUrlEncodedContent(keyValues);
var postResponse = await Client.PostAsync("/basket/index", formContent);
postResponse.EnsureSuccessStatusCode();
var stringResponse = await postResponse.Content.ReadAsStringAsync();
var postResponse = await Client.PostAsync("/basket/index", formContent);
postResponse.EnsureSuccessStatusCode();
var stringResponse = await postResponse.Content.ReadAsStringAsync();
// Assert
Assert.Contains(".NET Black &amp; White Mug", stringResponse);
// Assert
Assert.Contains(".NET Black &amp; White Mug", stringResponse);
keyValues.Clear();
keyValues.Add(new KeyValuePair<string, string>("__RequestVerificationToken", token));
keyValues.Clear();
keyValues.Add(new KeyValuePair<string, string>("__RequestVerificationToken", token));
formContent = new FormUrlEncodedContent(keyValues);
var postResponse2 = await Client.PostAsync("/Basket/Checkout", formContent);
Assert.Contains("/Identity/Account/Login", postResponse2.RequestMessage.RequestUri.ToString());
}
formContent = new FormUrlEncodedContent(keyValues);
var postResponse2 = await Client.PostAsync("/Basket/Checkout", formContent);
Assert.Contains("/Identity/Account/Login", postResponse2.RequestMessage.RequestUri.ToString());
}
}