예제 #1
0
            public void AnyCustomerIdAndBranch_WhenIsDeleteIsTrueAndActiveIsTrueSetsActiveToFalse()
            {
                // 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"
                };
                UserProfile fakeProfile = new UserProfile();
                ListModel   testList    = new ListModel {
                    ListId   = 1,
                    BranchId = "FUT",
                    Items    = new List <ListItemModel> {
                        new ListItemModel {
                            ListItemId = 1,
                            ItemNumber = "123456",
                            Active     = true,
                            IsDelete   = true
                        }
                    }
                };

                // act
                testunit.SaveList(fakeProfile, testcontext, testList);

                // assert - Always returns what is setup provided the mock is called
                mockDetailsRepo.Verify(h => h.Save(It.Is <MandatoryItemsListDetail>(d => d.Active.Equals(false))), Times.Once(), "Error updating");
            }
예제 #2
0
            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");
            }
예제 #3
0
            public void AnyCustomerIdAndBranch_Completes()
            {
                // 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"
                };
                UserProfile fakeUser = new UserProfile();

                // act
                testunit.CreateList(fakeUser, testcontext);

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