public void LoadBillItemDetailViewModelsSortedByPositionViaPassedBill() { // Arrange Bill bill = ModelFactory.GetDefaultBill(); bill.BillItems.Clear(); BillItem billItem1 = new BillItem() { Position = 2 }; BillItem billItem2 = new BillItem() { Position = 1 }; bill.AddBillItem(billItem1); bill.AddBillItem(billItem2); // Act this._billItemEditViewModel.LoadBill(bill); // Assert this._billItemEditViewModel.BillItemDetailViewModels.Should().HaveCount(2); this._billItemEditViewModel.BillItemDetailViewModels[0].Position.Should().Be(1); this._billItemEditViewModel.BillItemDetailViewModels[1].Position.Should().Be(2); }
public void MovesItemDown() { // Arrange Bill bill = new Bill(); for (int i = 0; i < 5; i++) { BillItem billItem = ModelFactory.GetDefaultBillItem(); billItem.Position = i + 1; billItem.Amount = i + 1; bill.AddBillItem(billItem); } // Act this._billItemEditViewModel.LoadBill(bill); Messenger.Default.Send(new NotificationMessage <bool>(true, Resources.Message_EnableStateForBillItemEditVM)); this._billItemEditViewModel.SelectedBillItemDetailViewModel = this._billItemEditViewModel.BillItemDetailViewModels[2]; this._billItemEditViewModel.MoveItemDownCommand.RelayCommand.Execute(null); // Assert this._billItemEditViewModel.BillItemDetailViewModels[2].Position.Should().Be(3); this._billItemEditViewModel.BillItemDetailViewModels[2].Amount.Should().Be(4); this._billItemEditViewModel.BillItemDetailViewModels[3].Position.Should().Be(4); this._billItemEditViewModel.BillItemDetailViewModels[3].Amount.Should().Be(3); }
public void UpdatesPositionsWhenBillItemWasDeleted() { // Arrange Bill bill = new Bill(); for (int i = 0; i < 5; i++) { BillItem billItem = ModelFactory.GetDefaultBillItem(); billItem.Position = i + 1; bill.AddBillItem(billItem); } // Act this._billItemEditViewModel.LoadBill(bill); this._billItemEditViewModel.SelectedBillItemDetailViewModel = this._billItemEditViewModel.BillItemDetailViewModels[2]; Messenger.Default.Send(new NotificationMessage <bool>(true, Resources.Message_EnableStateForBillItemEditVM)); this._billItemEditViewModel.DeleteItemCommand.RelayCommand.Execute(null); // Assert for (int i = 0; i < this._billItemEditViewModel.BillItemDetailViewModels.Count; i++) { int currentPosition = i + 1; this._billItemEditViewModel.BillItemDetailViewModels[i].Position.Should().Be(currentPosition); } }
public void ThrowExceptionWhenNullBillItemShouldBeAddedToBill() { // Arrange Bill bill = new Bill(); // Act Action action = () => bill.AddBillItem(null); // Assert action.ShouldThrow <ArgumentNullException>(); }
public void CanAddBillItemToBill() { // Arrange Bill bill = new Bill(); BillItem billItem = new BillItem(); // Act bill.AddBillItem(billItem); // Assert bill.BillItems.Should().NotBeEmpty(); }
public void GetClonedBill() { // Arrange Bill bill = ModelFactory.GetDefaultBill(); BillItem billItem = ModelFactory.GetDefaultBillItem(); bill.AddBillItem(billItem); // Act Bill copiedBill = (Bill)bill.Clone(); // Assert bill.Equals(copiedBill).Should().BeTrue(); }
public void BillsUnequalIfBillItemsHaveDifferentQuantity() { // Arrange Bill bill1 = ModelFactory.GetDefaultBill(); Bill bill2 = ModelFactory.GetDefaultBill(); BillItem billItem = ModelFactory.GetDefaultBillItem(); bill1.AddBillItem(billItem); // Act bool isEqual = bill1.Equals(bill2); // Assert isEqual.Should().BeFalse(); }
public void BillsEqualIfBothBillsHaveSameValuesAndSameBillItems() { // Arrange Bill bill1 = ModelFactory.GetDefaultBill(); Bill bill2 = ModelFactory.GetDefaultBill(); BillItem billDetail1 = ModelFactory.GetDefaultBillItem(); BillItem billDetail2 = ModelFactory.GetDefaultBillItem(); bill1.AddBillItem(billDetail1); bill2.AddBillItem(billDetail2); // Act bool isEqual = bill1.Equals(bill2); // Assert isEqual.Should().BeTrue(); }
public void BillsUnequalIfBillItemsDiffer() { // Arrange Bill bill1 = ModelFactory.GetDefaultBill(); Bill bill2 = ModelFactory.GetDefaultBill(); BillItem billDetail1 = ModelFactory.GetDefaultBillItem(); BillItem billDetail2 = ModelFactory.GetDefaultBillItem(); billDetail2.ArticleNumber = 5; bill1.AddBillItem(billDetail1); bill2.AddBillItem(billDetail2); // Act bool isEqual = bill1.Equals(bill2); // Assert isEqual.Should().BeFalse(); }
public void CanNotMoveItemDownWhenNoItemIsSelected() { // Arrange Bill bill = new Bill(); for (int i = 0; i < 5; i++) { BillItem billItem = ModelFactory.GetDefaultBillItem(); billItem.Position = i + 1; billItem.Amount = i + 1; bill.AddBillItem(billItem); } // Act this._billItemEditViewModel.LoadBill(bill); Messenger.Default.Send(new NotificationMessage <bool>(true, Resources.Message_EnableStateForBillItemEditVM)); // Assert this._billItemEditViewModel.MoveItemDownCommand.RelayCommand.CanExecute(null).Should().BeFalse(); }
public void CanNotMoveItemDownWhenEditingNotEnabled() { // Arrange Bill bill = new Bill(); for (int i = 0; i < 5; i++) { BillItem billItem = ModelFactory.GetDefaultBillItem(); billItem.Position = i + 1; billItem.Amount = i + 1; bill.AddBillItem(billItem); } // Act this._billItemEditViewModel.LoadBill(bill); this._billItemEditViewModel.SelectedBillItemDetailViewModel = this._billItemEditViewModel.BillItemDetailViewModels[2]; // Assert this._billItemEditViewModel.MoveItemDownCommand.RelayCommand.CanExecute(null).Should().BeFalse(); }