|
|
|
|
@ -152,21 +152,43 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(shippingItems.All(si => si.ProductDto?.Id == si.ProductId), "shippingItem.Product == null");
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(shippingItems.All(x => x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.GrossWeight) == x.MeasuredGrossWeight));
|
|
|
|
|
Assert.IsTrue(shippingItems.All(x => x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.NetWeight) == x.MeasuredNetWeight));
|
|
|
|
|
Assert.IsTrue(shippingItems.All(x => double.Round(x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.GrossWeight), 1) == x.MeasuredGrossWeight));
|
|
|
|
|
Assert.IsTrue(shippingItems.All(x => double.Round(x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.NetWeight), 1) == x.MeasuredNetWeight));
|
|
|
|
|
|
|
|
|
|
foreach (var shippingItem in shippingItems.ToList())
|
|
|
|
|
await ValidateProductValues(shippingItems.Where(si => si.ProductId.GetValueOrDefault(0) > 0).GroupBy(x => x.ProductId!.Value, si => si).ToDictionary(k => k.Key, v => v.ToList()));
|
|
|
|
|
|
|
|
|
|
var rnd = new Random();
|
|
|
|
|
foreach (var shippingItem in shippingItems)
|
|
|
|
|
{
|
|
|
|
|
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(shippingItem.ProductId!.Value);
|
|
|
|
|
await UpdateShippingItemAsync(shippingItem.Id, rnd.Next(-10, 10), rnd.NextDouble() + rnd.Next(-3, 3), rnd.NextDouble() + rnd.Next(-5, 5), rnd.NextDouble() + rnd.Next(-1, 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(measuringProductDto!.Quantity == shippingItem.ProductDto!.StockQuantity);
|
|
|
|
|
var shippingItemSumQnty = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredQuantity);
|
|
|
|
|
Assert.IsTrue(shippingItemSumQnty == measuringProductDto.Quantity, $"{shippingItem}; shippingItemSum Quantity: {shippingItemSumQnty} == {measuringProductDto.Quantity}");
|
|
|
|
|
shippingItems = await _signalRClient.GetShippingItems();
|
|
|
|
|
Assert.IsNotNull(shippingItems);
|
|
|
|
|
|
|
|
|
|
var shippingItemSumWeight = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredNetWeight);
|
|
|
|
|
Assert.IsTrue(shippingItemSumWeight == measuringProductDto!.NetWeight, $"{shippingItem}; shippingItemSum NetWeight: {shippingItemSumWeight} == {measuringProductDto.NetWeight}");
|
|
|
|
|
await ValidateProductValues(shippingItems.Where(si => si.ProductId.GetValueOrDefault(0) > 0).GroupBy(x => x.ProductId!.Value, si => si).ToDictionary(k => k.Key, v => v.ToList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shippingItemSumWeight = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredGrossWeight);
|
|
|
|
|
private async Task ValidateProductValues(Dictionary<int, List<ShippingItem>> shippingItemsByProductId)
|
|
|
|
|
{
|
|
|
|
|
foreach (var kvPair in shippingItemsByProductId)
|
|
|
|
|
{
|
|
|
|
|
var shippingItems = kvPair.Value;
|
|
|
|
|
var productDto = await _signalRClient.GetProductDtoById(kvPair.Key);
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(productDto);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(shippingItems.Where(si => si.ProductId == productDto.Id).All(si => si.ProductDto!.StockQuantity == productDto.StockQuantity));
|
|
|
|
|
|
|
|
|
|
var shippingItemSumQnty = shippingItems.Where(x => x.IsMeasured && x.ProductId == productDto.Id).Sum(x => x.MeasuredQuantity);
|
|
|
|
|
Assert.IsTrue(shippingItemSumQnty == productDto.StockQuantity, $"{productDto}; shippingItemSum Quantity: {shippingItemSumQnty} == {productDto.StockQuantity}");
|
|
|
|
|
|
|
|
|
|
if (!productDto.IsMeasurable) continue;
|
|
|
|
|
|
|
|
|
|
var shippingItemSumWeight = double.Round(shippingItems.Where(x => x.IsMeasured && x.ProductId == productDto.Id).Sum(x => x.MeasuredNetWeight), 1);
|
|
|
|
|
Assert.IsTrue(shippingItemSumWeight == productDto!.NetWeight, $"{productDto}; shippingItemSum NetWeight: {shippingItemSumWeight} == {productDto.NetWeight}");
|
|
|
|
|
|
|
|
|
|
shippingItemSumWeight = double.Round(shippingItems.Where(x => x.IsMeasured && x.ProductId == productDto.Id).Sum(x => x.MeasuredGrossWeight), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -195,6 +217,7 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
Assert.IsNotNull(shippingItem, $"shippingItemId: {shippingItemId}");
|
|
|
|
|
|
|
|
|
|
if (shippingItem.IsMeasurable) Assert.IsNotNull(shippingItem.Pallet, $"shippingItem.Pallet == null; shippingItem.PalletId: {shippingItem.PalletId}");
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(shippingItem.ProductDto, $"shippingItem.Product == null; shippingItem.ProductId: {shippingItem.ProductId}");
|
|
|
|
|
Assert.IsTrue(shippingItem.Id == shippingItemId);
|
|
|
|
|
|
|
|
|
|
@ -206,8 +229,9 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataTestMethod]
|
|
|
|
|
[DataRow(1, -1, -2.137563300001, -333.75238200001, 2.12545)]
|
|
|
|
|
[DataRow(1, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
[DataRow(1, 1, 0, 1, 0)]
|
|
|
|
|
[DataRow(1, -1, -2.137563300001, -33.75238200001, 2.12545)]
|
|
|
|
|
[DataRow(1, 1, 2.137563300001, 390.75238200001, 2.12545)]
|
|
|
|
|
[DataRow(1, 1, 20.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
[DataRow(2, -1, -20.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
[DataRow(2, -1, 20.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
@ -218,74 +242,99 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
[DataRow(5, -1, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
public async Task UpdateShippingItemTest(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight, double incTare)
|
|
|
|
|
{
|
|
|
|
|
Assert.IsTrue(true);
|
|
|
|
|
return;
|
|
|
|
|
await UpdateShippingItemAsync(shippingItemId, incQuantity, incPalletWeight, incGrossWeight, incTare);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateShippingItemAsync(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight, double incTare)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"params: {shippingItemId}; {incQuantity}; {incPalletWeight}; {incGrossWeight}; {incTare}");
|
|
|
|
|
|
|
|
|
|
var originalShippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
|
|
|
|
var originalMeasuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
|
|
|
|
|
Console.WriteLine($"{originalShippingItem}");
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(originalShippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
|
|
|
|
|
var productDto = await GetProductDtoByIdAsync(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(originalShippingItem.IsMeasurable == productDto.IsMeasurable);
|
|
|
|
|
Console.WriteLine($"{productDto}; NetWeight: {productDto.NetWeight}");
|
|
|
|
|
|
|
|
|
|
var shippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
|
|
|
|
var shippingItemPallet = originalShippingItem.ShippingItemPallets!.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
var originalShippingItemPallet = shippingItem.ShippingItemPallets!.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (originalShippingItemPallet == null)
|
|
|
|
|
if (shippingItemPallet == null)
|
|
|
|
|
{
|
|
|
|
|
originalShippingItemPallet = new ShippingItemPallet { ShippingItemId = shippingItem.Id, PalletWeight = shippingItem.Pallet?.Weight ?? 0 };
|
|
|
|
|
shippingItem.ShippingItemPallets!.Add(originalShippingItemPallet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(originalShippingItemPallet);
|
|
|
|
|
|
|
|
|
|
var nullResultIsValid = shippingItem.IsMeasured && !shippingItem.IsValidMeasuringValues();
|
|
|
|
|
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidMeasuringValues(originalMeasuringProductDto.IsMeasurable));
|
|
|
|
|
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidSafeMeasuringValues());
|
|
|
|
|
|
|
|
|
|
originalShippingItemPallet.TrayQuantity += incQuantity;
|
|
|
|
|
originalShippingItemPallet.GrossWeight += incGrossWeight;
|
|
|
|
|
originalShippingItemPallet.PalletWeight += incPalletWeight;
|
|
|
|
|
originalShippingItemPallet.TareWeight += incTare;
|
|
|
|
|
|
|
|
|
|
//shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
|
|
|
|
var shippingItemPallet = await _signalRClient.UpdateShippingItemPallet(originalShippingItemPallet);
|
|
|
|
|
|
|
|
|
|
//A szerver oldal 0-ra állítja a shippingItemPallet weight-eket, ha nem mérhető! - J.
|
|
|
|
|
if (!originalMeasuringProductDto.IsMeasurable)
|
|
|
|
|
{
|
|
|
|
|
originalShippingItemPallet.GrossWeight = 0;
|
|
|
|
|
originalShippingItemPallet.PalletWeight = 0;
|
|
|
|
|
originalShippingItemPallet.TareWeight = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nullResultIsValid || !originalShippingItemPallet.IsValidSafeMeasuringValues())
|
|
|
|
|
{
|
|
|
|
|
Assert.IsNull(shippingItemPallet);
|
|
|
|
|
return;
|
|
|
|
|
shippingItemPallet = new ShippingItemPallet { ShippingItemId = originalShippingItem.Id, PalletWeight = originalShippingItem.Pallet?.Weight ?? 0 };
|
|
|
|
|
originalShippingItem.ShippingItemPallets!.Add(shippingItemPallet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(shippingItemPallet);
|
|
|
|
|
Assert.IsTrue(shippingItemPallet.TareWeight == originalShippingItemPallet.TareWeight);
|
|
|
|
|
Assert.IsTrue(shippingItemPallet.TrayQuantity == originalShippingItemPallet.TrayQuantity);
|
|
|
|
|
Assert.IsTrue(shippingItemPallet.GrossWeight == originalShippingItemPallet.GrossWeight);
|
|
|
|
|
Assert.IsTrue(shippingItemPallet.PalletWeight == originalShippingItemPallet.PalletWeight);
|
|
|
|
|
Assert.IsTrue(shippingItemPallet.ShippingItemId == originalShippingItemPallet.ShippingItemId);
|
|
|
|
|
|
|
|
|
|
shippingItem = await _signalRClient.GetShippingItemById(shippingItemPallet.ShippingItemId);
|
|
|
|
|
var nullResultIsValid = originalShippingItem.IsMeasured && !originalShippingItem.IsValidMeasuringValues();
|
|
|
|
|
nullResultIsValid = nullResultIsValid || originalShippingItem.ShippingItemPallets!.Any(x => !x.IsValidMeasuringValues(productDto.IsMeasurable));
|
|
|
|
|
nullResultIsValid = nullResultIsValid || originalShippingItem.ShippingItemPallets!.Any(x => !x.IsValidSafeMeasuringValues());
|
|
|
|
|
|
|
|
|
|
var originalPalletNetWeight = shippingItemPallet.NetWeight;
|
|
|
|
|
|
|
|
|
|
shippingItemPallet.TrayQuantity += incQuantity;
|
|
|
|
|
shippingItemPallet.GrossWeight += incGrossWeight;
|
|
|
|
|
shippingItemPallet.PalletWeight += incPalletWeight;
|
|
|
|
|
shippingItemPallet.TareWeight += incTare;
|
|
|
|
|
|
|
|
|
|
var incNetWeight = productDto.IsMeasurable ? double.Round(shippingItemPallet.NetWeight - originalPalletNetWeight, 1) : 0;
|
|
|
|
|
|
|
|
|
|
//shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
|
|
|
|
var dbShippingItemPallet = await _signalRClient.UpdateShippingItemPallet(shippingItemPallet);
|
|
|
|
|
|
|
|
|
|
//A szerver oldal 0-ra állítja a shippingItemPallet weight-eket, ha nem mérhető! - J.
|
|
|
|
|
if (!productDto.IsMeasurable)
|
|
|
|
|
{
|
|
|
|
|
shippingItemPallet.GrossWeight = 0;
|
|
|
|
|
shippingItemPallet.PalletWeight = 0;
|
|
|
|
|
shippingItemPallet.TareWeight = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nullResultIsValid || !shippingItemPallet.IsValidSafeMeasuringValues())
|
|
|
|
|
{
|
|
|
|
|
Assert.IsNull(dbShippingItemPallet);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(dbShippingItemPallet);
|
|
|
|
|
Assert.IsTrue(dbShippingItemPallet.TareWeight == shippingItemPallet.TareWeight);
|
|
|
|
|
Assert.IsTrue(dbShippingItemPallet.TrayQuantity == shippingItemPallet.TrayQuantity);
|
|
|
|
|
Assert.IsTrue(dbShippingItemPallet.GrossWeight == shippingItemPallet.GrossWeight);
|
|
|
|
|
Assert.IsTrue(dbShippingItemPallet.PalletWeight == shippingItemPallet.PalletWeight);
|
|
|
|
|
Assert.IsTrue(dbShippingItemPallet.ShippingItemId == shippingItemPallet.ShippingItemId);
|
|
|
|
|
Assert.IsTrue(dbShippingItemPallet.NetWeight == double.Round(originalPalletNetWeight + incNetWeight, 1));
|
|
|
|
|
|
|
|
|
|
var shippingItem = await _signalRClient.GetShippingItemById(dbShippingItemPallet.ShippingItemId);
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(shippingItem);
|
|
|
|
|
Assert.IsNotNull(shippingItem.ProductDto);
|
|
|
|
|
Assert.IsNotNull(shippingItem.ShippingItemPallets);
|
|
|
|
|
Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
incGrossWeight = originalMeasuringProductDto.IsMeasurable ? double.Round(incGrossWeight, 1) : 0;
|
|
|
|
|
var incNetWeight = originalMeasuringProductDto.IsMeasurable ? double.Round((incGrossWeight - incPalletWeight) - (incQuantity * incTare), 1) : 0;
|
|
|
|
|
Assert.IsTrue(shippingItem.IsMeasurable == productDto.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
//var incNetWeight = productDto.IsMeasurable ? double.Round(dbShippingItemPallet.NetWeight - originalPalletNetWeight, 1) : 0;
|
|
|
|
|
incGrossWeight = productDto.IsMeasurable ? double.Round(incGrossWeight, 1) : 0;
|
|
|
|
|
|
|
|
|
|
var isMeasuredPalletsCount = shippingItem.ShippingItemPallets!.Count(x => x.IsMeasured);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(shippingItem.MeasuredNetWeight == double.Round(originalShippingItem.MeasuredNetWeight + incNetWeight, 1));
|
|
|
|
|
Assert.IsTrue(shippingItem.IsMeasured == (shippingItem.ShippingItemPallets!.All(x => x.IsMeasured) && shippingItem.MeasuringCount == isMeasuredPalletsCount));
|
|
|
|
|
|
|
|
|
|
if (shippingItem.IsMeasured)
|
|
|
|
|
{
|
|
|
|
|
Assert.IsTrue(shippingItem.IsValidMeasuringValues());
|
|
|
|
|
Assert.IsTrue(shippingItem.MeasuringCount == isMeasuredPalletsCount);
|
|
|
|
|
Assert.IsTrue(shippingItem.ProductDto.StockQuantity == originalShippingItem.ProductDto!.StockQuantity + incQuantity);
|
|
|
|
|
Assert.IsTrue(shippingItem.ProductDto.IncomingQuantity == productDto.IncomingQuantity - incQuantity);
|
|
|
|
|
|
|
|
|
|
var dbProductDto = await GetProductDtoByIdAsync(originalShippingItem.ProductId!.Value, shippingItem.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(dbProductDto.StockQuantity == productDto.StockQuantity + incQuantity);
|
|
|
|
|
Assert.IsTrue(dbProductDto.IncomingQuantity == productDto.IncomingQuantity - incQuantity);
|
|
|
|
|
Assert.IsTrue(dbProductDto.NetWeight == double.Round(productDto.NetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -297,13 +346,7 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(shippingItem.MeasuredQuantity == originalShippingItem.MeasuredQuantity + incQuantity);
|
|
|
|
|
Assert.IsTrue(shippingItem.ProductDto.StockQuantity == originalShippingItem.ProductDto!.StockQuantity + incQuantity);
|
|
|
|
|
|
|
|
|
|
var measuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, shippingItem.IsMeasurable);
|
|
|
|
|
Assert.IsTrue(measuringProductDto.StockQuantity == originalMeasuringProductDto.StockQuantity + incQuantity);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(measuringProductDto.NetWeight == double.Round(originalMeasuringProductDto.NetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(shippingItem.ShippingItemPallets!.All(x => x.IsValidSafeMeasuringValues()));
|
|
|
|
|
Assert.IsTrue(shippingItem.ShippingItemPallets!.All(x => x.IsValidMeasuringValues(shippingItem.IsMeasurable)));
|
|
|
|
|
|
|
|
|
|
@ -402,23 +445,11 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task GetProductDtosTest()
|
|
|
|
|
{
|
|
|
|
|
var productDto = await _signalRClient.GetProductDtos();
|
|
|
|
|
var productDtos = await _signalRClient.GetProductDtos();
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(productDto);
|
|
|
|
|
Assert.IsTrue(productDto.Count != 0);
|
|
|
|
|
Assert.IsTrue(productDto.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public async Task GetAllMeasuringProductDtosTest()
|
|
|
|
|
{
|
|
|
|
|
var measuringProductDtos = await _signalRClient.GetAllMeasuringProductDtos();
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(measuringProductDtos);
|
|
|
|
|
Assert.IsTrue(measuringProductDtos.Count != 0);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(measuringProductDtos.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
|
|
|
|
//Assert.IsTrue(measuringProductDtos.All(x => !x.IsMeasurable || x.HasMeasuringValues()));
|
|
|
|
|
Assert.IsNotNull(productDtos);
|
|
|
|
|
Assert.IsTrue(productDtos.Count != 0);
|
|
|
|
|
Assert.IsTrue(productDtos.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
@ -428,32 +459,169 @@ namespace FruitBankHybrid.Shared.Tests
|
|
|
|
|
[DataRow(33, true)]
|
|
|
|
|
[DataRow(64, false)]
|
|
|
|
|
[DataRow(7, false)]
|
|
|
|
|
public async Task GetMeasuringProductDtoByIdTest(int productId, bool isMeasurableExcepted)
|
|
|
|
|
public async Task GetProductDtoByIdTest(int productId, bool isMeasurableExcepted)
|
|
|
|
|
{
|
|
|
|
|
await GetMeasuringProductDtoByIdAsync(productId, isMeasurableExcepted);
|
|
|
|
|
await GetProductDtoByIdAsync(productId, isMeasurableExcepted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<MeasuringProductDto> GetMeasuringProductDtoByIdAsync(int productId, bool isMeasurableExcepted)
|
|
|
|
|
public async Task<ProductDto> GetProductDtoByIdAsync(int productId, bool isMeasurableExcepted)
|
|
|
|
|
{
|
|
|
|
|
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(productId);
|
|
|
|
|
var productDto = await _signalRClient.GetProductDtoById(productId);
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(measuringProductDto);
|
|
|
|
|
Assert.IsNotNull(productDto);
|
|
|
|
|
|
|
|
|
|
if (isMeasurableExcepted) Assert.IsTrue(measuringProductDto.HasMeasuringValues(), $"{measuringProductDto.IsMeasurable}, {measuringProductDto.NetWeight}");
|
|
|
|
|
if (isMeasurableExcepted) Assert.IsTrue(productDto.HasMeasuringValues(), $"{productDto.IsMeasurable}, {productDto.NetWeight}");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Assert.IsTrue(measuringProductDto.Id > 0);
|
|
|
|
|
Assert.IsTrue(measuringProductDto.StockQuantity >= 0);
|
|
|
|
|
Assert.IsTrue(measuringProductDto.NetWeight == 0);
|
|
|
|
|
Assert.IsTrue(productDto.Id > 0);
|
|
|
|
|
Assert.IsTrue(productDto.StockQuantity >= 0);
|
|
|
|
|
Assert.IsTrue(productDto.NetWeight == 0);
|
|
|
|
|
|
|
|
|
|
Assert.IsFalse(measuringProductDto.IsMeasurable);
|
|
|
|
|
Assert.IsFalse(productDto.IsMeasurable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return measuringProductDto;
|
|
|
|
|
return productDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Product
|
|
|
|
|
|
|
|
|
|
#region OrderItem
|
|
|
|
|
//[return: NotNull]
|
|
|
|
|
//public async Task<ShippingItem> GetOrderDtoByIdAsync(int orderId)
|
|
|
|
|
//{
|
|
|
|
|
// var orderDto = await _signalRClient.GetOrderDtoById(orderId);
|
|
|
|
|
|
|
|
|
|
// Assert.IsNotNull(orderDto, $"orderDto: {orderId}");
|
|
|
|
|
|
|
|
|
|
// if (orderDto.IsMeasurable) Assert.IsNotNull(orderDto.Pallet, $"orderDto.Pallet == null; orderDto.PalletId: {orderDto.PalletId}");
|
|
|
|
|
|
|
|
|
|
// Assert.IsNotNull(orderDto.ProductDto, $"orderDto.Product == null; orderDto.ProductId: {orderDto.ProductId}");
|
|
|
|
|
// Assert.IsTrue(orderDto.Id == orderId);
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(orderDto.QuantityOnDocument > 0, "QuantityOnDocument == 0");
|
|
|
|
|
// Assert.IsTrue(orderDto.NetWeightOnDocument > 0, "NetWeightOnDocument == 0");
|
|
|
|
|
// Assert.IsTrue(orderDto.GrossWeightOnDocument > 0, "GrossWeightOnDocument == 0");
|
|
|
|
|
|
|
|
|
|
// return orderDto;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//[DataTestMethod]
|
|
|
|
|
//[DataRow(1, -1, -2.137563300001, -333.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(1, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(1, 1, 20.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(2, -1, -20.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(2, -1, 20.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(3, 1, 2.137563300001, 1.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(3, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(4, 13, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(5, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//[DataRow(5, -1, 2.137563300001, 3.75238200001, 2.12545)]
|
|
|
|
|
//public async Task UpdateOrderItemTest(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight, double incTare)
|
|
|
|
|
//{
|
|
|
|
|
// Assert.IsTrue(true);
|
|
|
|
|
// return;
|
|
|
|
|
// await UpdateOrderItemAsync(shippingItemId, incQuantity, incPalletWeight, incGrossWeight, incTare);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//public async Task UpdateOrderItemAsync(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight, double incTare)
|
|
|
|
|
//{
|
|
|
|
|
//var originalShippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
|
|
|
|
// var productDto = await GetProductDtoByIdAsync(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(originalShippingItem.IsMeasurable == productDto.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
// var shippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
|
|
|
|
|
|
|
|
|
// var shippingItemPallet = shippingItem.ShippingItemPallets!.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
// if (shippingItemPallet == null)
|
|
|
|
|
// {
|
|
|
|
|
// shippingItemPallet = new ShippingItemPallet { ShippingItemId = shippingItem.Id, PalletWeight = shippingItem.Pallet?.Weight ?? 0 };
|
|
|
|
|
// shippingItem.ShippingItemPallets!.Add(shippingItemPallet);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Assert.IsNotNull(shippingItemPallet);
|
|
|
|
|
|
|
|
|
|
// var nullResultIsValid = shippingItem.IsMeasured && !shippingItem.IsValidMeasuringValues();
|
|
|
|
|
// nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidMeasuringValues(productDto.IsMeasurable));
|
|
|
|
|
// nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidSafeMeasuringValues());
|
|
|
|
|
|
|
|
|
|
// shippingItemPallet.TrayQuantity += incQuantity;
|
|
|
|
|
// shippingItemPallet.GrossWeight += incGrossWeight;
|
|
|
|
|
// shippingItemPallet.PalletWeight += incPalletWeight;
|
|
|
|
|
// shippingItemPallet.TareWeight += incTare;
|
|
|
|
|
|
|
|
|
|
// //shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
|
|
|
|
// var dbShippingItemPallet = await _signalRClient.UpdateShippingItemPallet(shippingItemPallet);
|
|
|
|
|
|
|
|
|
|
// //A szerver oldal 0-ra állítja a shippingItemPallet weight-eket, ha nem mérhető! - J.
|
|
|
|
|
// if (!productDto.IsMeasurable)
|
|
|
|
|
// {
|
|
|
|
|
// shippingItemPallet.GrossWeight = 0;
|
|
|
|
|
// shippingItemPallet.PalletWeight = 0;
|
|
|
|
|
// shippingItemPallet.TareWeight = 0;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (nullResultIsValid || !shippingItemPallet.IsValidSafeMeasuringValues())
|
|
|
|
|
// {
|
|
|
|
|
// Assert.IsNull(dbShippingItemPallet);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Assert.IsNotNull(dbShippingItemPallet);
|
|
|
|
|
// Assert.IsTrue(dbShippingItemPallet.TareWeight == shippingItemPallet.TareWeight);
|
|
|
|
|
// Assert.IsTrue(dbShippingItemPallet.TrayQuantity == shippingItemPallet.TrayQuantity);
|
|
|
|
|
// Assert.IsTrue(dbShippingItemPallet.GrossWeight == shippingItemPallet.GrossWeight);
|
|
|
|
|
// Assert.IsTrue(dbShippingItemPallet.PalletWeight == shippingItemPallet.PalletWeight);
|
|
|
|
|
// Assert.IsTrue(dbShippingItemPallet.ShippingItemId == shippingItemPallet.ShippingItemId);
|
|
|
|
|
|
|
|
|
|
// shippingItem = await _signalRClient.GetShippingItemById(dbShippingItemPallet.ShippingItemId);
|
|
|
|
|
|
|
|
|
|
// Assert.IsNotNull(shippingItem);
|
|
|
|
|
// Assert.IsNotNull(shippingItem.ProductDto);
|
|
|
|
|
// Assert.IsNotNull(shippingItem.ShippingItemPallets);
|
|
|
|
|
// Assert.IsTrue(shippingItem.IsMeasurable == productDto.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
// incGrossWeight = productDto.IsMeasurable ? double.Round(incGrossWeight, 1) : 0;
|
|
|
|
|
// var incNetWeight = productDto.IsMeasurable ? double.Round((incGrossWeight - incPalletWeight) - (incQuantity * incTare), 1) : 0;
|
|
|
|
|
|
|
|
|
|
// var isMeasuredPalletsCount = shippingItem.ShippingItemPallets!.Count(x => x.IsMeasured);
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(shippingItem.IsMeasured == (shippingItem.ShippingItemPallets!.All(x => x.IsMeasured) && shippingItem.MeasuringCount == isMeasuredPalletsCount));
|
|
|
|
|
|
|
|
|
|
// if (shippingItem.IsMeasured)
|
|
|
|
|
// {
|
|
|
|
|
// Assert.IsTrue(shippingItem.IsValidMeasuringValues());
|
|
|
|
|
// Assert.IsTrue(shippingItem.MeasuringCount == isMeasuredPalletsCount);
|
|
|
|
|
// Assert.IsTrue(shippingItem.ProductDto.StockQuantity == originalShippingItem.ProductDto!.StockQuantity + incQuantity);
|
|
|
|
|
// Assert.IsTrue(shippingItem.ProductDto.IncomingQuantity == productDto.IncomingQuantity - incQuantity);
|
|
|
|
|
|
|
|
|
|
// var dbProductDto = await GetProductDtoByIdAsync(originalShippingItem.ProductId!.Value, shippingItem.IsMeasurable);
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(dbProductDto.StockQuantity == productDto.StockQuantity + incQuantity);
|
|
|
|
|
// Assert.IsTrue(dbProductDto.IncomingQuantity == productDto.IncomingQuantity - incQuantity);
|
|
|
|
|
// Assert.IsTrue(dbProductDto.NetWeight == double.Round(productDto.NetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// incQuantity = 0;
|
|
|
|
|
// incNetWeight = 0;
|
|
|
|
|
// incGrossWeight = 0;
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(shippingItem.MeasuringCount > isMeasuredPalletsCount);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(shippingItem.MeasuredQuantity == originalShippingItem.MeasuredQuantity + incQuantity);
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(shippingItem.ShippingItemPallets!.All(x => x.IsValidSafeMeasuringValues()));
|
|
|
|
|
// Assert.IsTrue(shippingItem.ShippingItemPallets!.All(x => x.IsValidMeasuringValues(shippingItem.IsMeasurable)));
|
|
|
|
|
|
|
|
|
|
// Assert.IsTrue(shippingItem.MeasuredNetWeight == double.Round(originalShippingItem.MeasuredNetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
|
|
|
|
|
// Assert.IsTrue(shippingItem.MeasuredGrossWeight == double.Round(originalShippingItem.MeasuredGrossWeight + (shippingItem.IsMeasurable ? incGrossWeight : 0), 1));
|
|
|
|
|
//}
|
|
|
|
|
#endregion OrderItem
|
|
|
|
|
|
|
|
|
|
#region Login
|
|
|
|
|
[TestMethod]
|
|
|
|
|
[DataRow("aasd@dsserver.com", "Asdasd123456")]
|
|
|
|
|
|