Add new tests, improvments
This commit is contained in:
parent
1c666c7ac7
commit
f55f12dfd0
|
|
@ -10,8 +10,13 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
[TestClass]
|
||||
public sealed class FruitBankClientTests
|
||||
{
|
||||
private const string Fixture = "_test.temp";
|
||||
|
||||
private FruitBankSignalRClient _signalRClient = null!;
|
||||
|
||||
private static string GetFixtureName(string name) => $"{GetOriginalName(name)}{Fixture}";
|
||||
private static string GetOriginalName(string name) => name.Replace(Fixture, string.Empty);
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInit()
|
||||
{
|
||||
|
|
@ -30,7 +35,7 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
var partners = await _signalRClient.GetPartners();
|
||||
|
||||
Assert.IsNotNull(partners);
|
||||
Assert.IsTrue(partners.Any());
|
||||
Assert.IsTrue(partners.Count != 0);
|
||||
}
|
||||
|
||||
//[DataTestMethod]
|
||||
|
|
@ -51,8 +56,7 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
{
|
||||
var partner = await GetPartnerByIdTest(partnerId);
|
||||
|
||||
const string fixture = "_test.temp";
|
||||
var newName = $"{partner.Name.Replace(fixture, string.Empty)}{fixture}";
|
||||
var newName = GetFixtureName(partner.Name);
|
||||
|
||||
partner.Name = newName;
|
||||
await _signalRClient.UpdatePartner(partner);
|
||||
|
|
@ -60,10 +64,9 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
partner = await GetPartnerByIdTest(partnerId);
|
||||
Assert.IsTrue(partner.Name == newName);
|
||||
|
||||
partner.Name = partner.Name.Replace(fixture, string.Empty);
|
||||
partner.Name = GetOriginalName(partner.Name);
|
||||
await _signalRClient.UpdatePartner(partner);
|
||||
}
|
||||
|
||||
#endregion Partner
|
||||
|
||||
#region Shipping
|
||||
|
|
@ -86,9 +89,9 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
Assert.IsTrue(shippings.All(s => !s.IsAllMeasured));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public async Task GetShippingByIdTest(int shippingId)
|
||||
//[TestMethod]
|
||||
//[DataRow(1)]
|
||||
public async Task<Shipping> GetShippingByIdTest(int shippingId)
|
||||
{
|
||||
var shipping = await _signalRClient.GetShippingById(shippingId);
|
||||
|
||||
|
|
@ -98,6 +101,25 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
Assert.IsTrue(shipping.Id == shippingId);
|
||||
Assert.IsTrue(shipping.ShippingDocuments.All(s => s.ShippingId == shippingId));
|
||||
Assert.IsTrue(shipping.ShippingDocuments.All(sd => sd.ShippingItems != null && sd.ShippingItems.Any(si => si.ShippingDocumentId == sd.Id)));
|
||||
|
||||
return shipping;
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(1)]
|
||||
public async Task UpdateShippingTest(int shippingId)
|
||||
{
|
||||
var shipping = await GetShippingByIdTest(shippingId);
|
||||
var newLicencePlate = GetFixtureName(shipping.LicencePlate);
|
||||
|
||||
shipping.LicencePlate = newLicencePlate;
|
||||
await _signalRClient.UpdateShipping(shipping);
|
||||
|
||||
shipping = await GetShippingByIdTest(shippingId);
|
||||
Assert.IsTrue(shipping.LicencePlate == newLicencePlate);
|
||||
|
||||
shipping.LicencePlate = GetOriginalName(shipping.LicencePlate);
|
||||
await _signalRClient.UpdateShipping(shipping);
|
||||
}
|
||||
|
||||
#endregion Shipping
|
||||
|
|
@ -113,14 +135,33 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
Assert.IsTrue(shippingItems.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public async Task GetShippingItemByIdTest(int shippingItemeId)
|
||||
//[TestMethod]
|
||||
//[DataRow(1)]
|
||||
public async Task<ShippingItem> GetShippingItemByIdTest(int shippingItemeId)
|
||||
{
|
||||
var shippingItem = await _signalRClient.GetShippingItemById(shippingItemeId);
|
||||
|
||||
Assert.IsNotNull(shippingItem);
|
||||
Assert.IsTrue(shippingItem.Id == shippingItemeId);
|
||||
|
||||
return shippingItem;
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(1)]
|
||||
public async Task UpdateShippingItemTest(int shippingItemId)
|
||||
{
|
||||
var shippingItem = await GetShippingItemByIdTest(shippingItemId);
|
||||
var newName = GetFixtureName(shippingItem.Name);
|
||||
|
||||
shippingItem.Name = newName;
|
||||
await _signalRClient.UpdateShippingItem(shippingItem);
|
||||
|
||||
shippingItem = await GetShippingItemByIdTest(shippingItemId);
|
||||
Assert.IsTrue(shippingItem.Name == newName);
|
||||
|
||||
shippingItem.Name = GetOriginalName(shippingItem.Name);
|
||||
await _signalRClient.UpdateShippingItem(shippingItem);
|
||||
}
|
||||
|
||||
#endregion ShippingItem
|
||||
|
|
@ -133,17 +174,36 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
var shippingDocuments = await _signalRClient.GetShippingDocuments();
|
||||
|
||||
Assert.IsNotNull(shippingDocuments);
|
||||
Assert.IsTrue(shippingDocuments.Any());
|
||||
Assert.IsTrue(shippingDocuments.Count != 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(2)]
|
||||
public async Task GetShippingDocumentByIdTest(int shippingDocumentId)
|
||||
//[TestMethod]
|
||||
//[DataRow(2)]
|
||||
public async Task<ShippingDocument> GetShippingDocumentByIdTest(int shippingDocumentId)
|
||||
{
|
||||
var shippingDocument = await _signalRClient.GetShippingDocumentById(shippingDocumentId);
|
||||
|
||||
Assert.IsNotNull(shippingDocument);
|
||||
Assert.IsTrue(shippingDocument.Id == shippingDocumentId);
|
||||
|
||||
return shippingDocument;
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(2)]
|
||||
public async Task UpdateShippingDocumentTest(int shippingDocumentId)
|
||||
{
|
||||
var shippingDocument = await GetShippingDocumentByIdTest(shippingDocumentId);
|
||||
var newCountry = GetFixtureName(shippingDocument.Country);
|
||||
|
||||
shippingDocument.Country = newCountry;
|
||||
await _signalRClient.UpdateShippingDocument(shippingDocument);
|
||||
|
||||
shippingDocument = await GetShippingDocumentByIdTest(shippingDocumentId);
|
||||
Assert.IsTrue(shippingDocument.Country == newCountry);
|
||||
|
||||
shippingDocument.Country = GetOriginalName(shippingDocument.Country);
|
||||
await _signalRClient.UpdateShippingDocument(shippingDocument);
|
||||
}
|
||||
|
||||
#endregion ShippingDocument
|
||||
|
|
|
|||
Loading…
Reference in New Issue