Пример #1
0
        public void GetAllRooms_WhenDatabaseIsEmpty_ReturnEmpty(int expectedStatusCode)
        {
            // Arrange
            _mockService.Setup(s => s.GetAllRooms()).Returns(Task.FromResult((new List <Room>()).AsQueryable()));

            // Action
            var response = _controller.GetAllRooms().GetAwaiter().GetResult();
            var result   = response.Result as ObjectResult;

            // Assert
            Assert.That(result.StatusCode == expectedStatusCode);
            Assert.That(response, Is.InstanceOf(typeof(ActionResult <ServiceResponse <List <Resource> > >)));
            var resultValue = result.Value as ServiceResponse <List <Resource> >;

            Assert.That(resultValue.Message, Is.Null);
            Assert.That(resultValue.Data.Count == 0);
            Utilities.PrintOut(result);
        }