public void GetNewPurchaseOrderNo_ExistingId_Valid() { // Arrange string expectedPrefix = $"PO-{DateTime.Now.Year}{DateTime.Now.Month:00}"; var previous = IdService.GetNewPurchaseOrderNo(context); new PurchaseOrderRepository(context).Save(new PurchaseOrder() { PurchaseOrderNo = previous, Status = new StatusService(context).FindStatusByStatusId(16), CreatedDateTime = DateTime.Now.AddDays(1 - DateTime.Today.Day), }); // Act var current = IdService.GetNewPurchaseOrderNo(context); new PurchaseOrderRepository(context).Save(new PurchaseOrder() { PurchaseOrderNo = current, Status = new StatusService(context).FindStatusByStatusId(16), CreatedDateTime = DateTime.Now, }); var previousSerialNoParseResult = Int32.TryParse(previous.Substring(previous.Length - 3), out int previousSerialNo); var resultSerialNoParseResult = Int32.TryParse(current.Substring(current.Length - 3), out int resultSerialNo); // Assert Assert.AreEqual(1, resultSerialNo - previousSerialNo); }
public void GetNewPurchaseOrderNoTest() { // Arrange string expectedPrefix = $"PO-{DateTime.Now.Year}{DateTime.Now.Month:00}"; // Act var result = IdService.GetNewPurchaseOrderNo(context); var serialNoParseResult = Int32.TryParse(result.Substring(result.Length - 3), out int serialNo); // Assert Assert.AreEqual(expectedPrefix, result.Substring(0, 9)); Assert.IsTrue(serialNoParseResult); }