public void CreateAccountCustomerRelationShip1_PublishUpsertException_TransactionFailure() { //Arrange var accountUid = Guid.NewGuid(); var parentUid = Guid.NewGuid(); var childUid = Guid.NewGuid(); var actionUTC = DateTime.UtcNow; var accountDetail = new DbAccount { CustomerAccountID = 1, CustomerAccountUID = accountUid, AccountName = "ACC04", BSSID = "BSS04", DealerAccountCode = "DAC04", NetworkCustomerCode = "NCC04", }; transaction.Execute(Arg.Any <List <Action> >()).Returns(a => throw new Exception()); //Act Assert.Throws <Exception>(() => accountService.CreateAccountCustomerRelationShip( parentUid, childUid, accountDetail, actionUTC, "Remove")); //Assert transaction.DidNotReceive().Upsert(Arg.Any <DbAccount>()); transaction.DidNotReceive().Publish(Arg.Any <KafkaMessage>()); }
public void FetchEssentialAssets_InvalidRequestWithAssetSerialNumberFilter_ThrowsException() { AssetSettingsListRequestDto request = new AssetSettingsListRequestDto { CustomerUid = Guid.NewGuid().ToString("N"), UserUid = Guid.NewGuid().ToString("N"), PageNumber = 1, PageSize = 10, SortColumn = "AssetId", SortDirection = "ASC", FilterName = "InvalidFilterName", FilterValue = "Fuel" }; try { var values = _assetSettingsListRepository.FetchEssentialAssets(request).Result; } catch (AggregateException ex) { Assert.NotNull(ex.InnerException); var exception = ex.InnerException; var queryExpected = string.Format(Queries.FetchAssetsForCustomerAndUserUId + Queries.SelectFoundRows, (request.PageNumber > 0) ? string.Format(Queries.LimitClause, (request.PageNumber - 1) * request.PageSize, request.PageSize) : string.Empty, // Limit offset and limit page size string.Format(Queries.OrderByClause, Constants.AssetSettingsSortConfig[(AssetSettingsSortColumns)Enum.Parse(typeof(AssetSettingsSortColumns), request.SortColumn)], request.SortDirection), // order by clause string.Format("AND a.InvalidFilterName LIKE '%{0}%'", request.FilterValue), request.DeviceType); _stubTransactions.DidNotReceive().GetMultipleResultSetAsync <AssetSettingsListDto, long>(Arg.Any <string>(), Arg.Any <dynamic>()); Assert.NotNull(exception.Message); Assert.Equal(exception.Message, "Requested value 'InvalidFilterName' was not found."); } }
public void CreateCustomer_PublishUpsertException_TransactionException() { //Arrange var customerEvent = new CreateCustomerEvent { CustomerName = "CUS01", CustomerUID = Guid.NewGuid(), CustomerType = "Customer", BSSID = "BSS01", DealerNetwork = "None", NetworkDealerCode = "NDC01", PrimaryContactEmail = "*****@*****.**", FirstName = "FN01", LastName = "LN01", IsActive = true, ActionUTC = DateTime.UtcNow, ReceivedUTC = DateTime.UtcNow }; transaction.Execute(Arg.Any <List <Action> >()) .Returns(a => { throw new Exception(); }); //Act Assert.Throws <Exception>(() => customerService.CreateCustomer(customerEvent)); //Assert transaction.DidNotReceive().Upsert(Arg.Any <DbCustomer>()); transaction.DidNotReceive().Publish(Arg.Any <List <KafkaMessage> >()); }
public void BulkDissociateCustomerUser_InValidUsersForCustomer_NoTransaction() { //Arrange var customerUid = Guid.NewGuid(); var userUid1 = Guid.NewGuid(); var userUid2 = Guid.NewGuid(); var userIds = new List <Guid> { userUid1, userUid2 }; //Act var resultData = userCustomerService .BulkDissociateCustomerUser(customerUid, userIds, DateTime.UtcNow); //Assert Assert.False(resultData); transaction.Received(1).Get <DbUserCustomer>( Arg.Is <string>(m => m.Contains(customerUid.ToString("N")) && m.Contains(userUid1.ToString("N")) && m.Contains(userUid2.ToString("N")))); transaction.DidNotReceive().Delete(Arg.Any <string>()); transaction.DidNotReceive().Publish(Arg.Any <List <KafkaMessage> >()); }