コード例 #1
0
ファイル: AgentTests.cs プロジェクト: horodynskyi/Insurance
        public async Task AgentTests_GetAgent_NotNull()
        {
            var mockAgent           = new Agent();
            var mockAgentRepository = await new MockAgentRepository().MockGetById(null);
            var mockUnitOfWork      = new MockUnitOfWork().MockGetAgentRepository(mockAgentRepository.Object);
            var agentService        = new AgentService(mockUnitOfWork.Object);
            var agent = await agentService.GetById(2);

            Assert.Null(agent);
            mockUnitOfWork.VerifyGetAgentRepository(Times.Once());
            mockAgentRepository.VerifyGetById(Times.Once());
        }
コード例 #2
0
ファイル: AgentTests.cs プロジェクト: horodynskyi/Insurance
        public async Task AgentTests_GetAllAgents_ReturnsIEnumerableAgents()
        {
            // Arrange
            var mockAgents = new List <Agent> {
                new Agent(),
            };

            var mockAgentRepository = await new MockAgentRepository().MockGetAll(mockAgents);

            var mockUnitOfWork = new MockUnitOfWork().MockGetAgentRepository(mockAgentRepository.Object);

            var agentService = new AgentService(mockUnitOfWork.Object);

            // Act
            var agent = await agentService.GetAll();

            // Assert
            Assert.NotNull(agent);
            mockUnitOfWork.VerifyGetAgentRepository(Times.Once());
            mockAgentRepository.VerifyGetAll(Times.Once());
        }