diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor index 6c230d0a..3eb0b3f5 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferToDriverGridComponent.razor @@ -219,7 +219,7 @@ private Task LoadComboBoxItems() { //TODO: CarModelDtoMin-t megcsinálni és azt lekérni a ComboBox-hoz! - J. - return AdminSignalRClient.GetAllCarsAndDriversByProductIdAsync(_cars, _drivers, TiamConstClient.TransferProductId, StateHasChanged); + return AdminSignalRClient.GetAllCarsAndDriversByProductIdAsync(TiamConstClient.TransferProductId, _cars, _drivers, StateHasChanged); } private void DataItemChanged(GridDataItemChangedEventArgs args) diff --git a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs index b7528428..36e90108 100644 --- a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs +++ b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs @@ -43,9 +43,9 @@ namespace TIAMWebApp.Shared.Application.Services return await GetAllAsync>(SignalRTags.GetAllCarsByProductId, [productId]) ?? []; } - public Task GetAllCarsAndDriversByProductIdAsync(List intoCars, List intoDrivers, Guid productId, Action? callback = null) + public Task GetAllCarsAndDriversByProductIdAsync(Guid productId, List intoCars, List intoDrivers, Action? callback = null) { - return GetAllCarsByProductIdAsync(intoCars, productId, () => + return GetAllCarsByProductIdAsync(productId, intoCars, () => { intoDrivers.Clear(); intoDrivers.AddRange(intoCars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); @@ -54,7 +54,7 @@ namespace TIAMWebApp.Shared.Application.Services }); } - public Task GetAllCarsByProductIdAsync(List intoCars, Guid productId, Action? callback = null) + public Task GetAllCarsByProductIdAsync(Guid productId, List intoCars, Action? callback = null) { Logger.Detail($"GetAllCarsByProductIdAsync client called; productId: {productId}"); diff --git a/Tiam.Services.Client.Tests/SignalRClientTest.cs b/Tiam.Services.Client.Tests/SignalRClientTest.cs index 53fc458a..25709da6 100644 --- a/Tiam.Services.Client.Tests/SignalRClientTest.cs +++ b/Tiam.Services.Client.Tests/SignalRClientTest.cs @@ -7,9 +7,11 @@ using Azure; using DevExpress.Data.Filtering; using DevExpress.Data.Linq; using DevExpress.Data.Linq.Helpers; +using TIAM.Core.Consts; using TIAM.Core.Enums; using TIAM.Core.Loggers; using TIAM.Database.Test; +using TIAM.Entities.Drivers; using TIAM.Entities.ServiceProviders; using TIAM.Entities.Transfers; using TIAM.Entities.Users; @@ -28,11 +30,13 @@ namespace Tiam.Services.Client.Tests [TestInitialize] public void TestInitialize() - { } + { + } [TestCleanup] public void TearDown() - { } + { + } [DataTestMethod] [DataRow(CompanyIdString)] @@ -130,7 +134,7 @@ namespace Tiam.Services.Client.Tests transferDest.Address.AddressText = modifiedAddress; transferDest = await _signalRClient.PostDataAsync(SignalRTags.UpdateTransferDestination, transferDest); - + Assert.IsNotNull(transferDest); Assert.IsNotNull(transferDest.Address); @@ -176,12 +180,12 @@ namespace Tiam.Services.Client.Tests var transferDestinationToProducts = await _signalRClient.GetByIdAsync>(SignalRTags.GetTransferDestinationToProductsByTransferDestinationId, transferDestId); Assert.IsNotNull(transferDestinationToProducts); Assert.IsTrue(transferDestinationToProducts.Count > 0); - Assert.IsTrue(transferDestinationToProducts.All(x=>x.TransferDestinationId == transferDestId)); + Assert.IsTrue(transferDestinationToProducts.All(x => x.TransferDestinationId == transferDestId)); transferDestinationToProducts = await _signalRClient.GetByIdAsync>(SignalRTags.GetTransferDestinationToProductsByProductId, productId); Assert.IsNotNull(transferDestinationToProducts); Assert.IsTrue(transferDestinationToProducts.Count > 0); - Assert.IsTrue(transferDestinationToProducts.All(x=>x.ProductId == productId)); + Assert.IsTrue(transferDestinationToProducts.All(x => x.ProductId == productId)); await _signalRClient.PostDataAsync(SignalRTags.RemoveTransferDestinationToProduct, transferDestinationToProduct); //mielõbb kitöröljük, h ne maradjon szemét a db-ben - J. @@ -199,16 +203,16 @@ namespace Tiam.Services.Client.Tests var criteriaString = CriteriaOperator.FromLambda(x => x.UserId == userId && statuses.Contains(x.TransferStatusType)).ToString(); //var criteria = CriteriaOperator.Parse(criteriaString); - + //_signalRDataSource.AsQueryable().Expression. //var filteredData = new List().AsQueryable().AppendWhere(converter, criteria) as IQueryable; - var transfers = await _signalRClient.GetAllAsync>(SignalRTags.GetTransfersByFilterText, [criteriaString]); + var transfers = await _signalRClient.GetTransfersByFilterText(criteriaString); //var transfers = await _signalRClient.GetAllAsync>(SignalRTags.GetTransfersByExpression, [userId, filteredData!.Expression]); Assert.IsNotNull(transfers); Assert.IsTrue(transfers.Count > 0); - Assert.IsTrue(transfers.All(x=>statuses.Contains(x.TransferStatusType))); + Assert.IsTrue(transfers.All(x => statuses.Contains(x.TransferStatusType))); //var converter = new CriteriaToExpressionConverter(); ////CriteriaOperator critOps = CriteriaOperator.Parse(tdashboard.EmployeeFilter); @@ -227,5 +231,46 @@ namespace Tiam.Services.Client.Tests //Assert.IsNotNull(filteredTransfers); //Assert.IsTrue(filteredTransfers.All(x => x.LuggageCount == 1)); } + + [TestMethod] + public async Task GetAllTransfersTest_ReturnTransfers_WhenHasTransfers() + { + var transfers = await _signalRClient.GetTransfers(); + + Assert.IsNotNull(transfers); + Assert.IsTrue(transfers.Count > 0); + } + + [TestMethod] + [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] + public async Task GetTransfersByUserIdTest_ReturnTransfers_WhenAllTransfersByUserId(string userIdString) + { + var userId = Guid.Parse(userIdString); + var transfers = await _signalRClient.GetTransfersByUserId(userId); + + Assert.IsNotNull(transfers); + + Assert.IsTrue(transfers.Count > 0); + Assert.IsTrue(transfers.All(x => x.UserId == userId)); + } + + [TestMethod] + [DataRow("")] + public async Task GetAllCarsAndDriversByProductIdAsyncTest_ReturnCarsAndDrivers_WhenHasCarsAndDrivers(string productIdString) + { + var cars = new List(); + var drivers = new List(); + var productId = TiamConstClient.TransferProductId; //Guid.Parse(productIdString); + + await _signalRClient.GetAllCarsAndDriversByProductIdAsync(productId, cars, drivers); + + await TaskHelper.WaitToAsync(() => drivers.Count > 0, 5000, 50); + + Assert.IsTrue(cars.Count > 0); + Assert.IsTrue(drivers.Count > 0); + + Assert.IsTrue(cars.All(car => drivers.Any(driver => driver.Id == car.UserProductMappingId && driver.ProductId == productId))); + Assert.IsTrue(drivers.All(driver => driver.ProductId == productId && cars.Any(car => car.UserProductMappingId == driver.Id))); + } } } \ No newline at end of file