This commit is contained in:
Simon Cropp 2024-08-26 20:49:52 +10:00
Родитель 5fd09ef605
Коммит 90d7d5be5e
28 изменённых файлов: 278 добавлений и 269 удалений

Просмотреть файл

@ -292,7 +292,7 @@ public async Task Added()
await using var data = new SampleDbContext(options);
var company = new Company
{
Name = "before"
Name = "company name"
};
data.Add(company);
await Verify(data.ChangeTracker);
@ -334,7 +334,7 @@ public async Task Deleted()
await using var data = new SampleDbContext(options);
data.Add(new Company
{
Name = "before"
Name = "company name"
});
await data.SaveChangesAsync();
@ -378,13 +378,13 @@ public async Task Modified()
await using var data = new SampleDbContext(options);
var company = new Company
{
Name = "before"
Name = "old name"
};
data.Add(company);
await data.SaveChangesAsync();
data.Companies.Single()
.Name = "after";
.Name = "new name";
await Verify(data.ChangeTracker);
}
```
@ -420,17 +420,20 @@ This test:
<a id='snippet-Queryable'></a>
```cs
var queryable = data.Companies
.Where(_ => _.Name == "value");
.Where(_ => _.Name == "company name");
await Verify(queryable);
```
<sup><a href='/src/Verify.EntityFramework.Tests/CoreTests.cs#L314-L320' title='Snippet source file'>snippet source</a> | <a href='#snippet-Queryable' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in the following verified file:
Will result in the following verified files:
### EF Core
#### CoreTests.Queryable.verified.txt
<!-- snippet: CoreTests.Queryable.verified.txt -->
<a id='snippet-CoreTests.Queryable.verified.txt'></a>
```txt
@ -443,6 +446,9 @@ Will result in the following verified file:
<sup><a href='/src/Verify.EntityFramework.Tests/CoreTests.Queryable.verified.txt#L1-L5' title='Snippet source file'>snippet source</a> | <a href='#snippet-CoreTests.Queryable.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
#### CoreTests.Queryable.verified.sql
<!-- snippet: CoreTests.Queryable.verified.sql -->
<a id='snippet-CoreTests.Queryable.verified.sql'></a>
```sql
@ -456,6 +462,9 @@ WHERE [c].[Content] = N'value'
### EF Classic
#### ClassicTests.Queryable.verified.txt
<!-- snippet: ClassicTests.Queryable.verified.txt -->
<a id='snippet-ClassicTests.Queryable.verified.txt'></a>
```txt

Просмотреть файл

@ -2,7 +2,7 @@
Added: {
Company: {
Id: 0,
Content: before
Name: company name
}
}
}

Просмотреть файл

@ -2,42 +2,42 @@
{
$type: Company,
Id: 1,
Content: Company1
Name: Company1
},
{
$type: Company,
Id: 4,
Content: Company2
Name: Company2
},
{
$type: Company,
Id: 6,
Content: Company3
Name: Company3
},
{
$type: Company,
Id: 7,
Content: Company4
Name: Company4
},
{
$type: Employee,
Id: 2,
CompanyId: 1,
Content: Employee1,
Name: Employee1,
Age: 25
},
{
$type: Employee,
Id: 3,
CompanyId: 1,
Content: Employee2,
Name: Employee2,
Age: 31
},
{
$type: Employee,
Id: 5,
CompanyId: 4,
Content: Employee4,
Name: Employee4,
Age: 34
}
]

Просмотреть файл

@ -1,3 +1,3 @@
{
Content: employee
Name: employee
}

Просмотреть файл

@ -1,3 +1,3 @@
{
Content: employee
Name: employee
}

Просмотреть файл

@ -3,6 +3,6 @@
Message:
SelectExpression must have at least one ordering.
Expression:
SELECT c.Id, c.Content
SELECT c.Id, c.Name
FROM Companies AS c
}

Просмотреть файл

@ -2,9 +2,9 @@
Modified: {
Company: {
Id: 0,
Content: {
Original: before,
Current: after
Name: {
Original: old name,
Current: new name
}
}
}

Просмотреть файл

@ -5,21 +5,21 @@
HasTransaction: false,
Parameters: {
@p0 (Int32): 0,
@p1 (String?): Title
@p1 (String): Title
},
Text:
SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
INSERT INTO [Companies] ([Id], [Content])
INSERT INTO [Companies] ([Id], [Name])
VALUES (@p0, @p1);
},
{
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT [c].[Id], [c].[Content]
SELECT [c].[Id], [c].[Name]
FROM [Companies] AS [c]
WHERE [c].[Content] = N'Title'
WHERE [c].[Name] = N'Title'
}
]
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,12 +1,12 @@
{
queryable: {
Sql:
SELECT [c].[Id], [c].[Content]
SELECT [c].[Id], [c].[Name]
FROM [Companies] AS [c]
WHERE [c].[Content] = N'value',
WHERE [c].[Name] = N'value',
Result: [
{
Content: value
Name: value
}
]
}

Просмотреть файл

@ -4,12 +4,12 @@
HasTransaction: false,
Parameters: {
@p0 (Int32): 0,
@p1 (String?): Guid_1
@p1 (String): Guid_1
},
Text:
SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
INSERT INTO [Companies] ([Id], [Content])
INSERT INTO [Companies] ([Id], [Name])
VALUES (@p0, @p1);
}
}

