public void GetMedicineList_InvalidData_ModelStateError()
        {
            // Arrange
            var medicinesController = new MedicinesController(It.IsAny <IMedicinesRepository>());

            medicinesController.ModelState.AddModelError(string.Empty, string.Empty);

            // Act
            var result   = medicinesController.GetMedicineList(It.IsAny <GetMedicinesViewModel>()) as BadRequestObjectResult;
            var response = result.Value as List <OperationError>;

            // Assert
            Assert.AreEqual((int)HttpStatusCode.BadRequest, result.StatusCode);
            Assert.IsNotNull(response);
            Assert.AreEqual(ErrorResources.ModelStateError, response.Single().Message);
        }
        public void GetMedicineList_CorrectData_ListOfMedicines()
        {
            // Arrange
            mock.Setup(x => x.GetMedicineList(It.IsAny <GetMedicinesViewModel>()))
            .Returns(() =>
                     new OperationResult <IEnumerable <MedicineHeader> >(new List <MedicineHeader>(returnedMedicineList)));

            var medicinesController = new MedicinesController(mock.Object);

            // Act
            var result   = medicinesController.GetMedicineList(It.IsAny <GetMedicinesViewModel>()) as OkObjectResult;
            var response = result.Value as Result <IEnumerable <MedicineHeader> >;

            // Assert
            Assert.AreEqual((int)HttpStatusCode.OK, result.StatusCode);
            Assert.IsNotNull(response.Items);
            Assert.AreEqual(2, response.TotalCount);
            Assert.AreEqual(2, response.Items.Count());
        }
        public void GetMedicineList_DatabaseConnectionProblem_DatabaseError()
        {
            // Arrange
            mock.Setup(x => x.GetMedicineList(It.IsAny <GetMedicinesViewModel>()))
            .Returns(() =>
                     new OperationResult <IEnumerable <MedicineHeader> >(
                         new OperationError((int)ErrorCodes.InternalServerError, ErrorResources.DatabaseError)));

            var medicinesController = new MedicinesController(mock.Object);

            // Act
            var result   = medicinesController.GetMedicineList(It.IsAny <GetMedicinesViewModel>()) as BadRequestObjectResult;
            var response = result.Value as IEnumerable <OperationError>;

            // Assert
            Assert.AreEqual((int)HttpStatusCode.BadRequest, result.StatusCode);
            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.Count());
            Assert.AreEqual(ErrorResources.DatabaseError, response.Single().Message);
            Assert.AreEqual((int)ErrorCodes.InternalServerError, response.Single().ErrorCode);
        }