コード例 #1
0
        public void SendRequest_Request_Null_Fails()
        {
            // Arrange
            _autoMockContainer
            .Register <IRequestService, RequestService>();

            var mockUnitOfWork = _autoMockContainer
                                 .GetMock <IUnitOfWork>();

            var requestEntity = new Domain.Entities.Request();

            mockUnitOfWork
            .Setup(uow => uow.CreateEntity <Domain.Entities.Request>())
            .Returns(requestEntity);

            _autoMockContainer
            .GetMock <IUnitOfWorkFactory>().Setup(uowf => uowf.Create())
            .Returns(mockUnitOfWork.Object);

            _autoMockContainer
            .GetMock <IDateTimeService>()
            .Setup(dts => dts.GetCurrentDateAndTime())
            .Returns(DateTime.Now);

            // Act
            Request request = null;

            Assert.ThrowsDelegate sendRequestAction = () => _autoMockContainer.Resolve <IRequestService>().CreateRequest(request);

            // Assert
            Assert.Throws <ArgumentNullException>(sendRequestAction);
        }
コード例 #2
0
 public Request Create(Domain.Entities.Request request)
 {
     return(new Request()
     {
         Headers = request.Headers.Select(_headerFactory.Create).ToList(),
         Id = request.Id,
         Name = request.RequestName,
         Url = request.Url,
         GroupId = request.GroupId
     });
 }
コード例 #3
0
        public void SendRequest_Request_NonEmpty_Passes()
        {
            // Arrange
            _autoMockContainer
                .Register<IRequestService, RequestService>();

            var mockUnitOfWork = _autoMockContainer
                .GetMock<IUnitOfWork>();

            var requestEntity = new Domain.Entities.Request();

            mockUnitOfWork
                .Setup(uow => uow.CreateEntity<Domain.Entities.Request>())
                .Returns(requestEntity);

            _autoMockContainer
                .GetMock<IUnitOfWorkFactory>().Setup(uowf => uowf.Create())
                .Returns(mockUnitOfWork.Object);

            _autoMockContainer
                .GetMock<IDateTimeService>()
                .Setup(dts => dts.GetCurrentDateAndTime())
                .Returns(DateTime.Now);

            // Act
            Request request = new Request
                                  {
                                      Type = RequestType.Operation,
                                      //RequestString = "Test operation"
                                  };

            Assert.ThrowsDelegate sendRequestAction = () => _autoMockContainer.Resolve<IRequestService>().CreateRequest(request);

            // Assert
            Assert.DoesNotThrow(sendRequestAction);
            //Assert.Equal(requestEntity.RequestText, request.RequestString);
            Assert.Equal(requestEntity.RequestType, (Domain.Entities.RequestType)request.Type);
        }
コード例 #4
0
        public void SendRequest_Request_NonEmpty_Passes()
        {
            // Arrange
            _autoMockContainer
            .Register <IRequestService, RequestService>();

            var mockUnitOfWork = _autoMockContainer
                                 .GetMock <IUnitOfWork>();

            var requestEntity = new Domain.Entities.Request();

            mockUnitOfWork
            .Setup(uow => uow.CreateEntity <Domain.Entities.Request>())
            .Returns(requestEntity);

            _autoMockContainer
            .GetMock <IUnitOfWorkFactory>().Setup(uowf => uowf.Create())
            .Returns(mockUnitOfWork.Object);

            _autoMockContainer
            .GetMock <IDateTimeService>()
            .Setup(dts => dts.GetCurrentDateAndTime())
            .Returns(DateTime.Now);

            // Act
            Request request = new Request
            {
                Type = RequestType.Operation,
                //RequestString = "Test operation"
            };

            Assert.ThrowsDelegate sendRequestAction = () => _autoMockContainer.Resolve <IRequestService>().CreateRequest(request);

            // Assert
            Assert.DoesNotThrow(sendRequestAction);
            //Assert.Equal(requestEntity.RequestText, request.RequestString);
            Assert.Equal(requestEntity.RequestType, (Domain.Entities.RequestType)request.Type);
        }
コード例 #5
0
        public void SendRequest_Request_Null_Fails()
        {
            // Arrange
            _autoMockContainer
                .Register<IRequestService, RequestService>();

            var mockUnitOfWork = _autoMockContainer
                .GetMock<IUnitOfWork>();

            var requestEntity = new Domain.Entities.Request();

            mockUnitOfWork
                .Setup(uow => uow.CreateEntity<Domain.Entities.Request>())
                .Returns(requestEntity);

            _autoMockContainer
                .GetMock<IUnitOfWorkFactory>().Setup(uowf => uowf.Create())
                .Returns(mockUnitOfWork.Object);

            _autoMockContainer
                .GetMock<IDateTimeService>()
                .Setup(dts => dts.GetCurrentDateAndTime())
                .Returns(DateTime.Now);

            // Act
            Request request = null;

            Assert.ThrowsDelegate sendRequestAction = () => _autoMockContainer.Resolve<IRequestService>().CreateRequest(request);

            // Assert
            Assert.Throws<ArgumentNullException>(sendRequestAction);
        }