Просмотреть файл

@ -1,3 +1,3 @@
SELECT [c].[Id], [c].[Content]
SELECT [c].[Id], [c].[Name]
FROM [Companies] AS [c]
WHERE [c].[Content] = N'value'
WHERE [c].[Name] = N'company name'

Просмотреть файл

@ -1,5 +1,5 @@
[
{
Content: value
Name: company name
}
]

Просмотреть файл

@ -3,8 +3,8 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT [c].[Id], [c].[Content]
SELECT [c].[Id], [c].[Name]
FROM [Companies] AS [c]
WHERE [c].[Content] = N'Title'
WHERE [c].[Name] = N'Title'
}
}

Просмотреть файл

@ -6,9 +6,9 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT [c].[Id], [c].[Content]
SELECT [c].[Id], [c].[Name]
FROM [Companies] AS [c]
WHERE [c].[Content] = N'Title'
WHERE [c].[Name] = N'Title'
}
}
]

Просмотреть файл

@ -3,8 +3,8 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT [c].[Id], [c].[Content]
SELECT [c].[Id], [c].[Name]
FROM [Companies] AS [c]
WHERE [c].[Content] = N'Title'
WHERE [c].[Name] = N'Title'
}
}

Просмотреть файл

@ -6,7 +6,7 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT "c"."Id", "c"."Content"
SELECT "c"."Id", "c"."Name"
FROM "Companies" AS "c"
}
}

Просмотреть файл

@ -6,7 +6,7 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT "c"."Id", "c"."Content"
SELECT "c"."Id", "c"."Name"
FROM "Companies" AS "c"
}
}

Просмотреть файл

@ -6,7 +6,7 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT "c"."Id", "c"."Content"
SELECT "c"."Id", "c"."Name"
FROM "Companies" AS "c"
}
}

Просмотреть файл

@ -6,7 +6,7 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT "c"."Id", "c"."Content"
SELECT "c"."Id", "c"."Name"
FROM "Companies" AS "c"
}
}

Просмотреть файл

@ -6,7 +6,7 @@
Type: ReaderExecutedAsync,
HasTransaction: false,
Text:
SELECT "c"."Id", "c"."Content"
SELECT "c"."Id", "c"."Name"
FROM "Companies" AS "c"
}
}

Просмотреть файл

@ -1,4 +1,4 @@
{
Id: 1,
Content: Company1
Name: Company1
}

Просмотреть файл

@ -2,7 +2,7 @@
Modified: {
Employee: {
Id: 0,
Content: {
Name: {
Original: before,
Current: after
}

Просмотреть файл

@ -2,7 +2,7 @@
Modified: {
Employee: {
Id: 0,
Content: {
Name: {
Original: before,
Current: after
}

Просмотреть файл

@ -2,14 +2,14 @@
Modified: {
Company: {
Id: 0,
Content: {
Name: {
Original: companyBefore,
Current: companyAfter
}
},
Employee: {
Id: 0,
Content: {
Name: {
Original: employeeBefore,
Current: employeeAfter
}

Просмотреть файл

@ -1,40 +1,40 @@
[
{
Id: 1,
Content: Company1,
Name: Company1,
Employees: [
{
Id: 2,
CompanyId: 1,
Content: Employee1,
Name: Employee1,
Age: 25
},
{
Id: 3,
CompanyId: 1,
Content: Employee2,
Name: Employee2,
Age: 31
}
]
},
{
Id: 4,
Content: Company2,
Name: Company2,
Employees: [
{
Id: 5,
CompanyId: 4,
Content: Employee4,
Name: Employee4,
Age: 34
}
]
},
{
Id: 6,
Content: Company3
Name: Company3
},
{
Id: 7,
Content: Company4
Name: Company4
}
]

Просмотреть файл

@ -1,18 +1,18 @@
[
{
Id: 1,
Content: Company1
Name: Company1
},
{
Id: 4,
Content: Company2
Name: Company2
},
{
Id: 6,
Content: Company3
Name: Company3
},
{
Id: 7,
Content: Company4
Name: Company4
}
]

Просмотреть файл

@ -67,7 +67,7 @@ public class CoreTests
await using var data = new SampleDbContext(options);
var company = new Company
{
Name = "before"
Name = "company name"
};
data.Add(company);
await Verify(data.ChangeTracker);
@ -85,7 +85,7 @@ public class CoreTests
await using var data = new SampleDbContext(options);
data.Add(new Company
{
Name = "before"
Name = "company name"
});
await data.SaveChangesAsync();
@ -106,13 +106,13 @@ public class CoreTests
await using var data = new SampleDbContext(options);
var company = new Company
{
Name = "before"
Name = "old name"
};
data.Add(company);
await data.SaveChangesAsync();
data.Companies.Single()
.Name = "after";
.Name = "new name";
await Verify(data.ChangeTracker);
}
@ -307,14 +307,14 @@ public class CoreTests
await database.AddData(
new Company
{
Name = "value"
Name = "company name"
});
var data = database.Context;
#region Queryable
var queryable = data.Companies
.Where(_ => _.Name == "value");
.Where(_ => _.Name == "company name");
await Verify(queryable);
#endregion