/// <summary>
        /// Add completed transfer 
        /// </summary>
        /// <param name="realMoneySourceId">if null then returns a random real money source</param>
        /// <param name="user">if null then returns a random user</param>
        /// <param name="amount">if null then returns random amount</param>
        public static Transfer AddTransferRealSourceToUser(RealMoneySourceType? realSourceId, Guid? user, decimal? amount)
        {
            realSourceId = realSourceId.HasValue
              ? realSourceId.Value
              : DictionariesHelper.GetRandomDictionaryEntryId<RealMoneySourceType>(DictionaryTypes.RealMoneySource, RealMoneySourceFields.RealMoneySourceId);
              user = user.HasValue
              ? user.Value
              : UsersFacadeHelper.GetRandomUser(null).UserId();
              amount = amount.HasValue
              ? amount.Value
              : new Random((int)DateTime.Now.Ticks).Next(10, 20);

              Guid key = Guid.NewGuid();
              string note = string.Format("Transfer a real money source to a user {0}", key);
              var udBeforeTransfer = UsersFacade.GetDynamicsForUser(user.Value);
              Transfer t = TransferFactory.CreateRealSourceToUser(realSourceId.Value, user.Value, amount.Value, note);
              Transfer nt = BillingSystemFacade.AddTransfer(t);
              var udAfterTransfer = UsersFacade.GetDynamicsForUser(user.Value);
              Assert.IsTrue(udAfterTransfer.Compare(udBeforeTransfer));
              Assert.IsTrue(t.Compare(nt));
              Assert.AreEqual(TransferStatus.Pending, nt.Status);
              var ct = BillingSystemFacade.CompleteTransfer(nt.TransferId);
              Assert.AreEqual(TransferStatus.Completed, ct.Status);
              var udAfterTransferComplete = UsersFacade.GetDynamicsForUser(user.Value);
              Assert.AreEqual(udBeforeTransfer.MoneyAvailable + amount, udAfterTransferComplete.MoneyAvailable);
              return nt;
        }
Example #2
0
 public static Transfer CreateRealSourceToUser(RealMoneySourceType source, Guid userId
     , decimal amount, string note)
 {
     Transfer t = new Transfer();
       t.FromTransferParticipant = new TransferParticipant();
       t.FromTransferParticipant.RealMoneySourceId = (int)source;
       t.ToTransferParticipant = new TransferParticipant();
       t.ToTransferParticipant.UserId = userId;
       t.Amount = amount;
       t.Note = note;
       t.Status = TransferStatus.Pending;
       return t;
 }
 public static Transfer AddTransferFromUserToRealSource(RealMoneySourceType? realSourceId, Guid? user, decimal? amount)
 {
     var u = user ?? UsersFacadeHelper.GetRandomUser(null).UserId();
       var sourceType = realSourceId
     ?? DictionariesHelper.GetRandomDictionaryEntryId<RealMoneySourceType>(
       DictionaryTypes.RealMoneySource, RealMoneySourceFields.RealMoneySourceId);
       var s = BillingSystemFacade.GetRealMoneySource(sourceType);
       var a = amount ?? new Random((int)DateTime.Now.Ticks).Next(10, 20);
       var n = string.Format("a test transfer from the user {0} to real source", u);
       var t = TransferFactory.CreateUserToRealSource(s, u, a, n);
       var at = BillingSystemFacade.AddTransfer(t);
       Assert.IsTrue(t.Compare(at));
       return at;
 }
Example #4
0
 public static RealMoneySource GetRealMoneySource(RealMoneySourceType moneySourceTupe)
 {
     return new RealMoneySource().Load<RealMoneySource>(
     Dictionaries.Instance.GetRealMoneySourceById((int)moneySourceTupe));
 }