コード例 #1
0
        public void Lounge_Service_Should_Add_Lounge_Successfully()
        {
            //Arrange
            var lounge    = ObjectMother.GetDefaultLounge();
            var loungeCmd = ObjectMother.GetLoungeAddCommand();

            _mockLoungeRepository.Setup(r => r.Add(It.IsAny <Lounge>())).Returns(lounge);

            //Action
            var addedLounge = _loungeService.Add(loungeCmd);

            //Assert
            _mockLoungeRepository.Verify(r => r.Add(It.IsAny <Lounge>()), Times.Once);
            addedLounge.Id.Should().Be(lounge.Id);
        }
コード例 #2
0
        public IHttpActionResult Post(LoungeAddCommand LoungeCmd)
        {
            var validator = LoungeCmd.Validate(_service);

            if (!validator.IsValid)
            {
                return(HandleValidationFailure(validator.Errors));
            }

            return(HandleCallback(_service.Add(LoungeCmd)));
        }