public void AnyCustomerIdAndBranch_CallsDeleteDetail() { // arrange Mock <IMandatoryItemsListHeadersRepository> mockHeaderRepo = new Mock <IMandatoryItemsListHeadersRepository>(); Mock <IMandatoryItemsListDetailsRepository> mockDetailsRepo = new Mock <IMandatoryItemsListDetailsRepository>(); MandatoryItemsListLogicImpl testunit = new MandatoryItemsListLogicImpl(mockHeaderRepo.Object, mockDetailsRepo.Object); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "123456" }; int testId = 1; MandatoryItemsListDetail testDetail = new MandatoryItemsListDetail { CatalogId = "FUT", ItemNumber = "123456", Each = false, LineNumber = 1, Id = testId }; // act testunit.DeleteMandatoryItems(testDetail); // assert - Always returns what is setup provided the mock is called mockDetailsRepo.Verify(h => h.Delete(testId), Times.Once(), "Error updating"); }
public void GoodItem_ReturnsValue() { // arrange MandatoryItemsListDetail test = MakeDetail(); bool expected = true; // act // assert test.Active .Should() .Be(expected); }
public void GoodDetail_ReturnsNullProprietaryCustomers() { // arrange MandatoryItemsListDetail detail = MakeDetail(); // act ListItemModel results = detail.ToWebModel(); // assert results.ProprietaryCustomers .Should() .BeNull(); }
public void GoodDetail_ReturnsNullToDate() { // arrange MandatoryItemsListDetail detail = MakeDetail(); // act ListItemModel results = detail.ToWebModel(); // assert results.ToDate .Should() .BeNull(); }
public void GoodItem_HasDefaultValue() { // arrange MandatoryItemsListDetail test = new MandatoryItemsListDetail(); bool expected = false; // act // assert test.Active .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedType() { // arrange MandatoryItemsListDetail detail = MakeDetail(); ListType expected = ListType.Mandatory; // act ListItemModel results = detail.ToWebModel(); // assert results.Type .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCustomInveotryItemId() { // arrange MandatoryItemsListDetail detail = MakeDetail(); int expected = 0; // act ListItemModel results = detail.ToWebModel(); // assert results.CustomInventoryItemId .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedActive() { // arrange MandatoryItemsListDetail detail = MakeDetail(); bool expected = true; // act ListItemModel results = detail.ToWebModel(); // assert results.Active .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCatalogId() { // arrange MandatoryItemsListDetail detail = MakeDetail(); string expected = "FUT"; // act ListItemModel results = detail.ToWebModel(); // assert results.CatalogId .Should() .Be(expected); }
public void GoodDetail_ReturnsIsDeleteAsFalse() { // arrange MandatoryItemsListDetail detail = MakeDetail(); bool expected = false; // act ListItemModel results = detail.ToWebModel(); // assert results.IsDelete .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedPosition() { // arrange MandatoryItemsListDetail detail = MakeDetail(); int expected = 7; // act ListItemModel results = detail.ToWebModel(); // assert results.Position .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedItemNumber() { // arrange MandatoryItemsListDetail detail = MakeDetail(); string expected = "123456"; // act ListItemModel results = detail.ToWebModel(); // assert results.ItemNumber .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCreatedUtc() { // arrange MandatoryItemsListDetail detail = MakeDetail(); DateTime expected = new DateTime(2017, 7, 20, 10, 44, 0, DateTimeKind.Utc); // act ListItemModel results = detail.ToWebModel(); // assert results.CreatedUtc .Should() .Be(expected); }
public void GoodDetail_ReturnsQuantityOfZero() { // arrange MandatoryItemsListDetail detail = MakeDetail(); int expected = 0; // act ListItemModel results = detail.ToWebModel(); // assert results.Quantity .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedEach() { // arrange bool expected = true; int headerId = 1; ListItemModel model = MakeModel(); // act MandatoryItemsListDetail results = model.ToMandatoryItemsListDetail(headerId); // assert results.Each .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedCatalogId() { // arrange string expected = "FUT"; int headerId = 1; ListItemModel model = MakeModel(); // act MandatoryItemsListDetail results = model.ToMandatoryItemsListDetail(headerId); // assert results.CatalogId .Should() .Be(expected); }
public void GoodModel_ReturnsExpecteQuantity() { // arrange int expected = 17; int headerId = 1; ListItemModel model = MakeModel(); // act MandatoryItemsListDetail results = model.ToMandatoryItemsListDetail(headerId); // assert results.Quantity .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedItemNumber() { // arrange string expected = "123456"; int headerId = 1; ListItemModel model = MakeModel(); // act MandatoryItemsListDetail results = model.ToMandatoryItemsListDetail(headerId); // assert results.ItemNumber .Should() .Be(expected); }
public static ListItemModel ToWebModel(this MandatoryItemsListDetail value) { return(new ListItemModel() { Active = value.Active, ListItemId = value.Id, Type = ListType.Mandatory, ItemNumber = value.ItemNumber, Each = value.Each ?? false, Quantity = value.Quantity, CatalogId = value.CatalogId, Position = value.LineNumber, ModifiedUtc = value.ModifiedUtc, CreatedUtc = value.CreatedUtc }); }
public static MandatoryItemsListDetail ToMandatoryItemsListDetail(this ListItemModel model, long headerId = 0) { MandatoryItemsListDetail item = new MandatoryItemsListDetail() { Active = true, CatalogId = model.CatalogId, Each = model.Each ?? false, Id = model.ListItemId, Quantity = model.Quantity, ItemNumber = model.ItemNumber, HeaderId = headerId, LineNumber = model.Position }; return(item); }
public void PartialDetail_ReturnsNullEach() { // arrange IMandatoryItemsListDetailsRepository repo = MakeRepo(); // act MandatoryItemsListDetail detail = MakeDetail(); detail.Each = null; repo.Save(detail); List<MandatoryItemsListDetail> details = repo.GetAllByHeader(GOOD_HEADER_ID); // assert details.First(x => x.ItemNumber.Equals(NEW_ITEM_NUMBER)) .Each .Should() .BeNull(); }
public long Save(MandatoryItemsListDetail model) { DynamicParameters parms = new DynamicParameters(); parms.Add(PARMNAME_ID, model.Id); parms.Add(PARMNAME_PARENT_MANDATORY_ITEMS_HEADER_ID, model.HeaderId); parms.Add(PARMNAME_ITEMNUMBER, model.ItemNumber); parms.Add(PARMNAME_EACH, model.Each); parms.Add(PARMNAME_CATALOG_ID, model.CatalogId); parms.Add(PARMNAME_ACTIVE, model.Active); parms.Add(PARMNAME_LINENUMBER, model.LineNumber); parms.Add(PARMNAME_QUANTITY, model.Quantity); parms.Add(PARMNAME_RETURNVALUE, direction: ParameterDirection.Output, dbType: DbType.Int64); ExecuteSPCommand(SPNAME_SAVE, parms); return(parms.Get <long>(PARMNAME_RETURNVALUE)); }
public void SaveDetail(UserSelectedContext catalogInfo, MandatoryItemsListDetail detail) { if (detail.HeaderId == 0) { MandatoryItemsListHeader header = _headersRepo.GetListHeaderForCustomer(catalogInfo); if (header == null) { detail.HeaderId = _headersRepo.SaveMandatoryItemsHeader(new MandatoryItemsListHeader { BranchId = catalogInfo.BranchId, CustomerNumber = catalogInfo.CustomerId }); } else { detail.HeaderId = header.Id; } } _detailsRepo.Save(detail); }
public ListModel SaveList(UserProfile user, UserSelectedContext catalogInfo, ListModel list) { MandatoryItemsListHeader header = _headersRepo.GetListHeaderForCustomer(catalogInfo); if (header == null) { foreach (var item in list.Items) { MandatoryItemsListDetail detail = item.ToMandatoryItemsListDetail(0); detail.Active = !item.IsDelete; SaveDetail(catalogInfo, detail); } } else { foreach (var item in list.Items) { MandatoryItemsListDetail detail = item.ToMandatoryItemsListDetail(header.Id); detail.Active = !item.IsDelete; SaveDetail(catalogInfo, detail); } } return(ReadList(user, catalogInfo, false)); }
public void DeleteMandatoryItems(MandatoryItemsListDetail detail) { _detailsRepo.Delete(detail.Id); }