public void IfOrderLineIsNullStreamShouldNotBeWrittenTo() { HttpResponseBase response = new OutOfContextResponseBuilder().Build(); _downloadProductService.WriteDownloadToResponse(response, new Order(), null); A.CallTo(() => _fileSystem.WriteToStream(A <string> ._, A <Stream> ._)).MustNotHaveHappened(); }
public void IfAllChecksPassEcommerceResultShouldBeCorrectOrderline() { var order = new Order(); var orderLine = new OrderLineBuilder().WithFileUrl("test-file-url").Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); A.CallTo(() => _fileSystem.Exists("test-file-url")).Returns(true); var writeDownloadToResponse = _downloadProductService.WriteDownloadToResponse(response, order, orderLine); writeDownloadToResponse.As <EcommerceDownloadResult>().OrderLine.Should().Be(orderLine); }
public void IfFileDoesNotExistStreamShouldNotBeWrittenTo() { var order = new Order(); var orderLine = new OrderLineBuilder().WithFileUrl("test-file-url").Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); A.CallTo(() => _fileSystem.Exists("test-file-url")).Returns(false); _downloadProductService.WriteDownloadToResponse(response, order, orderLine); A.CallTo(() => _fileSystem.WriteToStream(A <string> ._, A <Stream> ._)).MustNotHaveHappened(); }
public void IfAnyRuleErrorsStreamShouldNotBeWrittenTo() { var order = new Order(); var orderLine = new OrderLineBuilder().Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); SetRulesStatus(order, orderLine, false); _downloadProductService.WriteDownloadToResponse(response, order, orderLine); A.CallTo(() => _fileSystem.WriteToStream(A <string> ._, A <Stream> ._)).MustNotHaveHappened(); }
public void IfAllChecksPassIncreaseTheDownloadCount() { var order = new Order(); var orderLine = new OrderLineBuilder().WithFileUrl("test-file-url").WithFileName("test-file-name").WithNumberOfDownloads(1).Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); A.CallTo(() => _fileSystem.Exists("test-file-url")).Returns(true); _downloadProductService.WriteDownloadToResponse(response, order, orderLine); orderLine.NumberOfDownloads.Should().Be(2); A.CallTo(() => _session.Update(orderLine)).MustHaveHappened(); }