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); }
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 }); }
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); }
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); }
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); }