public void NullLabel_ReturnsNull() { // arrange var detail = new CustomListDetail() { Active = true, CatalogId = "FDF", CustomInventoryItemId = 15, Each = true, HeaderId = 1, ItemNumber = "100123", Label = null, LineNumber = 300, Par = 17 }; var repo = MakeRepo(); // act var detailId = repo.SaveCustomListDetail(detail); var results = repo.GetCustomListDetails(detail.HeaderId); // assert results.First(d => d.Id == detailId) .Label .Should() .BeNull(); }
public void SaveItem(CustomListDetail item) { // try to find the parent header id if it is not in the model if (item.HeaderId == 0) { const string HEADER_MISSING_TEXT = "No header id was set"; throw new ArgumentException(HEADER_MISSING_TEXT, nameof(item.HeaderId)); } _detailsRepo.SaveCustomListDetail(item); }
public void IniatlizedItem_HasDefaultValue() { // arrange CustomListDetail test = new CustomListDetail(); // act // assert test.Label .Should() .BeNull(); }
public ListModel SaveList(UserProfile user, UserSelectedContext catalogInfo, ListModel list) { CreateOrUpdateList(user, catalogInfo, list.ListId, list.Name, true); foreach (var item in list.Items) { CustomListDetail detail = item.ToCustomListDetail(list.ListId); detail.Active = !item.IsDelete; SaveItem(detail); } return(ReadList(list.ListId, catalogInfo, false)); }
public void GoodItem_ReturnsDefaultValue() { // arrange CustomListDetail fakeItem = MakeItem(); string expected = "Fake Label"; // act // assert fakeItem.Label .Should() .Be(expected); }
public void GoodItem_ReturnsDefaultValue() { // arrange CustomListDetail fakeItem = MakeItem(); int expected = 1592; // act // assert fakeItem.CustomInventoryItemId .Should() .Be(expected); }
public void IniatlizedItem_HasDefaultValue() { // arrange CustomListDetail test = new CustomListDetail(); bool expected = false; // act // assert test.Active .Should() .Be(expected); }
public void GoodItem_ReturnsDefaultValue() { // arrange CustomListDetail fakeItem = MakeItem(); bool expected = true; // act // assert fakeItem.Active .Should() .Be(expected); }
public void IniatlizedItem_HasDefaultValue() { // arrange CustomListDetail test = new CustomListDetail(); int expected = 0; // act // assert test.Par .Should() .Be(expected); }
public void GoodItem_ReturnsDefaultValue() { // arrange CustomListDetail fakeItem = MakeItem(); decimal expected = 19.5m; // act // assert fakeItem.Par .Should() .Be(expected); }
public void GoodDetail_ReturnsNullToDate() { // arrange CustomListDetail detail = MakeDetail(); // act ListItemModel results = detail.ToWebModel(); // assert results.ToDate .Should() .BeNull(); }
public void GoodDetail_ReturnsNullProprietaryCustomers() { // arrange CustomListDetail detail = MakeDetail(); // act ListItemModel results = detail.ToWebModel(); // assert results.ProprietaryCustomers .Should() .BeNull(); }
public void GoodDetail_ReturnsIsDeleteAsFalse() { // arrange CustomListDetail detail = MakeDetail(); bool expected = false; // act ListItemModel results = detail.ToWebModel(); // assert results.IsDelete .Should() .Be(expected); }
public void BadHeaderId_ThrowsArgumentException() { // arrange CustomListDetail detail = new CustomListDetail(); MockDependents mockDependents = new MockDependents(); ICustomListLogic logic = MakeMockLogic(mockDependents); // act Action act = () => logic.SaveItem(detail); // assert act.Should().Throw <ArgumentException>(); }
public void GoodDetail_ReturnsExpectedPosition() { // arrange CustomListDetail detail = MakeDetail(); int expected = 17; // act ListItemModel results = detail.ToWebModel(); // assert results.Position .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedItemNumber() { // arrange CustomListDetail detail = MakeDetail(); string expected = "123456"; // act ListItemModel results = detail.ToWebModel(); // assert results.ItemNumber .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCreatedUtc() { // arrange CustomListDetail detail = MakeDetail(); DateTime expected = new DateTime(2017, 7, 5, 16, 41, 0, DateTimeKind.Utc); // act ListItemModel results = detail.ToWebModel(); // assert results.CreatedUtc .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCustomInveotryItemId() { // arrange CustomListDetail detail = MakeDetail(); int expected = 101; // act ListItemModel results = detail.ToWebModel(); // assert results.CustomInventoryItemId .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedType() { // arrange CustomListDetail detail = MakeDetail(); ListType expected = ListType.Custom; // act ListItemModel results = detail.ToWebModel(); // assert results.Type .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCatalogId() { // arrange CustomListDetail detail = MakeDetail(); string expected = "FUT"; // act ListItemModel results = detail.ToWebModel(); // assert results.CatalogId .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedActive() { // arrange CustomListDetail detail = MakeDetail(); bool expected = true; // act ListItemModel results = detail.ToWebModel(); // assert results.Active .Should() .Be(expected); }
public void GoodDetail_ReturnsQuantityOfZero() { // arrange CustomListDetail detail = MakeDetail(); int expected = 0; // act ListItemModel results = detail.ToWebModel(); // assert results.Quantity .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedLabel() { // arrange string expected = "Fake Label"; int headerId = 1; ListItemModel model = MakeModel(); // act CustomListDetail results = model.ToCustomListDetail(headerId); // assert results.Label .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedPar() { // arrange decimal expected = 9.76m; int headerId = 1; ListItemModel model = MakeModel(); // act CustomListDetail results = model.ToCustomListDetail(headerId); // assert results.Par .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedLineNumber() { // arrange int expected = 23; int headerId = 1; ListItemModel model = MakeModel(); // act CustomListDetail results = model.ToCustomListDetail(headerId); // assert results.LineNumber .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedEach() { // arrange bool expected = true; int headerId = 1; ListItemModel model = MakeModel(); // act CustomListDetail results = model.ToCustomListDetail(headerId); // assert results.Each .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedCustomInventoryItemId() { // arrange int expected = 1900; int headerId = 1; ListItemModel model = MakeModel(); // act CustomListDetail results = model.ToCustomListDetail(headerId); // assert results.CustomInventoryItemId .Should() .Be(expected); }
public void GoodHeaderId_CallsTheExpectedMethod() { // arrange CustomListDetail detail = new CustomListDetail { HeaderId = 17 }; MockDependents mockDependents = new MockDependents(); ICustomListLogic logic = MakeMockLogic(mockDependents); // act logic.SaveItem(detail); // assert mockDependents.MockDetailRepo.Verify(r => r.SaveCustomListDetail(It.IsAny <CustomListDetail>()), Times.Once); }
public static ListItemModel ToWebModel(this CustomListDetail value) { return(new ListItemModel() { ListItemId = value.Id, Type = ListType.Custom, ItemNumber = value.ItemNumber, Position = value.LineNumber, Label = value.Label, ParLevel = value.Par, ModifiedUtc = value.ModifiedUtc, CreatedUtc = value.CreatedUtc, Each = value.Each ?? false, CatalogId = value.CatalogId, Active = value.Active, CustomInventoryItemId = value.CustomInventoryItemId ?? 0 }); }
public long SaveCustomListDetail(CustomListDetail model) { DynamicParameters parms = new DynamicParameters(); parms.Add(PARMNAME_ID, model.Id); parms.Add(PARMNAME_ACTIVE, model.Active); parms.Add(PARMNAME_CATALOG, model.CatalogId); parms.Add(PARMNAME_EACH, model.Each); parms.Add(PARMNAME_HEADERID, model.HeaderId); parms.Add(PARMNAME_INVID, model.CustomInventoryItemId); parms.Add(PARMNAME_ITEMNUMBER, model.ItemNumber); parms.Add(PARMNAME_LINENUMBER, model.LineNumber); parms.Add(PARMNAME_LABEL, model.Label); parms.Add(PARMNAME_PAR, model.Par); parms.Add(PARMNAME_RETVAL, dbType: DbType.Int64, direction: ParameterDirection.Output); ExecuteSPCommand(SPNAME_SAVE, parms); return(parms.Get <long>(PARMNAME_RETVAL)); }