private static void DeclarerChanged(Topic sender, TopicChanged param) { DVar<string> dec=sender as DVar<string>; Topic infoT; DVar<string> infoD; if(dec==null) { return; } StatementDescription stR=null; if(param.Art==TopicChanged.ChangeArt.Remove) { stR=_statements.FirstOrDefault(z => z.name==dec.name); if(stR!=null) { _statements.Remove(stR); } } else { if(param.Art==TopicChanged.ChangeArt.Value) { stR=_statements.FirstOrDefault(z => z.name==dec.name); } if(stR==null) { stR=new StatementDescription() { name=dec.name }; _statements.Add(stR); } stR.image=dec.value; if(dec.Exist("_description", out infoT) && (infoD=(infoT as DVar<string>))!=null && !string.IsNullOrEmpty(infoD.value)) { stR.sortKey=infoD.value.Substring(0, 2); stR.info=infoD.value.Substring(2); } } }
private Statement CreateOutcome(decimal amount) { var date = DateTime.Parse("2018-04-15"); var category = Category.Create(IncomeCategoryName); category.SetId(1); var statement = Statement.CreateOutcome(StatementDescription.Create("Income"), MoneyAmount.Create(amount), date, category); return(statement); }
public void ShouldNotCreateStatementWithCategoryWithoutId() { // Arrange var date = DateTime.Parse("2018-04-14"); var category = Category.Create("category"); // Act Action create = () => Statement.CreateOutcome(StatementDescription.Create("test"), MoneyAmount.Create(10m), date, category); //Assert Assert.Throws <ArgumentException>(create); }
private Statement CreateIncome(decimal amount) { var date = DateTime.Parse("2018-04-14"); var category = Category.Create("income-category"); category.SetId(1); var statement = Statement.CreateOutcome(StatementDescription.Create("Income"), MoneyAmount.Create(amount), date, category); statement.SetProperty("Direction", StatementDirection.Income); return(statement); }
public void Create_CreditCardStatement_BillShoudNotBeNull() { // Arrange string description = "test description"; decimal amount = 100m; DateTime date = DateTime.Parse("2018-05-02"); CreditCardBill nullBill = null; // Act Action createStatement = () => CreditCardStatement.Create( nullBill, StatementDescription.Create(description), MoneyAmount.Create(amount), date); // Assert Assert.Throws <ArgumentNullException>(createStatement); }
public void Create_CreditCardStatement_BillShoudHaveId() { // Arrange string description = "test description"; decimal amount = 100m; DateTime date = DateTime.Parse("2018-05-02"); CreditCardBill billWithoutId = new CreditCardBill(); // Act Action createStatement = () => CreditCardStatement.Create( billWithoutId, StatementDescription.Create(description), MoneyAmount.Create(amount), date); // Assert Assert.Throws <ArgumentException>(createStatement); }
public static Statement CreateOutcome(StatementDescription description, MoneyAmount amount, DateTime dueDate, Category category) { if (!category.Exists()) { throw new ArgumentException("Cannot assign categories not present on database", nameof(category)); } return(new Statement() { Description = description, Amount = amount, DueDate = dueDate, Category = category, Direction = StatementDirection.Outcome, Paid = false }); }
public void MarkAsPaidShouldSavePaymentDate() { // Arrange var date = DateTime.Parse("2018-04-14"); var category = Category.Create("category"); category.SetId(1); var statement = Statement.CreateOutcome(StatementDescription.Create("test"), MoneyAmount.Create(10m), date, category); // Act statement.MarkAsPaid(date); // Assert Assert.Equal(date, statement.PaymentDate); Assert.True(statement.Paid); }
public static CreditCardStatement Create(CreditCardBill bill, StatementDescription description, MoneyAmount amount, DateTime date) { if (bill == null) { throw new ArgumentNullException(nameof(bill)); } if (bill.Id < 1) { throw new ArgumentException("Credit card bill entity must have a valid id.", nameof(bill)); } return(new CreditCardStatement() { Bill = bill, Description = description, Amount = amount, BuyDate = date }); }
public void Create_CreditCardStatement() { // Arrange string description = "test description"; decimal amount = 100m; DateTime date = DateTime.Parse("2018-05-02"); int id = 10; CreditCardBill bill = new CreditCardBill(); bill.SetId(id); // Act CreditCardStatement statement = CreditCardStatement.Create( bill, StatementDescription.Create(description), MoneyAmount.Create(amount), date); // Assert Assert.Equal(id, statement.Bill.Id); Assert.Equal(description, statement.Description.Value); Assert.Equal(amount, statement.Amount.Value); Assert.Equal(date, statement.BuyDate); }
public void CreateOutcome() { // Arrange var amount = MoneyAmount.Create(10m); var description = StatementDescription.Create("test"); var date = DateTime.Parse("2018-04-14"); var category = Category.Create("category"); category.SetId(1); // Act var statement = Statement.CreateOutcome(description, amount, date, category); // Assert Assert.Equal(0, statement.Id); Assert.Equal(amount, statement.Amount); Assert.Equal(description, statement.Description); Assert.Equal(category, statement.Category); Assert.Equal(date, statement.DueDate); Assert.Null(statement.PaymentDate); Assert.False(statement.Paid); Assert.Equal(StatementDirection.Outcome, statement.Direction); }
public override int GetHashCode() { int hashCode = 1465447186; if (Status != null) { hashCode += Status.GetHashCode(); } if (Card != null) { hashCode += Card.GetHashCode(); } if (EntryMethod != null) { hashCode += EntryMethod.GetHashCode(); } if (CvvStatus != null) { hashCode += CvvStatus.GetHashCode(); } if (AvsStatus != null) { hashCode += AvsStatus.GetHashCode(); } if (AuthResultCode != null) { hashCode += AuthResultCode.GetHashCode(); } if (ApplicationIdentifier != null) { hashCode += ApplicationIdentifier.GetHashCode(); } if (ApplicationName != null) { hashCode += ApplicationName.GetHashCode(); } if (ApplicationCryptogram != null) { hashCode += ApplicationCryptogram.GetHashCode(); } if (VerificationMethod != null) { hashCode += VerificationMethod.GetHashCode(); } if (VerificationResults != null) { hashCode += VerificationResults.GetHashCode(); } if (StatementDescription != null) { hashCode += StatementDescription.GetHashCode(); } if (DeviceDetails != null) { hashCode += DeviceDetails.GetHashCode(); } if (CardPaymentTimeline != null) { hashCode += CardPaymentTimeline.GetHashCode(); } if (RefundRequiresCardPresence != null) { hashCode += RefundRequiresCardPresence.GetHashCode(); } if (Errors != null) { hashCode += Errors.GetHashCode(); } return(hashCode); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CardPaymentDetails other && ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) && ((Card == null && other.Card == null) || (Card?.Equals(other.Card) == true)) && ((EntryMethod == null && other.EntryMethod == null) || (EntryMethod?.Equals(other.EntryMethod) == true)) && ((CvvStatus == null && other.CvvStatus == null) || (CvvStatus?.Equals(other.CvvStatus) == true)) && ((AvsStatus == null && other.AvsStatus == null) || (AvsStatus?.Equals(other.AvsStatus) == true)) && ((AuthResultCode == null && other.AuthResultCode == null) || (AuthResultCode?.Equals(other.AuthResultCode) == true)) && ((ApplicationIdentifier == null && other.ApplicationIdentifier == null) || (ApplicationIdentifier?.Equals(other.ApplicationIdentifier) == true)) && ((ApplicationName == null && other.ApplicationName == null) || (ApplicationName?.Equals(other.ApplicationName) == true)) && ((ApplicationCryptogram == null && other.ApplicationCryptogram == null) || (ApplicationCryptogram?.Equals(other.ApplicationCryptogram) == true)) && ((VerificationMethod == null && other.VerificationMethod == null) || (VerificationMethod?.Equals(other.VerificationMethod) == true)) && ((VerificationResults == null && other.VerificationResults == null) || (VerificationResults?.Equals(other.VerificationResults) == true)) && ((StatementDescription == null && other.StatementDescription == null) || (StatementDescription?.Equals(other.StatementDescription) == true)) && ((DeviceDetails == null && other.DeviceDetails == null) || (DeviceDetails?.Equals(other.DeviceDetails) == true)) && ((CardPaymentTimeline == null && other.CardPaymentTimeline == null) || (CardPaymentTimeline?.Equals(other.CardPaymentTimeline) == true)) && ((RefundRequiresCardPresence == null && other.RefundRequiresCardPresence == null) || (RefundRequiresCardPresence?.Equals(other.RefundRequiresCardPresence) == true)) && ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true))); }