public IEnumerator PlayerAbortsTransaction() { // setup scene var go = new GameObject(); var smm = go.AddComponent <SteamPurchasingClientMock>(); yield return(null); // setup database var transaction = new SteamTransactionEntity { state = SteamTransactionEntity.InitiatedState, playerSteamId = 123456789L, orderId = 111222333L, transactionId = 374839L, language = "en", currency = "USD", items = new List <SteamTransactionEntity.Item> { new SteamTransactionEntity.Item { itemId = 1, quantity = 3, totalAmountInCents = 15_00, description = "An example product, that a user can buy.", category = null, productClass = typeof(ExampleVirtualProduct).FullName } } }; transaction.Save(); Http.Fake(); // Steamworks fires the callback smm.SteamworksCallbackHandler( new MicroTxnAuthorizationResponse_t { m_ulOrderID = 111222333L, m_unAppID = 440, m_bAuthorized = 0 // NOT authorized } ); Http.AssertNothingSent(); // transaction was updated accordingly transaction.Refresh(); Assert.AreEqual( SteamTransactionEntity.AbortedState, transaction.state ); // client logs failure LogAssert.Expect( LogType.Error, new Regex( "^The transaction failed because of:\n" + "You've aborted the transaction\\.$", RegexOptions.Multiline ) ); }
public void FinalizingTransactionThatDoesNotExist() { Http.Fake(); Assert.Throws <SteamPurchasingServerFacet.SteamMicrotransactionException>(() => { OnFacet <SteamPurchasingServerFacet> .CallSync <SteamTransactionEntity>( nameof(SteamPurchasingServerFacet.FinalizeTransaction), 123456789L, true ); }, "No initiated transaction with order id 123456789 was found."); Http.AssertNothingSent(); }
public void InitiatingTransactionWithNoProducts() { var transaction = new SteamTransactionEntity { playerSteamId = 123456789L }; Http.Fake(); Assert.Throws <ArgumentException>(() => { OnFacet <SteamPurchasingServerFacet> .CallSync( nameof(SteamPurchasingServerFacet.InitiateTransaction), transaction ); }, "Given transaction has no items inside of it."); Http.AssertNothingSent(); }
public void FinalizingTransactionThatIsNotInitiated() { var transaction = new SteamTransactionEntity { playerSteamId = 123456789L, state = SteamTransactionEntity.BeingPreparedState }; Http.Fake(); Assert.Throws <SteamPurchasingServerFacet.SteamMicrotransactionException>(() => { OnFacet <SteamPurchasingServerFacet> .CallSync <SteamTransactionEntity>( nameof(SteamPurchasingServerFacet.FinalizeTransaction), 123456789L, true ); }, "No initiated transaction with order id 123456789 was found."); Http.AssertNothingSent(); }