Example #1
0
    def test_init_function_is_called_when_invoking_get_instance(self):
        init_function = FunctionMock()
        proxy = ExpensiveResourceProxy(init_function)

        proxy.get_instance()

        assert_that(init_function.has_been_called)
Example #2
0
    def test_init_function_is_called_when_invoking_get_instance(self):
        init_function = FunctionMock()
        proxy = ExpensiveResourceProxy(init_function)

        proxy.get_instance()

        assert_that(init_function.has_been_called)
Example #3
0
    def test_result_of_init_function_is_cached_by_the_proxy(self):
        init_function = FunctionMock()
        proxy = ExpensiveResourceProxy(init_function)

        first_instance = proxy.get_instance()
        second_instance = proxy.get_instance()

        assert_that(init_function.number_of_calls, equal_to(1))
        assert_that(first_instance is second_instance)
Example #4
0
    def test_result_of_init_function_is_cached_by_the_proxy(self):
        init_function = FunctionMock()
        proxy = ExpensiveResourceProxy(init_function)

        first_instance = proxy.get_instance()
        second_instance = proxy.get_instance()

        assert_that(init_function.number_of_calls, equal_to(1))
        assert_that(first_instance is second_instance)
Example #5
0
    def test_init_function_is_used_for_getting_the_instance(self):
        proxy = ExpensiveResourceProxy(FunctionMock())

        instance = proxy.get_instance()

        assert_that(instance, equal_to(EXPENSIVE_RESOURCE_STUB))
Example #6
0
    def test_init_function_is_used_for_getting_the_instance(self):
        proxy = ExpensiveResourceProxy(FunctionMock())

        instance = proxy.get_instance()

        assert_that(instance, equal_to(EXPENSIVE_RESOURCE_STUB))