예제 #1
0
        public void PostUser()

        {
            var repo = new Mock <RoomsRep>(db);

            RoomsController controller = new RoomsController(repo.Object);

            Rooms user = new Rooms {
                RoomId = 02, RoomType = "NON AC", price = 2250
            };

            var data = controller.Post(user) as OkObjectResult;


            Assert.AreEqual(200, data.StatusCode);
        }
예제 #2
0
        public async void PostRoom_ReturnsCreated_WhenSuccessful()
        {
            mockMapper.Setup(m => m.Map <Room>(It.IsAny <RoomViewModel>()))
            .Returns(kitchen);
            mockMapper.Setup(m => m.Map <RoomViewModel>(It.IsAny <Room>()))
            .Returns(kitchenViewModel);
            mockRepo.Setup(r => r.SaveAllAsync())
            .Returns(Task.FromResult(true));

            var result = await controller.Post(kitchenViewModel);

            var createdResult = result.Should().BeAssignableTo <CreatedAtRouteResult>().Subject;
            var viewModel     = createdResult.Value.Should().BeAssignableTo <RoomViewModel>().Subject;

            viewModel.Name.Should().Be("Kitchen");
        }