public void CallToSaveList_DoesSetActiveFlagToTrueWhenIsDeleteFalseAndActiveFalse()
            {
                // arrange
                Mock <IInventoryValuationListHeadersRepository> mockHeaderRepo  = new Mock <IInventoryValuationListHeadersRepository>();
                Mock <IInventoryValuationListDetailsRepository> mockDetailsRepo = new Mock <IInventoryValuationListDetailsRepository>();
                InventoryValuationListLogicImpl testunit    = new InventoryValuationListLogicImpl(mockHeaderRepo.Object, mockDetailsRepo.Object);
                UserSelectedContext             testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile();
                ListModel   testList = new ListModel {
                    ListId         = 1,
                    CustomerNumber = "123456",
                    BranchId       = "FUT",
                    Items          = new List <ListItemModel> {
                        new ListItemModel {
                            ItemNumber = "123456",
                            Active     = false,
                            IsDelete   = false
                        }
                    }
                };

                // act
                ListModel results = testunit.SaveList(fakeUser, testcontext, testList);

                // assert
                mockDetailsRepo.Verify(h => h.SaveInventoryValuationDetail(It.Is <InventoryValuationListDetail>(d => d.Active.Equals(true))), Times.Once(), "Error updating");
            }
            public void AnyCustomerIdAndBranch_CallsDetailsRepoSaveInventoryValuationDetail()
            {
                // arrange
                Mock <IInventoryValuationListHeadersRepository> mockHeaderRepo  = new Mock <IInventoryValuationListHeadersRepository>();
                Mock <IInventoryValuationListDetailsRepository> mockDetailsRepo = new Mock <IInventoryValuationListDetailsRepository>();
                InventoryValuationListLogicImpl testunit    = new InventoryValuationListLogicImpl(mockHeaderRepo.Object, mockDetailsRepo.Object);
                UserSelectedContext             testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile();
                long        fakeId   = 1;
                InventoryValuationListDetail testItem =
                    new InventoryValuationListDetail {
                    CatalogId  = "FUT",
                    ItemNumber = "123456",
                    Each       = false,
                    LineNumber = 1,
                    HeaderId   = 1L
                };

                // act
                testunit.SaveItem(fakeUser, testcontext, fakeId, testItem);

                // assert - Always returns what is setup provided the mock is called
                mockDetailsRepo.Verify(h => h.SaveInventoryValuationDetail(testItem), Times.Once(), "Error updating");
            }
            public void CallToSaveList_DoesCallHeaderRepo()
            {
                // arrange
                Mock <IInventoryValuationListHeadersRepository> mockHeaderRepo  = new Mock <IInventoryValuationListHeadersRepository>();
                Mock <IInventoryValuationListDetailsRepository> mockDetailsRepo = new Mock <IInventoryValuationListDetailsRepository>();
                InventoryValuationListLogicImpl testunit    = new InventoryValuationListLogicImpl(mockHeaderRepo.Object, mockDetailsRepo.Object);
                UserSelectedContext             testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile();
                ListModel   testList = new ListModel {
                    ListId         = 1,
                    CustomerNumber = "123456",
                    BranchId       = "FUT",
                    Items          = new List <ListItemModel> {
                        new ListItemModel {
                            ItemNumber = "123456"
                        }
                    }
                };

                // act
                ListModel results = testunit.SaveList(fakeUser, testcontext, testList);

                // assert
                mockHeaderRepo.Verify(h => h.SaveInventoryValuationListHeader(It.IsAny <InventoryValuationListHeader>()), Times.Once(), "Error updating");
            }
            public void AnyCustomerIdAndBranch_CallsHeaderRepoSave()
            {
                // arrange
                Mock <IInventoryValuationListHeadersRepository> mockHeaderRepo  = new Mock <IInventoryValuationListHeadersRepository>();
                Mock <IInventoryValuationListDetailsRepository> mockDetailsRepo = new Mock <IInventoryValuationListDetailsRepository>();
                InventoryValuationListLogicImpl testunit    = new InventoryValuationListLogicImpl(mockHeaderRepo.Object, mockDetailsRepo.Object);
                UserSelectedContext             testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser   = new UserProfile();
                long        fakeId     = 1;
                string      fakeName   = "Fake Name";
                bool        testActive = true;
                bool        expected   = true;

                // act
                long results = testunit.CreateOrUpdateList(fakeUser, testcontext, fakeId, fakeName, testActive);

                // assert - Always returns what is setup provided the mock is called
                mockHeaderRepo.Verify(h => h.SaveInventoryValuationListHeader(It.IsAny <InventoryValuationListHeader>()), Times.Once(), "Error updating");
            }