Exemple #1
0
            public async void Should_return_CreatedAtActionResult_with_created_Stats()
            {
                //Arrange
                var expectedResult = new Stats()
                {
                    Time = 30
                };

                var finalResult = new StatsRequest()
                {
                    Time = 30
                };

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


                UnitofWorkMock
                .Setup(m => m.Stats)
                .Returns(StatsRepository.Object);

                MapperMock
                .Setup(m => m.Map <Stats>(finalResult))
                .Returns(expectedResult);

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

                //Assert
                StatsRepository.VerifyAll();
                MapperMock.VerifyAll();

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

                Assert.Same(finalResult, response.Value);
            }
Exemple #2
0
            public async void Should_Return_OkObjectResult_with_one_Stat()
            {
                //Arrange
                var expectedResult = new Stats()
                {
                    StatsId = 1, Time = 20
                };

                var finalResult = new StatsResponse()
                {
                    StatsId = 1, Time = 30
                };

                StatsRepository
                .Setup(x => x.Get(expectedResult.StatsId))
                .ReturnsAsync(expectedResult).Verifiable();

                UnitofWorkMock
                .Setup(m => m.Stats)
                .Returns(StatsRepository.Object);

                MapperMock
                .Setup(m => m.Map <StatsResponse>(expectedResult))
                .Returns(finalResult);

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

                //Assert
                StatsRepository.Verify();
                MapperMock.VerifyAll();

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

                Assert.Same(finalResult, okResult.Value);
            }