Пример #1
0
        public OrganisationControllerTestFixtures SetQueryException <TException>() where TException : Exception, new()
        {
            MediatorMock
            .Setup(m => m.SendAsync(It.IsAny <GetOrganisationQuery>()))
            .Throws <TException>();

            return(this);
        }
Пример #2
0
        public AccountLegalEntityControllerTestFixtures SetQueryResponse(long forAccountLegalEntityId, GetAccountLegalEntityQueryResult sendQueryResult)
        {
            MediatorMock
            .Setup(m => m.Send(
                       It.Is <GetAccountLegalEntityQuery>(request => request.AccountLegalEntityId == forAccountLegalEntityId),
                       It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(sendQueryResult));

            return(this);
        }
            public void should_receive_request_and_send_response()
            {
                // Arrange
                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeReadQuery>(), default(CancellationToken)))
                .ReturnsAsync(AnyEmployeeResponse);

                // Act
                var result = EmployeeControllerUnderTest.Read(AnyEmployeeResponse.EmployeeId).Result;

                // Assert
                Assert.IsType <OkObjectResult>(result);
            }
            public void should_receive_request_and_delete_request()
            {
                // Arrange
                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeDeleteCommand>(), default(CancellationToken)))
                .ReturnsAsync(Unit.Value);

                // Act
                var result = EmployeeControllerUnderTest.Delete(AnyEmployeeResponse.EmployeeId).Result;

                // Assert
                Assert.IsType <OkResult>(result);
            }
Пример #5
0
        public OrganisationControllerTestFixtures SetQueryResult(Organisation organisation)
        {
            var response = new GetOrganisationResponse
            {
                Organisation = organisation
            };

            MediatorMock
            .Setup(m => m.SendAsync(It.Is <GetOrganisationQuery>(goq => goq.OrganisationType == organisation.Type && goq.Identifier == organisation.Code)))
            .ReturnsAsync(() => response);

            return(this);
        }
            public void should_receive_request_and_update_employee()
            {
                // Arrange
                EmployeeRequest inputRequest = new EmployeeRequest()
                {
                    Name    = "joe",
                    Address = "waterloo",
                    Email   = "*****@*****.**"
                };

                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeUpdateCommand>(), default(CancellationToken)))
                .ReturnsAsync(Unit.Value);

                // Act
                var result = EmployeeControllerUnderTest.Update(AnyEmployeeResponse.EmployeeId, inputRequest).Result;

                // Assert
                Assert.IsType <OkResult>(result);
            }
            public void should_receive_request_to_create_employee()
            {
                // Arrange
                var inputRequest = new EmployeeRequest()
                {
                    Name    = "joe",
                    Address = "wellington",
                    Email   = "*****@*****.**"
                };

                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeCreateCommand>(), default(CancellationToken)))
                .ReturnsAsync(employeeCommand);

                // Act
                var result = EmployeeControllerUnderTest.Create(inputRequest).Result;

                // Assert
                Assert.IsType <CreatedResult>(result);
            }
Пример #8
0
        public AuthorizationControllerTestFixture SetCanAccessApprenticeshipToReturnTrue()
        {
            MediatorMock.Setup(x => x.Send(It.IsAny <CanAccessApprenticeshipQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(true);

            return(this);
        }