public async Task It_should_rollback_both_entity_and_change_log_within_sync_flow() { // Given var id = Guid.NewGuid(); var user = new UserAggregate(id, "Bond"); var changeLog = user.Changes.GetUncommittedChanges().ToList(); using var db = NewDbContext(); db.Users.Add(user); await db.SaveChangesAsync(); // When using (var tran = TransactionExt.Begin(IsolationLevel.ReadCommitted)) { user.Rename("James Bond"); db.SaveChanges(); } // Then db.DetachAll(); var savedUser = await db.Users.FindAsync(id); var savedChangeLog = await LoadChangeLog(user.StreamId); savedUser.Should().BeEquivalentTo(new UserAggregate(id, "Bond")); savedChangeLog.Should().HaveSameCount(changeLog); for (var i = 0; i < savedChangeLog.Count; i++) { savedChangeLog[i].Should().BeEquivalentTo((object)changeLog[i]); savedChangeLog[i].Should().BeOfType(changeLog[i].GetType()); } }
public static void Encode(IByteWriter stream, TransactionExt encodedTransactionExt) { XdrEncoding.EncodeInt32(encodedTransactionExt.Discriminant, stream); switch (encodedTransactionExt.Discriminant) { case 0: break; } }
public static Transaction Decode(XdrDataInputStream stream) { Transaction decodedTransaction = new Transaction(); decodedTransaction.SourceAccount = AccountID.Decode(stream); decodedTransaction.Fee = Uint32.Decode(stream); decodedTransaction.SeqNum = SequenceNumber.Decode(stream); int TimeBoundsPresent = stream.ReadInt(); if (TimeBoundsPresent != 0) { decodedTransaction.TimeBounds = TimeBounds.Decode(stream); } decodedTransaction.Memo = Memo.Decode(stream); int operationssize = stream.ReadInt(); decodedTransaction.Operations = new Operation[operationssize]; for (int i = 0; i < operationssize; i++) { decodedTransaction.Operations[i] = Operation.Decode(stream); } decodedTransaction.Ext = TransactionExt.Decode(stream); return(decodedTransaction); }
public static void Encode(XdrDataOutputStream stream, Transaction encodedTransaction) { AccountID.Encode(stream, encodedTransaction.SourceAccount); Uint32.Encode(stream, encodedTransaction.Fee); SequenceNumber.Encode(stream, encodedTransaction.SeqNum); if (encodedTransaction.TimeBounds != null) { stream.WriteInt(1); TimeBounds.Encode(stream, encodedTransaction.TimeBounds); } else { stream.WriteInt(0); } Memo.Encode(stream, encodedTransaction.Memo); int operationssize = encodedTransaction.Operations.Length; stream.WriteInt(operationssize); for (int i = 0; i < operationssize; i++) { Operation.Encode(stream, encodedTransaction.Operations[i]); } TransactionExt.Encode(stream, encodedTransaction.Ext); }
public static void Encode(XdrDataOutputStream stream, TransactionExt encodedTransactionExt) { stream.WriteInt(encodedTransactionExt.Discriminant); switch (encodedTransactionExt.Discriminant) { case 0: break; } }
public static void Encode(IByteWriter stream, TransactionExt encodedTransactionExt) { XdrEncoding.EncodeInt32(encodedTransactionExt.Discriminant, stream); switch (encodedTransactionExt.Discriminant) { case 0: break; } }
public static TransactionExt Decode(XdrDataInputStream stream) { var decodedTransactionExt = new TransactionExt(); var discriminant = stream.ReadInt(); decodedTransactionExt.Discriminant = discriminant; switch (decodedTransactionExt.Discriminant) { case 0: break; } return decodedTransactionExt; }
public static TransactionExt Decode(IByteReader stream) { TransactionExt decodedTransactionExt = new TransactionExt(); decodedTransactionExt.Discriminant = XdrEncoding.DecodeInt32(stream); switch (decodedTransactionExt.Discriminant) { case 0: break; } return(decodedTransactionExt); }
protected async Task InsertUserInTransaction(UserAggregate user, Task beforeTransactionDone) { await Task.Yield(); using var transaction = TransactionExt.BeginAsync(IsolationLevel.ReadCommitted); using var db = NewDbContext(); db.Users.Add(user); await db.SaveChangesAsync(); await beforeTransactionDone; transaction.Complete(); }
public static Transaction Decode(IByteReader stream) { Transaction decodedTransaction = new Transaction(); decodedTransaction.SourceAccount = AccountID.Decode(stream); decodedTransaction.Fee = Uint32.Decode(stream); decodedTransaction.SeqNum = SequenceNumber.Decode(stream); int timeBoundsPresent = XdrEncoding.DecodeInt32(stream); if (timeBoundsPresent != 0) { decodedTransaction.TimeBounds = TimeBounds.Decode(stream); } decodedTransaction.Memo = Memo.Decode(stream); int operationssize = XdrEncoding.DecodeInt32(stream); decodedTransaction.Operations = new Operation[operationssize]; for (int i = 0; i < operationssize; i++) { decodedTransaction.Operations[i] = Operation.Decode(stream); } decodedTransaction.Ext = TransactionExt.Decode(stream); return(decodedTransaction); }
public static void Encode(IByteWriter stream, Transaction encodedTransaction) { AccountID.Encode(stream, encodedTransaction.SourceAccount); Uint32.Encode(stream, encodedTransaction.Fee); SequenceNumber.Encode(stream, encodedTransaction.SeqNum); if (encodedTransaction.TimeBounds != null) { XdrEncoding.EncodeInt32(1, stream); TimeBounds.Encode(stream, encodedTransaction.TimeBounds); } else { XdrEncoding.EncodeInt32(0, stream); } Memo.Encode(stream, encodedTransaction.Memo); int operationssize = encodedTransaction.Operations.Length; XdrEncoding.EncodeInt32(operationssize, stream); for (int i = 0; i < operationssize; i++) { Operation.Encode(stream, encodedTransaction.Operations[i]); } TransactionExt.Encode(stream, encodedTransaction.Ext); }
public static TransactionExt Decode(IByteReader stream) { TransactionExt decodedTransactionExt = new TransactionExt(); decodedTransactionExt.Discriminant = XdrEncoding.DecodeInt32(stream); switch (decodedTransactionExt.Discriminant) { case 0: break; } return decodedTransactionExt; }