コード例 #1
0
            public async void Should_return_Throw_and_return_BadRequest_with_created_Leaderboard()
            {
                //Arrange
                var expectedResult = new LeaderBoard {
                    LeaderBoardId = 1
                };

                LeaderBoardRepository
                .Setup(l => l.Add(expectedResult)).Throws(new Exception());


                UnitofWorkMock
                .Setup(m => m.LeaderBoard)
                .Returns(LeaderBoardRepository.Object);

                //Act
                var result = await _uut.Post(expectedResult);

                //Assert
                LeaderBoardRepository.VerifyAll();

                var ErrorResult = Assert.IsType <BadRequestObjectResult>(result);

                Assert.Equal(400, ErrorResult.StatusCode);
            }
コード例 #2
0
            public async void Should_return_CreatedAtActionResult_with_created_Leaderboard()
            {
                //Arrange
                var expectedResult = new LeaderBoard {
                    LeaderBoardId = 1
                };

                LeaderBoardRepository
                .Setup(l => l.Add(expectedResult)).Verifiable();


                UnitofWorkMock
                .Setup(m => m.LeaderBoard)
                .Returns(LeaderBoardRepository.Object);

                //Act
                var result = await _uut.Post(expectedResult);

                //Assert
                LeaderBoardRepository.VerifyAll();

                var response = Assert.IsType <OkObjectResult>(result);

                Assert.Same(expectedResult, response.Value);
            }