public async Task UploadDocument_UploadsToDocumentService() { var fileMock = new Mock <IFormFile>(); _documentApiClient.Setup(x => x.CreateDocument(It.IsAny <DocumentService.SDK.Version.V1.Model.DocumentCreate>())) .ReturnsAsync(new TMS.Infrastructure.Messaging.Common.MessageResult <DocumentService.Domain.Data.DocumentResultRowData>("", "Processed") { ResultData = new DocumentService.Domain.Data.DocumentResultRowData() { DocContentId = 2, DocHeaderId = 1 } }); _svc = CreateService(); var result = await _svc.UploadDocument(new LoadDocumentUploadData() { LoadDocumentType = new LoadDocumentTypeData() { Id = (int)LoadshopDocumentServiceDocumentTypes.ProofOfDelivery }, LoadId = LOAD_ID, File = fileMock.Object }); result.Should().NotBeNull(); _documentApiClient.Verify(x => x.CreateDocument(It.IsAny <DocumentService.SDK.Version.V1.Model.DocumentCreate>()), Times.Once); _db.Verify(x => x.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once); }
public async Task RemoveDocument_Returns_WhenValidDocumentId() { _svc = CreateService(); await _svc.RemoveDocument(LOAD_DOCUMENT_ID); _documentApiClient.Verify(x => x.DeleteDocument(It.IsAny <int>()), Times.Once); _db.Verify(x => x.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once); }
public void GetDocument_Throws_WhenInvalidDocumentId() { _svc = CreateService(); _svc.Awaiting(x => x.GetDocument(Guid.Empty)).Should() .Throw <ValidationException>() .WithMessage("Document not found"); _documentApiClient.Verify(x => x.GetDocumentContent(It.IsAny <int>(), It.IsAny <int>()), Times.Never); }
public void GetDocumentTypes_Terms_ShouldReturnExpectedAgreement() { _svc = CreateService(); var documentTypeDatas = _svc.GetDocumentTypes(); documentTypeDatas.Count().Should().Be(2); documentTypeDatas.Single(x => x.Description == "Proof of Delivery").Should().NotBeNull(); documentTypeDatas.Single(x => x.Description == "Other").Should().NotBeNull(); }
public void RemoveDocument_Throws_WhenInvalidDocumentId() { _svc = CreateService(); _svc.Awaiting(x => x.RemoveDocument(Guid.Empty)).Should() .Throw <ValidationException>() .WithMessage("Document not found"); _documentApiClient.Verify(x => x.DeleteDocument(It.IsAny <int>()), Times.Never); _db.Verify(x => x.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Never); }
public void UploadDocument_Throws_WhenInvalidDocumentType() { _svc = CreateService(); _svc.Awaiting(x => x.UploadDocument(new LoadDocumentUploadData() { LoadDocumentType = null })).Should() .Throw <ValidationException>() .WithMessage("Invalid load document type"); _documentApiClient.Verify(x => x.DeleteDocument(It.IsAny <int>()), Times.Never); _db.Verify(x => x.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Never); }
public async Task GetDocument_Returns_WhenValidDocumentId() { _documentApiClient.Setup(x => x.GetDocumentContent(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new TMS.Infrastructure.Messaging.Client.FileMemoryStream() { FileName = "test.jpg" }); _svc = CreateService(); var result = await _svc.GetDocument(LOAD_DOCUMENT_ID); result.Should().NotBeNull(); result.FileName.Should().Be("test.jpg"); _documentApiClient.Verify(x => x.GetDocumentContent(It.IsAny <int>(), It.IsAny <int>()), Times.Once); }