public void CreateWithProductItemDefaults() { var salesOrder = new SalesOrders(this.Session).Extent().FirstOrDefault(); var before = new SalesOrderItems(this.Session).Extent().ToArray(); var expected = new SalesOrderItemBuilder(this.Session).WithSerialisedProductDefaults().Build(); salesOrder.AddSalesOrderItem(expected); this.Session.Derive(); Assert.True(expected.ExistDescription); Assert.True(expected.ExistComment); Assert.True(expected.ExistInternalComment); Assert.True(expected.ExistInvoiceItemType); Assert.True(expected.ExistProduct); Assert.True(expected.ExistSerialisedItem); Assert.True(expected.ExistQuantityOrdered); Assert.True(expected.ExistAssignedUnitPrice); var expectedDescription = expected.Description; var expectedComment = expected.Comment; var expectedInternalComment = expected.InternalComment; var expectedInvoiceItemType = expected.InvoiceItemType; var expectedProduct = expected.Product; var expectedSerialisedItem = expected.SerialisedItem; var expectedQuantityOrdered = expected.QuantityOrdered; var expectedAssignedUnitPrice = expected.AssignedUnitPrice; this.salesOrderListPage.Table.DefaultAction(salesOrder); var salesOrderOverview = new SalesOrderOverviewComponent(this.salesOrderListPage.Driver); var salesOrderItemOverviewPanel = salesOrderOverview.SalesorderitemOverviewPanel.Click(); var salesOrderItemCreate = salesOrderItemOverviewPanel .CreateSalesOrderItem() .BuildForProductItemDefaults(expected); this.Session.Rollback(); salesOrderItemCreate.SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new SalesOrderItems(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var actual = after.Except(before).First(); Assert.Equal(expectedDescription, actual.Description); Assert.Equal(expectedComment, actual.Comment); Assert.Equal(expectedInternalComment, actual.InternalComment); Assert.Equal(expectedInvoiceItemType, actual.InvoiceItemType); Assert.Equal(expectedProduct, actual.Product); Assert.Equal(expectedSerialisedItem, actual.SerialisedItem); Assert.Equal(expectedQuantityOrdered, actual.QuantityOrdered); Assert.Equal(expectedAssignedUnitPrice, actual.AssignedUnitPrice); }
public void EditWithSerialisedProductItemDefaults() { var salesOrder = new SalesOrders(this.Session).Extent().FirstOrDefault(); var before = new SalesOrderItems(this.Session).Extent().ToArray(); var disposableSalesOrder = new SalesOrderBuilder(this.Session).WithOrganisationInternalDefaults(this.internalOrganisation).Build(); var expected = disposableSalesOrder.SalesOrderItems.First(v => v.InvoiceItemType.IsProductItem); var salesOrderItem = salesOrder.SalesOrderItems.First(v => v.InvoiceItemType.IsProductItem); var id = salesOrderItem.Id; this.Session.Derive(); var expectedDescription = expected.Description; var expectedComment = expected.Comment; var expectedInternalComment = expected.InternalComment; var expectedInvoiceItemType = expected.InvoiceItemType; var expectedProduct = expected.Product; var expectedSerialisedItem = expected.SerialisedItem; var expectedQuantityOrdered = expected.QuantityOrdered; var expectedAssignedUnitPrice = expected.AssignedUnitPrice; this.salesOrderListPage.Table.DefaultAction(salesOrder); var salesOrderOverview = new SalesOrderOverviewComponent(this.salesOrderListPage.Driver); var salesOrderItemOverviewPanel = salesOrderOverview.SalesorderitemOverviewPanel.Click(); salesOrderItemOverviewPanel.Table.DefaultAction(salesOrderItem); var salesOrderItemEdit = new SalesOrderItemEditComponent(this.Driver); salesOrderItemEdit.Description.Set(expected.Description); salesOrderItemEdit.Comment.Set(expected.Comment); salesOrderItemEdit.InternalComment.Set(expected.InternalComment); salesOrderItemEdit.PriceableAssignedUnitPrice_2.Set(expected.AssignedUnitPrice.ToString()); this.Session.Rollback(); salesOrderItemEdit.SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new SalesOrderItems(this.Session).Extent().ToArray(); var actual = (SalesOrderItem)this.Session.Instantiate(id); Assert.Equal(after.Length, before.Length); Assert.Equal(expectedDescription, actual.Description); Assert.Equal(expectedComment, actual.Comment); Assert.Equal(expectedInternalComment, actual.InternalComment); Assert.Equal(expectedInvoiceItemType, actual.InvoiceItemType); Assert.Equal(expectedAssignedUnitPrice, actual.AssignedUnitPrice); }