public void ShouldCheckTypeOfInstanceResultAfterCreateFromPatientsController()
        {
            _patientsController = new PatientsController(_patientRepository);

            var expectedType = typeof(ViewResult);
            var value        = _patientsController.Create();

            Assert.IsInstanceOfType(value, expectedType);
        }
        public void ShouldCheckTypeOfInstanceResultAfterCreateFromPatientsController_WithFakeRepository()
        {
            _patientsController = new PatientsController(_fakePatientRepository);

            var expectedType = typeof(ActionResult);
            var value        = _patientsController.Create(new Patient());

            Assert.IsInstanceOfType(value, expectedType);
        }
Ejemplo n.º 3
0
        public void Create()
        {
            // Arrange
            PatientsController controller = new PatientsController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Ejemplo n.º 4
0
        public async Task PatientsControllerCreate_ValidCreatePatientCommand_CommandSentSuccessfully()
        {
            int successfulCreationId = 1;
            var mediatorMock         = Substitute.For <IMediator>();
            var loggerMock           = Substitute.For <ILogger <PatientsController> >();

            mediatorMock.Send(Arg.Any <CreatePatientCommand>()).Returns(successfulCreationId);
            CreatePatientCommand testCommand = new CreatePatientCommand {
                Surname = "Steve"
            };
            var sut = new PatientsController(mediatorMock, loggerMock);

            var result = await sut.Create(testCommand);

            var okResult = result as OkObjectResult;

            Assert.IsNotNull(okResult);
            Assert.That(okResult.StatusCode, Is.EqualTo(200));
            Assert.That(okResult.Value, Is.EqualTo(successfulCreationId));
            await mediatorMock.Received(1).Send(Arg.Is <CreatePatientCommand>(x => x.Surname == testCommand.Surname));

            loggerMock.Received(1);
        }