コード例 #1
0
        public void When_Unregister_called_with_registered_MockService_Then_removes_MockService()
        {
            var mockService = new MockService();

            MockServiceRepository.Unregister(mockService);

            MockServiceRepository.GetServiceMockById(mockService.ServiceId)
            .Should().BeNull("Because the mockService was unregistered");
        }
コード例 #2
0
        public void When_GetServiceMockById_called_with_registered_port_Then_returns_registered_MockService()
        {
            var mockService = new MockService();

            MockServiceRepository.GetServiceMockById(mockService.ServiceId)
            .Should().Be(mockService, "Because the MockService self-registered.");

            MockServiceRepository.Unregister(mockService);
        }
コード例 #3
0
        public void When_Unregister_called_with_unregistered_MockService_Then_throws_with_useful_message()
        {
            var mockService = new MockService();

            MockServiceRepository.Unregister(mockService);

            Action unregister = () => MockServiceRepository.Unregister(mockService);

            unregister
            .ShouldThrow <InvalidOperationException>("Because that MockService was not registered")
            .WithMessage("MokService not registered", "Because that helps debug the issue");
        }