Язык программирования C#9 и платформа .NET5 - Троелсен Эндрю
На нашем сайте KnigaRead.com Вы можете абсолютно бесплатно читать книгу онлайн Троелсен Эндрю, "Язык программирования C#9 и платформа .NET5" бесплатно, без регистрации.
namespace AutoLot.Dal.Tests.IntegrationTests
{
[Collection("Integation Tests")]
public class CarTests : BaseTest,
IClassFixture<EnsureAutoLotDatabaseTestFixture>
{
}
}
// CustomerTests.cs
using System.Collections.Generic;
using System;
using System.Linq;
using System.Linq.Expressions;
using AutoLot.Dal.Tests.Base;
using AutoLot.Models.Entities;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace AutoLot.Dal.Tests.IntegrationTests
{
[Collection("Integation Tests")]
public class CustomerTests : BaseTest,
IClassFixture<EnsureAutoLotDatabaseTestFixture>
{
}
}
// MakeTests.cs
using System.Linq;
using AutoLot.Dal.Repos;
using AutoLot.Dal.Repos.Interfaces;
using AutoLot.Dal.Tests.Base;
using AutoLot.Models.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Xunit;
namespace AutoLot.Dal.Tests.IntegrationTests
{
[Collection("Integation Tests")]
public class MakeTests : BaseTest,
IClassFixture<EnsureAutoLotDatabaseTestFixture>
{
}
}
// OrderTests.cs
using System.Linq;
using AutoLot.Dal.Repos;
using AutoLot.Dal.Repos.Interfaces;
using AutoLot.Dal.Tests.Base;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace AutoLot.Dal.Tests.IntegrationTests
{
[Collection("Integation Tests")]
public class OrderTests : BaseTest,
IClassFixture<EnsureAutoLotDatabaseTestFixture>
{
}
}
Добавьте в класс
MakeTests
MakeRepo
readonly
Dispose()
MakeRepo
[Collection("Integration Tests")]
public class MakeTests : BaseTest,
IClassFixture<EnsureAutoLotDatabaseTestFixture>
{
private readonly IMakeRepo _repo;
public MakeTests()
{
_repo = new MakeRepo(Context);
}
public override void Dispose()
{
_repo.Dispose();
}
...
}
Повторите те же действия для класса
OrderTests
OrderRepo
MakeRepo
[Collection("Integration Tests")]
public class OrderTests : BaseTest,
IClassFixture<EnsureAutoLotDatabaseTestFixture>
{
private readonly IOrderRepo _repo;
public OrderTests()
{
_repo = new OrderRepo(Context);
}
public override void Dispose()
{
_repo.Dispose();
}
...
}
Тестовые методы [Fact] и [Theory]
Тестовые методы без параметров называются фактами (и задействуют атрибут
[Fact]
[Theory]
AutoLot.Dal.Tests
SampleTests.cs
using
using Xunit;