1

My presenter class MyItemsPresenter will look something like so:

class MyItemsPresenter {
    internal var deliveryType: ServiceType = .typeA
    var myItemSections: [MySections] = [.sectionA, .sectionB, .sectionC]
    var didMoveDeals = false    
    private(set) var childViewControllers = [UIViewController]()
    
    var segmentTitles: [String] {
        myItemSections.map { $0.title }
    }

    var selectedOption: String?
        
    func createChildViewControllers() -> [UIViewController] {
        var childViewControllers = [UIViewController]()

        for item in myItemSections {
            switch item {
            case . sectionA:
                childViewControllers.append(MyListWireframe.assembleModuleA())
            case . sectionB:
                childViewControllers.append(MyListWireframe.assembleModuleB())
            case . sectionC:
                childViewControllers.append(MyListWireframe.assembleModuleC())
            default:
                break
            }
        }        
        self.childViewControllers = childViewControllers        
        return childViewControllers
    }
         
    private func resetSections() {
        myItemSections = getOriginalSections()
    }

    private func getOriginalSections() -> [MySections] {
        [.list, .buyItAgain, .clippedDeals, .lastOrder]
    }
    
    func showFirstTwoMenuItems() {
        if myItemSections.count > 2 {
            let upperRange = myItemSections.count-1
            myItemSections.removeSubrange(ClosedRange(uncheckedBounds: (lower: 2, upper: upperRange)))
            childViewControllers.removeSubrange(ClosedRange(uncheckedBounds: (lower: 2, upper: upperRange)))            
        }
    }
}

For writing test cases, I would like to write a Mock Presenter class for the above class say MyItemsPresenterMock. So how will my mock presenter class look? I'm using Quick and Nimble for test cases.

0 Answers0